首先 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等已經被標記過時,可以使用
queryForObject(String sql, Class<T> requiredType)
進行代替,需要返回的是什么類型,就在第三個參數(shù)寫什么類型。比如int類型就寫Integer.class. long類型就寫Long.class