Parameter index out of range (4 > number of parameters,which is 3).
Parameter index out of range (4 > number of parameters,which is 3).
public class UserDAOImpl implements IUserDAO {
\x05private Connection conn = null ;
\x05private PreparedStatement pstmt = null ;
\x05public UserDAOImpl(Connection conn){
\x05\x05this.conn = conn ;
\x05}
\x05
\x05
\x05public User select(String username,String password) throws Exception {
\x05\x05// TODO Auto-generated method stub
\x05\x05User user = null ;
\x05\x05String sql = "SELECT * FROM userinfo WHERE username=?and password=?" ;
\x05\x05this.pstmt = this.conn.prepareStatement(sql) ;
\x05\x05this.pstmt.setString(1,username) ;
\x05\x05this.pstmt.setString(2,password);
\x05\x05ResultSet rs = this.pstmt.executeQuery() ;
\x05\x05if(rs.next()){
\x05\x05\x05System.out.println("ok");
\x05\x05\x05user = new User() ;
\x05\x05\x05user.setUserid(rs.getInt(1));
\x05\x05\x05user.setUsername(rs.getString(2));
\x05\x05\x05
\x05\x05\x05user.setRealname(rs.getString(4));
\x05\x05\x05user.setRoletype(rs.getInt(5));
\x05\x05\x05user.setUserstate(rs.getInt(6));
\x05\x05\x05user.setDesc(rs.getString(7));
\x05\x05}
\x05\x05this.pstmt.close() ;
\x05\x05return user ;
\x05}
\x05
\x05public int userInsert(String username,String password,int roletype) throws Exception
\x05{
\x05\x05String insertCondition = "INSERT INTO userinfo VALUES (null,,,)" ;
\x05\x05this.pstmt = this.conn.prepareStatement(insertCondition) ;
\x05\x05this.pstmt.setString(1,username);
\x05\x05this.pstmt.setString(2,password);
\x05\x05//this.pstmt.setString(3,realname);
\x05\x05this.pstmt.setInt(4,roletype);
\x05\x05//this.pstmt.setInt(5,0);
\x05\x05//this.pstmt.setString(6,desc);
\x05\x05int n = this.pstmt.executeUpdate();
\x05\x05this.pstmt.close() ;
\x05\x05return n;
\x05}
\x05
}
public class UserDAOImpl implements IUserDAO {
\x05private Connection conn = null ;
\x05private PreparedStatement pstmt = null ;
\x05public UserDAOImpl(Connection conn){
\x05\x05this.conn = conn ;
\x05}
\x05
\x05
\x05public User select(String username,String password) throws Exception {
\x05\x05// TODO Auto-generated method stub
\x05\x05User user = null ;
\x05\x05String sql = "SELECT * FROM userinfo WHERE username=?and password=?" ;
\x05\x05this.pstmt = this.conn.prepareStatement(sql) ;
\x05\x05this.pstmt.setString(1,username) ;
\x05\x05this.pstmt.setString(2,password);
\x05\x05ResultSet rs = this.pstmt.executeQuery() ;
\x05\x05if(rs.next()){
\x05\x05\x05System.out.println("ok");
\x05\x05\x05user = new User() ;
\x05\x05\x05user.setUserid(rs.getInt(1));
\x05\x05\x05user.setUsername(rs.getString(2));
\x05\x05\x05
\x05\x05\x05user.setRealname(rs.getString(4));
\x05\x05\x05user.setRoletype(rs.getInt(5));
\x05\x05\x05user.setUserstate(rs.getInt(6));
\x05\x05\x05user.setDesc(rs.getString(7));
\x05\x05}
\x05\x05this.pstmt.close() ;
\x05\x05return user ;
\x05}
\x05
\x05public int userInsert(String username,String password,int roletype) throws Exception
\x05{
\x05\x05String insertCondition = "INSERT INTO userinfo VALUES (null,,,)" ;
\x05\x05this.pstmt = this.conn.prepareStatement(insertCondition) ;
\x05\x05this.pstmt.setString(1,username);
\x05\x05this.pstmt.setString(2,password);
\x05\x05//this.pstmt.setString(3,realname);
\x05\x05this.pstmt.setInt(4,roletype);
\x05\x05//this.pstmt.setInt(5,0);
\x05\x05//this.pstmt.setString(6,desc);
\x05\x05int n = this.pstmt.executeUpdate();
\x05\x05this.pstmt.close() ;
\x05\x05return n;
\x05}
\x05
}
其他人氣:797 ℃時(shí)間:2020-05-08 01:15:48
優(yōu)質(zhì)解答
insert into userinfo() values();userinfo字段補(bǔ)全
我來回答
類似推薦
- java.sql.SQLException:Parameter index out of range (1 > number of parameters,which is 0).
- //獲取頁面修改之前的信息(部分代碼)
- Parameter index out of range (1 > number of parameters, which is 0).
- block number is out of
- C#IndexOutOfRangeException:Array index is out of range怎么解決
- 四通八達(dá)中“達(dá)”什么意思
- 天地不仁,以萬物為芻狗.
- 用血球計(jì)數(shù)板計(jì)算酵母細(xì)胞總數(shù):對(duì)稀釋100倍后的酵母菌懸液計(jì)數(shù),若80小格中細(xì)胞數(shù)
- 富者乞羊 譯文
- 高中數(shù)學(xué)課程中的“函數(shù)”的結(jié)構(gòu)脈絡(luò)
- 描寫水的優(yōu)美句子
- 試證明:對(duì)于任意大于4的合數(shù)p,(p-2)!能被p整除.或舉出反例.
猜你喜歡
- 1世博會(huì)中國(guó)館的太陽能光伏發(fā)電系統(tǒng) 年均提供電能為1.08*10^13J,這意味著每年節(jié)約標(biāo)準(zhǔn)煤為( )噸(設(shè)標(biāo)準(zhǔn)煤完全燃燒,q煤=3.0*10^7J/kg)
- 2l理發(fā)師翻譯成英語
- 3在下列幾種現(xiàn)象中,系統(tǒng)動(dòng)量守恒的是
- 4王老師在新華書店購(gòu)買了《童話精選》和《科學(xué)家的故事》一共花了116元,童話每本2
- 51 she also tried to teach him __ to be quiet because other people wanted to rest.A when B where
- 6求滿足條件:頂點(diǎn)在原點(diǎn),關(guān)于x軸對(duì)稱,并且經(jīng)過點(diǎn)M(2,-4)的拋物線的標(biāo)準(zhǔn)方程,并求出此拋物線的準(zhǔn)線方程.
- 7“鐵錘錘碗錘不碎”.這句話覺得荒謬的理由是什么?覺得有道理的理由是什么?
- 8如圖,已知直線L1平行L2,且L3和L1、L2分別交于A、B兩點(diǎn),點(diǎn)P在直線AB上.
- 9什么無間
- 10333分之33乘101怎樣簡(jiǎn)便計(jì)算
- 11用總分總的形式寫一篇作文
- 121.What do you not like?還是What don't you like?Why do you not like?還是Why don't you like?