【发布时间】:2014-03-24 17:43:18
【问题描述】:
我正在使用这样的 java servlet 更新 oracle 数据库中的密码
Connection con;
PreparedStatement ps,ps1;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Drivers Not Found");
}
try{
con=DriverManager.getConnection("jdbc:odbc:SharedCryptography", "fyp", "fyp");
}catch(SQLException e1)
{
}
String query="UPDATE tbGroup SET GPassword='"+mypassword+"' where GName='"+GroupNamee+"' and OEmail='"+OwnerId+"'";
java.sql.Statement stmt = con.createStatement();
stmt.executeUpdate(query);
但它给出了 java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01756: 引用的字符串未正确终止
我做错了什么吗?请帮忙
【问题讨论】:
-
您的某个值中是否包含单引号字符?
-
@rgettman 你说的是哪个值?
-
当程序员没有正确转义查询参数时会发生这种情况。你真的应该使用准备好的语句
-
@BackSlash 什么意思?请帮忙