You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
745 B
30 lines
745 B
package JDBC;
|
|
import java.io.InputStream;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import java.sql.SQLException;
|
|
import java.util.Properties;
|
|
public class JDBCUtil {
|
|
static String url;
|
|
static Properties info = new Properties();
|
|
static{
|
|
try {
|
|
InputStream in=JDBCUtil.class.getClassLoader().getResourceAsStream("config.properties");
|
|
info.load(in);
|
|
url=info.getProperty("url");
|
|
Class.forName(info.getProperty("driver"));
|
|
} catch (Exception e) {
|
|
// TODO 自动生成的 catch 块
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
public static Connection getConnertion() throws SQLException{
|
|
Connection conn =DriverManager.getConnection(url,info.getProperty("user"),info.getProperty("password"));
|
|
return conn;
|
|
}
|
|
}
|
|
|