|
|
|
@ -0,0 +1,20 @@
|
|
|
|
|
package com.domain;
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
public class GetDBConnection {
|
|
|
|
|
public static Connection connectDB(String DBName,String id,String p) {
|
|
|
|
|
Connection con = null;
|
|
|
|
|
String
|
|
|
|
|
uri = "jdbc:mysql://localhost:3306/"+DBName+"?useSSL=true&characterEncoding=utf-8";
|
|
|
|
|
try{ Class.forName("com.mysql.jdbc.Driver");//<2F><><EFBFBD><EFBFBD>JDBC-MySQL<51><4C><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){}
|
|
|
|
|
try{
|
|
|
|
|
con = DriverManager.getConnection(uri,id,p); //<2F><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
catch(SQLException e){}
|
|
|
|
|
return con;
|
|
|
|
|
}
|
|
|
|
|
}
|