Java Utililty Methods JDBC Driver

List of utility methods to do JDBC Driver

Description

The list of methods to do JDBC Driver are organized into topic(s).

Method

DrivercreateDriver(ClassLoader classLoader, String driverClassName)
create Driver
Class<?> clazz = null;
if (classLoader != null) {
    try {
        clazz = classLoader.loadClass(driverClassName);
    } catch (ClassNotFoundException e) {
if (clazz == null) {
...
DrivercreateDriver(String driverClassName)
create Driver
Class clazz = null;
try {
    ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
    if (contextLoader != null) {
        clazz = contextLoader.loadClass(driverClassName);
} catch (ClassNotFoundException e) {
if (clazz == null) {
    try {
        clazz = Class.forName(driverClassName);
    } catch (ClassNotFoundException e) {
        throw new SQLException(e.getMessage(), e);
try {
    return (Driver) clazz.newInstance();
} catch (IllegalAccessException e) {
    throw new SQLException(e.getMessage(), e);
} catch (InstantiationException e) {
    throw new SQLException(e.getMessage(), e);
DrivercreateDriver(String driverClassName)
create Driver
try {
    return (Driver) Class.forName(driverClassName).newInstance();
} catch (IllegalAccessException e) {
    throw new SQLException(e.getMessage(), e);
} catch (InstantiationException e) {
    throw new SQLException(e.getMessage(), e);
} catch (ClassNotFoundException e) {
try {
    return (Driver) Thread.currentThread().getContextClassLoader().loadClass(driverClassName).newInstance();
} catch (IllegalAccessException e) {
    throw new SQLException(e.getMessage(), e);
} catch (InstantiationException e) {
    throw new SQLException(e.getMessage(), e);
} catch (ClassNotFoundException e) {
    throw new SQLException(e.getMessage(), e);
DrivercreateDriver(String driverClassName)
create Driver
return createDriver(null, driverClassName);
StringgetDriverClassName(String rawUrl)
get Driver Class Name
if (rawUrl.startsWith("jdbc:derby:")) {
    return "org.apache.derby.jdbc.EmbeddedDriver";
} else if (rawUrl.startsWith(MYSQL_PREFIX)) {
    return MYSQL_DRIVER;
} else if (rawUrl.startsWith("jdbc:log4jdbc:")) {
    return LOG4JDBC_DRIVER;
} else if (rawUrl.startsWith("jdbc:mariadb:")) {
    return MARIADB_DRIVER;
...
StringgetDriverClassName(String rawUrl)
get Driver Class Name
if (rawUrl.startsWith("jdbc:mysql:")) {
    return MYSQL_DRIVER;
} else if (rawUrl.startsWith("jdbc:oracle:")) {
    return ORACLE_DRIVER;
} else {
    throw new SQLException("unkow jdbc driver : " + rawUrl);
DrivergetDriverFromPath(String path, String className)
get Driver From Path
URL[] url = { new File(path).toURL() };
URLClassLoader loader = new URLClassLoader(url);
Class c = loader.loadClass(className);
Object instance = c.newInstance();
return (Driver) instance;
String[]getRegisteredDrivers()
get Registered Drivers
if (cashedDriversName == null) {
    Enumeration<Driver> drivers = DriverManager.getDrivers();
    Set<String> set = new HashSet<>();
    while (drivers.hasMoreElements()) {
        Driver driver = drivers.nextElement();
        if (!driver.getClass().getName().contains("fabric")) {
            set.add(driver.getClass().getName());
    cashedDriversName = set.toArray(new String[set.size()]);
return cashedDriversName.clone();
voidgetRSInfo(Object rsObj, int[] rsInfo, long[] rsCounter, Object[] conn, int[] errCode, String[] errDetail)
Method to get data pertaining to a specific result set object.
errCode[0] = 0;
errDetail[0] = "";
Object rsInfoObj = null;
if (!(rsT2Cls_.isInstance(rsObj))) {
    errCode[0] = RS_INFO_ERROR;
    errDetail[0] = "One or more returned result sets are not instances of "
            + "class org.trafodion.jdbc.t2.SQLMXResultSet";
    return;
...
StatementgetStatement()
Get db statement
try {
    Connection conn = getConnection();
    Statement stmt = conn.createStatement();
    statConns.put(stmt, conn);
    return stmt;
} catch (Exception e) {
    return null;