Java 帮我查一下错误

来源:百度知道 编辑:UC知道 时间:2024/07/02 21:19:26
private Connection con;

public void insertUser(String usrname,String password,String ask,String question,String permisson,String sex,int age,String regtime,String lasttime,long score,String introduce,String img,String rank,String state)
{
this.con=DateBaseConnection.getConnection();
Statement stmt=con.createStatement();
String usenote="INSERT INTO user(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)VALUES(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)";
stmt.executeUpdate(usenote);
stmt.close();
con.close();

}

错误提示:未处理的异常类型 SQLException
没有错误 已经编译通过了

String usenote="INSERT INTO user(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)VALUES(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)";

你这写的是字符串,values后面那些不是变量赋值
插入数据库的时候类型不匹配
-----------------------------------------
我好象理解错了
如果是编译未通过,以上请无视
laogao正解

try{
this.con=DateBaseConnection.getConnection();
Statement stmt=con.createStatement();
String usenote="INSERT INTO user(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)VALUES(usrname,password,ask,question,permisson,sex,age,regtime,lasttime,score,introduce,img,rank,stage)";
stmt.executeUpdate(usenote);
catch(Exception e){
e.printStackTrace();
}
stmt.close();
con.close();
}

ok

哥们可能是你getConnection(); 方法里面有错误 能不能 贴出来看下