Java Database Driver Name Get getDriverClassNameByJdbcUrl(String url)

Here you can find the source of getDriverClassNameByJdbcUrl(String url)

Description

get Driver Class Name By Jdbc Url

License

Apache License

Declaration

public static String getDriverClassNameByJdbcUrl(String url) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String getDriverClassNameByJdbcUrl(String 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";
        } else if (url.startsWith("jdbc:h2:")) {
            return "org.h2.Driver";
        } else {/*from w  w w  .j a  va  2 s.  com*/
            return "";
        }
    }
}

Related

  1. addDriver(String database, String jdoDriver, String driverClass, String urlPrefix, String sampleURL, String properties)
  2. driverClass(String url)
  3. getDriver(String dbms)
  4. getDriverClassName(String driver)
  5. getDriverName(String dbType)
  6. getTypes()