String pwd1=(String)session.getAttribute("user");// 获得session中的usid
String password1=request.getParameter("mm");
String password2=request.getParameter("qrmm");
System.out.println(pwd1);
System.out.println(password1);
System.out.println(password2);
if(password1.equals(password2))
{
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
String user = "root";
String password = "root";
String url = "jdbc:mysql://localhost/webkj?useunicode=true&characterEncoding=gbk";
conn = DriverManager.getConnection(url, "root", "root");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
String sql="update t_user set uspwd=? where usid=?";
//Statement stmt = conn.createStatement();
//int success = stmt.executeUpdate(sql);
//Statement stmt = conn.createStatement();
PreparedStatement pstmt= conn.prepareStatement(sql);
pstmt.setString(1,"password1");
pstmt.setString(2,"pwd1");
pstmt.executeUpdate();
总是说我的sql语句错误,我该怎么写啊。
String password1=request.getParameter("mm");
String password2=request.getParameter("qrmm");
System.out.println(pwd1);
System.out.println(password1);
System.out.println(password2);
if(password1.equals(password2))
{
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
String user = "root";
String password = "root";
String url = "jdbc:mysql://localhost/webkj?useunicode=true&characterEncoding=gbk";
conn = DriverManager.getConnection(url, "root", "root");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
String sql="update t_user set uspwd=? where usid=?";
//Statement stmt = conn.createStatement();
//int success = stmt.executeUpdate(sql);
//Statement stmt = conn.createStatement();
PreparedStatement pstmt= conn.prepareStatement(sql);
pstmt.setString(1,"password1");
pstmt.setString(2,"pwd1");
pstmt.executeUpdate();
总是说我的sql语句错误,我该怎么写啊。
解决方案 »
- 如何將做好的電腦網頁可以在手機上觀看
- null与""的问题
- myeclipse如何导入jsp文件阿?
- 一个自定义标签的问题,很简单的,就是图形显示不出来,请大家帮我看看,我是各种方法都用尽了,唉(块烦死了)
- 请教层的问题!
- 两个选择框,选定第一个选择框的一项时,第二个选择框的那些下拉值就相对应的变了,如何实现(在线!)
- 有没有什么办法可以对所有javabean做一次对SET方法统一的调度
- <jsp:setProperty name="user" property="*"/>
- ??谁遇到这样的问题,重定向到jsp页面,不运行,反而要下载。
- [求助]关于request header设置的问题
- xtream 把对象转换成xml时 string数组的处理问题
- 如何让div显示在Iframe上面呢?
还有就是,Connection conn放在if里边,下面那个conn会不报错?
------
LZ: sql语句没错,你的user里面就放了usid吗?
之后的System.out.println(pwd1);
检验了,pwd1是我想要的值。