首页 > 数据库技术 > 详细

java项目中读取jdbc.properties文件

时间:2018-09-07 12:42:04      阅读:288      评论:0      收藏:0      [点我收藏+]

java项目中读取jdbc.properties文件

转载于:https://blog.csdn.net/wanzhix/article/details/53640312

java内容

1 Properties props = Resources.getResourceAsProperties("jdbc.properties");
2 String url = props.getProperty("jdbc.url");
3 String driver = props.getProperty("jdbc.driverClass");
4 String username = props.getProperty("jdbc.username");
5 String password = props.getProperty("jdbc.password");
6 Class.forName(driver).newInstance();
7 Connection conn = (Connection) DriverManager.getConnection(url, username, password);

 

jdbc.properties文件内容

 1 jdbc.driverClass = com.mysql.jdbc.Driver
 2 jdbc.url = jdbc\:mysql\://127.0.0.1\:3306/db?useUnicode\=true&characterEncoding\=UTF-8&zeroDateTimeBehavior\=convertToNull&allowMultiQueries\=true
 3 jdbc.username = root
 4 jdbc.password = root
 5 jdbc.minPoolSize=2
 6 jdbc.maxPoolSize=20
 7 jdbc.checkoutTimeout=3000
 8 jdbc.maxStatements=50
 9 jdbc.testConnectionOnCheckin = false
10 jdbc.idleConnectionTestPeriod =18000

 

java项目中读取jdbc.properties文件

原文:https://www.cnblogs.com/carsonwuu/p/9603573.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!