Java Utililty Methods Database Driver Name Get

List of utility methods to do Database Driver Name Get

Description

The list of methods to do Database Driver Name Get are organized into topic(s).

Method

voidaddDriver(String database, String jdoDriver, String driverClass, String urlPrefix, String sampleURL, String properties)
add Driver
int length = drivers.length;
String[] newList = new String[length + 5];
System.arraycopy(drivers, 0, newList, 5, length);
drivers[0] = database;
drivers[1] = database;
drivers[2] = database;
drivers[3] = database;
drivers[4] = database;
...
StringdriverClass(String url)
Given a jdbc url, this tries to determine the target database and returns the driver class name as a string.
assert !blank(url);
if (url.contains(POSTGRESQL_FRAGMENT)) {
    return "org.postgresql.Driver";
if (url.contains(MYSQL_FRAGMENT)) {
    return "com.mysql.jdbc.Driver";
if (url.contains(HSQL_FRAGMENT)) {
...
StringgetDriver(String dbms)
get Driver
if (dbms.equalsIgnoreCase(MYSQL))
    return "com.mysql.jdbc.Driver";
if (dbms.equalsIgnoreCase(POSTGRESQL))
    return "org.postgresql.Driver";
if (dbms.equalsIgnoreCase(SQLSERVER))
    return "net.sourceforge.jtds.jdbc.Driver";
if (dbms.equalsIgnoreCase(ORACLE))
    return "oracle.jdbc.OracleDriver";
...
StringgetDriverClassName(String driver)
Given a driver type(such as mysql), return its jdbc driver class name.
if (driver.equals("mysql")) {
    return "com.mysql.jdbc.Driver";
if (driver.equals("sqlite")) {
    return "org.sqlite.JDBC";
} else {
    throw new Exception("Not tested jdbc driver type: " + driver);
StringgetDriverClassNameByJdbcUrl(String url)
get Driver Class Name By Jdbc Url
if (url.startsWith("jdbc:mysql:")) {
    return "com.mysql.jdbc.Driver";
} else if (url.startsWith("jdbc:postgresql:")) {
    return "org.postgresql.Driver";
} else if (url.startsWith("jdbc:sqlserver:")) {
    return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
} else if (url.startsWith("jdbc:jtds:sqlserver:")) {
    return "net.sourceforge.jtds.jdbc.Driver";
...
StringgetDriverName(String dbType)
get Driver Name
String driverName = "";
switch (dbType) {
case DBTYPE_MYSQL:
    driverName = "com.mysql.jdbc.Driver";
    break;
case DBTYPE_ORACLE:
    driverName = "oracle.jdbc.driver.OracleDriver";
    break;
...
String[][]getTypes()
get Types
return sJDBCTypes;