Java Database Driver Name Get getDriver(String dbms)

Here you can find the source of getDriver(String dbms)

Description

get Driver

License

Open Source License

Parameter

Parameter Description
dbms The name of a DBMS (MySQL, PostGreSQL, ...)

Return

A driver name that can be used in the getConnection() function.

Declaration

public static String getDriver(String dbms) 

Method Source Code

//package com.java2s;
/*//from   w  w  w.j  a v a2  s  .c  o m
Weave (Web-based Analysis and Visualization Environment)
Copyright (C) 2008-2011 University of Massachusetts Lowell
    
This file is a part of Weave.
    
Weave is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, Version 3,
as published by the Free Software Foundation.
    
Weave is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    public static String MYSQL = "MySQL";
    public static String POSTGRESQL = "PostgreSQL";
    public static String SQLSERVER = "Microsoft SQL Server";
    public static String ORACLE = "Oracle";

    /**
     * @param dbms The name of a DBMS (MySQL, PostGreSQL, ...)
     * @return A driver name that can be used in the getConnection() function.
     */
    public static String getDriver(String dbms) {
        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";
        return "";
    }
}

Related

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