哪错啊!急

来源:百度知道 编辑:UC知道 时间:2024/06/18 13:06:08
import java.sql.*;
public class conbean{
private Connection con;
private Statement st;
private ResultSet rs;
public conbean(){
}
public void getcon(){
con=null;
st=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/users","root","490507724");
st=con.createStatement();
}catch(Exception e){
e.printStackTrace();
}
}
public ResultSet login(String user,String pwd){
rs=null;
getcon();
try{
rs=st.executeQuery("select*from user where user='"+user"' and pwd='"pwd"'");
}catch(Exception e){
e.printStackTrace();
}
return rs;
}

public int update(String user,String pwd){
int pet=0l;
getcon();
try{
pet=st.exectuteUqdate("i

executeUpdate写成了exectuteUqdate
01写成了0l(不是字母L)是数字1
("select*from user where user='"+user"' and pwd='"pwd"'");这句sql写错了 "select*from user where user= '"+user+"' and pwd='"+pwd+" "

如果你用 Hibernate映射的话,你应该用类似st.setString(1,user),这样的方式来设置值。

如果是JDBC方式操作,则应该在SQL语句中用''把字符串型的引起来.

("select*from user where user='"+user"' and pwd='"pwd"'");又错在哪

你这个怎么加来着?