首先 Spring jdbc API
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jdbc/core/JdbcTemplate.html
數(shù)據(jù)庫查詢函數(shù):
jdbcTemplate.query(sql,new Object[]{UserID,password});
sql為提交的SQL語句,允許使用帶?的參數(shù)占位符浩淘,queryForInt()會自動將后面的UserID、password依次代入津函。
spring 3.2.2之后,jdbctemplate中的queryForInt孤页、queryForLong等已經(jīng)被標記過時尔苦,可以使用
queryForObject(String sql, Class<T> requiredType)
進行代替,需要返回的是什么類型行施,就在第三個參數(shù)寫什么類型允坚。比如int類型就寫Integer.class. long類型就寫Long.class