String sql = String.format("select count(*) from user where name='%s' and password='%s';", userName, userPass); int row = 0; jb.queryForObject(sql, Integer.class, row );
根據 row 的值來判斷是否有該用戶。html
Parameter index out of range (1 > number of parameters, which is 0)
測試後沒問題java
format 語句錯誤,檢查後發現沒錯sql
int 改成 integer ,改後也沒有變化數據庫
好像是說 jb.queryForObject(sql, Integer.class, row ); 有問題。網上查了下,改成:post
Integer row = (Integer) jb.queryForObject( "select count(*) from user where name=? and password=?",new Object[] {userName, userPass}, java.lang.Integer.class);