我在insert into statement中遇到语法错误。
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3149)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:216)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatement.java:138)
at com.cron.LockboxReports.execute(Reports.java:174)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:534)
这里查询
String sql2 = "INSERT INTO Report (Age,GoLive,Number,CustomerName,Address,Status,SubStatus,Sqrt,Type,Code,Deposit,filesend,approved,sendtoClient,byClient,fileapproved,TestSetups,Images,ImApproved,ProdSetupsAt,TSApprov,ToClient,ReceivedbyClient,ReceivedApproved,ItemsSent,ItemsApproved,ODsend,Approved,TotalEmail,Verified,fyCut,CodeToProd,CodeToComplete,Request,Complete) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
preparedstatement = con3.prepareStatement(sql2);
//Statement stmt = con3.createStatement();
preparedstatement.setString(1, Age);
....
preparedstatement.executeUpdate();
我已经尝试过选择查询,它的wokring文件。所以odbc连接很好。只有问题是查询...你能帮我吗。
答案 0 :(得分:2)
准备好的声明中缺少一个?。检查它的查询。您的表中有35个字段,34个?
String sql2 = "INSERT INTO Report(Age,GoLive,Number,CustomerName,Address,Status,SubStatus,Sqrt,Type,Code,Deposit,filesend,**approved**,sendtoClient,byClient,fileapproved,TestSetups,Images,ImApproved,ProdSetupsAt,TSApprov,ToClient,ReceivedbyClient,ReceivedApproved,ItemsSent,ItemsApproved,ODsend,**Approved**, TotalEmail,Verified,fyCut,CodeToProd,CodeToComplete,Request,Complete) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
您的表格中有两列同名已批准但问题正确无误。
使用这个
preparedstatement stmt= con3.prepareStatement(sql2);
//Statement stmt = con3.createStatement();
stmt.setString(1, Age);
stmt.executeUpdate();