* @return Connection
* @exception CreateConnectionFailureException
*/
public static Connection createConnection(JdbcConnectionContext dcc) {
if (dcc == null)
throw new CreateConnectionFailureException(
"createConnection failure: dcc is null.");
beforeConnection(dcc);
Connection connection = null;
if (dcc.useLoginForConnection()) {
connection = createConnection(dcc.getDriverClassName(), dcc.getUrl(),
loginUsername(), loginPassword(), dcc.getLoginTimeout());
}
else {
if (dcc.getUsername() == null) {
connection = createConnection(dcc.getDriverClassName(), dcc
.getUrl(), dcc.getLoginTimeout());
} else {
connection = createConnection(dcc.getDriverClassName(), dcc
.getUrl(), dcc.getUsername(), dcc.getPassword(), dcc
.getLoginTimeout());
}
}
if (connection == null)
throw new CreateConnectionFailureException(
"createConnection() failed for connection name: "
+ dcc.getConnectionName());
checkReadonly(connection, dcc);
checkAutoCommit(connection, dcc);