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() 

Method Source Code


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

import java.sql.*;

public class Main {
    public static Connection getConnection() {
        Connection conn = null;//w  w  w. j ava  2s.co  m
        String url = "jdbc:mysql://localhost:3306/record";
        String user = "root";
        String password = "123";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(url, user, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
}

Related

  1. createConnection(String url, String user, String password)
  2. createConnectionUtf8(String connString)
  3. createTable(String dbFile, String tableName, String tableDefinition)
  4. deleteTableData(String tableName)
  5. getAllNames()
  6. getConnection()
  7. getConnection()
  8. getConnection()
  9. getConnection()