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 ClassNotFoundException, SQLException 

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;

    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        if (null == conn) {
            connect();//from w  ww .  java2  s  .  c om
        }
        return conn;
    }

    public static Connection connect() throws ClassNotFoundException, SQLException {
        if (conn == null) {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://sqld.duapp.com:4050/rzUowhpAxCAvlnfNPBqx",
                    "N1iOGk7wiI5mecGukBwtwP8D", "VXSsFTyN1NQF3f13qtte29EWKsc2Kucu");
        }
        return conn;
    }
}

Related

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