日期:2014-05-18 浏览次数:20755 次
public class ConnectionProvider {
static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static String DBURL = "jdbc:mysql://localhost:3306/recipe";
static String USERNAME = "root";
static String PW = "poiu0000";
public static Connection connection = null;
static {
try {
Class.forName(JDBC_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println("Where is Driver?");
e.printStackTrace();
// return null;
}
System.out.println("Registered!");
try {
connection = DriverManager.getConnection(DBURL, USERNAME, PW);
System.out.println("Connected!!!");
} catch (SQLException ee) {
System.out.println("Connection Failed! ");
ee.printStackTrace();
// return null;
}
}
public static Connection getConnection() {
return connection;
}
}
public class ConnectionProvider {
static String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static String DBURL = "jdbc:mysql://localhost:3306/recipe";
static String USERNAME = "root";
static String PW = "poiu0000";
public static Connection connection = null;
static {
try {
Class.forName(JDBC_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println("Where is Driver?");
e.printStackTrace();
// return null;
}
System.out.println("Registered!");
}
public static Connection getConnection() {
&nb