JAVA代码如下:
String projectID=request.getParameter("projectid");//得到项目的唯一ID号
Session dbSession=mySessionFactory.getSession();
Transaction tx = dbSession.beginTransaction();
Connection conn=dbSession.connection();//取得Session的JDBC连接
Statement stmtProject=conn.createStatement();
String tmpStr;
try
{
//使用JDBC删除plan_sun_project表中满足条件的记录
tmpStr="delete from PLAN_SUN_PROJECT where PROJECTID="+projectID;
stmtProject.executeUpdate(tmpStr);//在此处出错
tx.commit();
}
catch (Exception e)
{
tx.rollback();
System.out.println(e.getMessage());
return null;
}
提示的错误是:ORA-00933: SQL 命令未正确结束。请大家帮忙。谢谢
String projectID=request.getParameter("projectid");//得到项目的唯一ID号
Session dbSession=mySessionFactory.getSession();
Transaction tx = dbSession.beginTransaction();
Connection conn=dbSession.connection();//取得Session的JDBC连接
Statement stmtProject=conn.createStatement();
String tmpStr;
try
{
//使用JDBC删除plan_sun_project表中满足条件的记录
tmpStr="delete from PLAN_SUN_PROJECT where PROJECTID="+projectID;
stmtProject.executeUpdate(tmpStr);//在此处出错
tx.commit();
}
catch (Exception e)
{
tx.rollback();
System.out.println(e.getMessage());
return null;
}
提示的错误是:ORA-00933: SQL 命令未正确结束。请大家帮忙。谢谢
System.out.println(tmpStr);
stmtProject.executeUpdate(tmpStr);//在此处出错 加一行,打出Sql,拿到数据库工具中执行,肯定是sql拼的有一些问题.
比较大的可能性是projectID为null,这样你的sql就变成:
delete from PLAN_SUN_PROJECT where PROJECTID=null
PROJECTID这个字段是数字还是字符串?
如果是字符串,记得加引号。
如果不是的,请这样写那条语句:
tmpStr="delete from PLAN_SUN_PROJECT where PROJECTID='"+projectID+"'";
prep.setString(1, projectID); 或者 prep.setInt(1, Integer.parseInt(projectID));
prep.executeUpdate();
这样才是好的习惯