Java JDBC MySQL Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Apache License

Declaration

public static java.sql.Connection getConnection() 

Method Source Code

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

import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
    private static java.sql.Connection con;

    public static java.sql.Connection getConnection() {
        try {//from  w w w.ja  va  2 s. c o  m
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/banco07";
            con = DriverManager.getConnection(url, "root", "");
            con.setAutoCommit(true);
            return con;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException se) {
            se.printStackTrace();
        }
        return null;
    }
}

Related

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