moneymore 发表于 2013-1-30 01:39:28

读取property文件中的数据库配置

java:
Properties props = new Properties();FileInputStream in = new FileInputStream("database.properties");props.load(in);in.close();String drivers = props.getProperty("jdbc.driver");String url = props.getProperty("jdbc.url");String username = props.getProperty("jdbc.username");String password = props.getProperty("jdbc.password");return DriverManager.getConnection(url, username, password); database.properties:
jdbc.drivers=org.postgresql.Driverjdbc.url=jdbc:postgresql:COREJAVAjdbc.username=dbuserjdbc.password=secret 
ok
 
页: [1]
查看完整版本: 读取property文件中的数据库配置