//根据userId查询注册用户信息
@Override
public ContactInfo findByUserId(String userId) {
ContactInfo contactInfo = null;
String sql = "select address1,address2,zip,email,homephone" +
"cellphone,officephone where userid = ?";
con = JdbcUtil.getConnection();
try {
ps = con.prepareStatement(sql);
ps.setString(1, userId);
rs = ps.executeQuery();
if(rs.next()){
contactInfo = new ContactInfo();
contactInfo.setAddress1(rs.getString(1));
contactInfo.setAddress2(rs.getString(2));
contactInfo.setZip(rs.getString(3));
contactInfo.setEmail(rs.getString(4));
contactInfo.setHomephone(rs.getString(5));
contactInfo.setCellphone(rs.getString(6));
contactInfo.setOfficephone(rs.getString(7));
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
JdbcUtil.release(rs, ps, con);
}
return contactInfo;
}运行后报以下异常:
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where userid = '12'' at line 1请问:报这个异常是什么意思?问什么会报这个异常?
该如何改正?谢谢各位!