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 Exception 

Method Source Code


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

import java.sql.*;

public class Main {
    private static final String url = "jdbc:mysql://127.0.0.1:3307/user";
    private static final String user = "root";
    private static final String password = "010203";
    private static Connection conn = null;

    public static Connection getConnection() throws Exception {
        if (conn == null) {
            conn = DriverManager.getConnection(url, user, password);
            return conn;
        }//from w  w w . j  ava2 s.com
        return conn;
    }
}

Related

  1. getConnection()
  2. getConnection()
  3. getConnection()
  4. getConnection()
  5. getConnection()
  6. getConnection()
  7. getConnection()
  8. getConnection()
  9. getConnection(final String host, final int port, final String schema, final String user, final String password)