Java JDBC MySQL Connection openConnection()

Here you can find the source of openConnection()

Description

open Connection

License

Apache License

Declaration

private static void openConnection() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

import java.sql.Statement;

public class Main {
    private static Connection mConn = null;
    private static Statement mStmt = null;

    private static void openConnection() {
        try {//  www  .  j  av  a2 s  .  c o  m
            Class.forName("com.mysql.jdbc.Driver");
            mConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/source_products", "root", "123");
            mStmt = mConn.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. getMySQLConnection(String hostName, String dbName, String userName, String password)
  2. getMysqlIndices(String conString)
  3. getNewDatabaseConnection(String dbUser, String dbPassword)
  4. getRssminerDB()
  5. getSearchReaderConnection()
  6. putData(int tID, String toolID)
  7. query(String sql)
  8. queryAll(String sql, List params)
  9. readMapListBySQL(String driverClass, String host, String port, String database, String user, String password, String sql)

  10. HOME | Copyright © www.java2s.com 2016