【281天】每日项目总结系列019(2017.11.13)

叨叨两句

  1. ~

JDBC

1.注册驱动 DriverManager.registerDriver()
2.获得连接 DriverManager.getConnection(url,user,password)
3.创建执行SQL语句的对象 connection.prepareStatement(sql) prepareStatement.setString(index,value)
4.执行SQL语句 prepareStatement.excuteQuery/excuteUpdate()
5.关闭资源 close()

使用配置文件解决硬编码的问题

properties文件的读取方式

Properties properties = new Properties()
将文件转换成流的两种方式new FileInputStream(文件路径)

classLoader.getResourceAsStream("文件名")
properties.load(inStream)

ResourceBundle bundle = ResouceBundle.getBundle('文件名不包含后缀')
bundle.getString(name)

评论

暂无评论