Get Database JDBC Connection

Return an active JDBC Connection Object.

Javadoc available at https://www.javatapas.com/docs/javatapas/sql/GetDatabaseConnection.html


public static Connection getDatabaseConnection(String dbDriver,
					String dbPreface,
					String dbHostName,
					String dbPort,
					String dbSchemaName,
					String dbParams,
					String dbUser,
					String dbPassword,
					String dbLoginTimeout) throws SQLException, ClassNotFoundException {

	Class.forName(dbDriver);

	String connStr = "jdbc:" + dbPreface + "://" + dbHostName + (dbPort == null ? "" : ":" + dbPort) + "/" + dbSchemaName + (dbParams == null ? "" : dbParams);

	if (dbLoginTimeout != null){DriverManager.setLoginTimeout(Integer.valueOf(dbLoginTimeout));}

	Connection conn = DriverManager.getConnection(connStr, dbUser, dbPassword);

	return conn;

}