标签:logs highlight oca com for 并且 resource sharp base
首先在数据库中有properties文件
里面的内容以键值对的方式出现
例如
driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/test user=root pwd=950218
然后设置一个类进行读取里面的driver,url等
例如:
public class MasterUtil { private static String url; private static String user; private static String pwd; static{ ResourceBundle rbundle = ResourceBundle.getBundle("database"); String driver = rbundle.getString("driver"); try { Class.forName(driver); //这个是加载数据库的驱动,调用了文件里的driver; url = rbundle.getString("url"); user = rbundle.getString("user"); pwd = rbundle.getString("pwd"); } catch (Exception e) { e.printStackTrace(); } } }
标签:logs highlight oca com for 并且 resource sharp base
原文地址:http://www.cnblogs.com/goodtimealways/p/6995056.html