C
chy.com
Unregistered / Unconfirmed
GUEST, unregistred user!
如题。还有
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://172.16.33.125:3306/gxdb?user=root&useUnicode=true;characterEncoding=8859_1";
con=(org.gjt.mm.mysql.Connection)DriverManager.getConnection(url,"root","");
//创建一个JDBC声明
Stmt = (org.gjt.mm.mysql.Statement)con.createStatement();
// String sql1="Insert into user(name,loginname,password,power,memo) values ('"+name+"','"+Loginname+"','"+password+"',"+power+",'"+memo+"')";
//out.println("SQL: "+sql1);
rst=(org.gjt.mm.mysql.ResultSet)Stmt.executeQuery("Insert into gxdb.user(name,loginname,password,power) values ('"+name+"','"+Loginname+"','"+password+"','"+power+"','"+memo+"')");
rst.close();
Stmt.close();
con.close();
out.println("用户添加成功!");
}
catch (SQLException E) {
out.println("SQLException: "+E.getMessage()+"<br><br>");
out.println("SQLException: "+E.getErrorCode()+"<br><br><br><br>");
}
其中
String sql1="Insert into user(name,loginname,password,power,memo) values ('"+name+"','"+Loginname+"','"+password+"',"+power+",'"+memo+"')";
rst=(org.gjt.mm.mysql.ResultSet)Stmt.executeQuery("Insert into gxdb.user(name,loginname,password,power) values ('"+name+"','"+Loginname+"','"+password+"','"+power+"','"+memo+"')");
哪里有错?可不可以在executeQuery()中写成sql1?
还有我的mysql怎么不能输入中文阿
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://172.16.33.125:3306/gxdb?user=root&useUnicode=true;characterEncoding=8859_1";
con=(org.gjt.mm.mysql.Connection)DriverManager.getConnection(url,"root","");
//创建一个JDBC声明
Stmt = (org.gjt.mm.mysql.Statement)con.createStatement();
// String sql1="Insert into user(name,loginname,password,power,memo) values ('"+name+"','"+Loginname+"','"+password+"',"+power+",'"+memo+"')";
//out.println("SQL: "+sql1);
rst=(org.gjt.mm.mysql.ResultSet)Stmt.executeQuery("Insert into gxdb.user(name,loginname,password,power) values ('"+name+"','"+Loginname+"','"+password+"','"+power+"','"+memo+"')");
rst.close();
Stmt.close();
con.close();
out.println("用户添加成功!");
}
catch (SQLException E) {
out.println("SQLException: "+E.getMessage()+"<br><br>");
out.println("SQLException: "+E.getErrorCode()+"<br><br><br><br>");
}
其中
String sql1="Insert into user(name,loginname,password,power,memo) values ('"+name+"','"+Loginname+"','"+password+"',"+power+",'"+memo+"')";
rst=(org.gjt.mm.mysql.ResultSet)Stmt.executeQuery("Insert into gxdb.user(name,loginname,password,power) values ('"+name+"','"+Loginname+"','"+password+"','"+power+"','"+memo+"')");
哪里有错?可不可以在executeQuery()中写成sql1?
还有我的mysql怎么不能输入中文阿