咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
我的config.properties放在了web工程的src目录下。
properties配置文件内容
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@10.1.55.241:1521:test
jdbc.username=landui
jdbc.password=landui
jdbc.show_sql=true
调用这些信息连接来数据库.一般是在dao类里. ResourceBundle bundle = ResourceBundle.getBundle("DBConfig"); String driver = bundle.getString("driver"); String url = bundle.getString("url"); String user = bundle.getString("user"); String password = bundle.getString("password"); try { Class.forName(driver); conn = DriverManager.getConnection(url, user, password); } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } catch (SQLException e) { System.out.println(e.getMessage()); }