ConnDB.java~10~
上传用户:toby828
上传日期:2015-06-26
资源大小:8558k
文件大小:1k
- package core;
- import java.sql.*;
- import java.util.Properties;
- import java.io.*;
- public class ConnDB {
- public Connection conn=null;
- public ResultSet rs=null;
- public Statement stmt=null;
- private static String propFileName="connDB.properties";
- private static Properties prop=new Properties();
- private static String dbClassName =
- "com.mysql.jdbc.Driver";
- private static String dbUrl =
- "jdbc:mysql://127.0.0.1:3306/db_libraryManage";
- private static String dbUser = "admin";
- private static String dbPwd = "111";
- private static void loadProperty() {
- try {
- prop.load(new FileInputStream(propFileName)); //通过文件输入流对象加载Properties文件
- dbClassName = prop.getProperty("DB_CLASS_NAME");
- dbUrl = prop.getProperty("DB_URL",
- "jdbc:mysql://127.0.0.1:3306/db_libraryManage");
- dbUser = prop.getProperty("DB_USER", "admin");
- dbPwd = prop.getProperty("DB_PWD", "111");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }