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

叨叨两句

  1. ~sql

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文件的读取方式url

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

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

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