import java.sql.*;
public class DBConnection {
private static Connection con;
public static Connection getMySQLConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost/ray", "root", "root");
}
catch(ClassNotFoundException e) {
System.out.println("Sorry, you get a ClassNotFoundException");
}
catch(SQLException e) {
System.out.println("Sorry, you get a SQLException");
}
if (con == null) {
System.out.println("con is null");
}
return con;
}
}
人到中年有点甜
陪伴而非守候