Java JDBC MySQL Connection getJtdsConnection()

Here you can find the source of getJtdsConnection()

Description

get Jtds Connection

License

Open Source License

Declaration

@SuppressWarnings("unused")
    private static Connection getJtdsConnection() throws SQLException, ClassNotFoundException 

Method Source Code

//package com.java2s;
/*//from   www .  j  a  v a 2 s  .c o m
 * Copyright (C) 2014 Picon software
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
    @SuppressWarnings("unused")
    private static Connection getJtdsConnection() throws SQLException, ClassNotFoundException {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");

        return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/ebs_DATADUMP", "eve", "eve");
    }

    public static Connection getConnection(String connectionType) throws SQLException, ClassNotFoundException {
        switch (connectionType) {
        case "sqlite":
            return getSqliteConnection();
        case "mysql":
            return getMySQLConnection();
        case "jtds":
        default:
            return getJtdsConnection();
        }
    }

    @SuppressWarnings("unused")
    private static Connection getSqliteConnection() throws SQLException, ClassNotFoundException {
        Class.forName("org.sqlite.JDBC");

        return DriverManager.getConnection("jdbc:sqlite:E:/git-views/sqlite-latest.sqlite", "", "");
    }

    @SuppressWarnings("unused")
    private static Connection getMySQLConnection() throws SQLException, ClassNotFoundException {
        Class.forName("com.mysql.jdbc.Driver");

        return DriverManager.getConnection("jdbc:mysql://localhost:3306/eve_dump", "root", "");
    }
}

Related

  1. getDBConnection(String urlFormat, String host, Integer port, String database, String user, String password)
  2. getDMPConn()
  3. getGoogleCloudDBConnection()
  4. getIonMassList()
  5. getJdbcConnection(String host, int port, String name, String user, String password)
  6. getMaxID()
  7. getMysqlCon(String ip, String port, String dbname, String username, String password)
  8. getMysqlConnection(final String url)
  9. getMySQLConnection(Properties props)