0

I'm getting syntax error in 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)

Here query

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(); 

I have tried with select query , its wokring file.So odbc connection is good.Only problem is query...could you please help me.

4

1 回答 1

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(); 
于 2012-12-11T03:10:59.310 回答