Java JDBC MySQL Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection() throws SQLException, ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

import java.sql.SQLException;

public class Main {
    private static Connection conn;
    private static final String mysqlDriver = "com.mysql.jdbc.Driver";
    private static final String mysqlURL = "jdbc:mysql://localhost:3306/course";
    private static final String username = "course6";
    private static final String password = "course6";

    public static Connection getConnection() throws SQLException, ClassNotFoundException {

        Class.forName(mysqlDriver);
        conn = DriverManager.getConnection(mysqlURL, username, password);
        return conn;
    }/*from  w  ww. ja  v a 2 s.  c o m*/
}

Related

  1. getConnection()
  2. getConnection()
  3. getConnection()
  4. getConnection()
  5. getConnection()
  6. getConnection()
  7. getConnection()
  8. getConnection()
  9. getConnection()