日期:2014-05-18  浏览次数:20716 次

JAVA连接数据库中用到PreparedStatement遇到的问题求教?
一直提示:java.sql.SQLException:   [Microsoft][SQLServer   2000   Driver   for   JDBC][SQLServer]必须声明变量   '@P1 '。

我的JAVA代码:
pstmt   =   conn.prepareStatement( " "   +
"insert   into   UserInfo( "   +
"userid, "   +
"username, "   +
"userpassword, "   +
"useremail, "   +
"usertruename, "   +
"usercodeid, "   +
"userposacalcode, "   +
"usersex, "   +
"usersheng, "   +
"usercity, "   +
"userxian, "   +
"userphone, "   +
"usermobile, "   +
"userjianjie)   values   (?,?,?,?,?,?,?,?,?,?,?,?,?,?) ");

/*
  *   计算出递增的用户ID
  */
++idNumber;
UserId   =   UserId   +   idNumber;

pstmt.setString(1,UserId);   //插入用户ID号
pstmt.setString(2,userinfo.getUserName());
pstmt.setString(3,userinfo.getUserPassWord());
pstmt.setString(4,userinfo.getUserEmail());
pstmt.setString(5,userinfo.getUserRealName());
pstmt.setString(6,userinfo.getUserShengFenCode());
pstmt.setString(7,userinfo.getUserPocal());
pstmt.setString(8,userinfo.getUserSex());
pstmt.setString(9,userinfo.getSheng());
pstmt.setString(10,userinfo.getCity());
pstmt.setString(11,userinfo.getXian());
pstmt.setString(12,userinfo.getTel());
pstmt.setString(13,userinfo.getMobilePhone());
pstmt.setString(14,userinfo.getDescription());
我看着这些参数都没问题的啊?请各们兄弟指教?

------解决方案--------------------
驱动包引了没有?
------解决方案--------------------
看看userinfo是怎么写的吧。。。。。。。。。。。。