You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
Hi,
I am trying to run the following SQL on MySQL database using JDBC.
INSERT INTO PRODUCTS (ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES (12345,'TestProduct',5,1,30,1.3,40,4,15,0)
and getting the following error.
org.nw.exception.ProductException: org.nw.exception.DataAccessException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'org.nw.types.impl.ProductImpl@4aea69ed' at line 1
at org.nw.dao.impl.mysql.ProductDAOImpl.createProduct(ProductDAOImpl.java:53)
at org.nw.dao.impl.mysql.test.ProductDAOImplTest.testCreateProductClean(ProductDAOImplTest.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:643)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:559)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:723)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1027)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
at org.testng.TestRunner.runWorkers(TestRunner.java:953)
at org.testng.TestRunner.privateRun(TestRunner.java:633)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:316)
at org.testng.SuiteRunner.run(SuiteRunner.java:195)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:903)
at org.testng.TestNG.runSuitesLocally(TestNG.java:872)
at org.testng.TestNG.run(TestNG.java:780)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:75)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:127)
Caused by: org.nw.exception.DataAccessException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'org.nw.types.impl.ProductImpl@4aea69ed' at line 1
at org.nw.dao.impl.mysql.BaseDAO.executeUpdate(BaseDAO.java:107)
at org.nw.dao.impl.mysql.ProductDAOImpl.createProduct(ProductDAOImpl.java:49)
... 23 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'org.nw.types.impl.ProductImpl@4aea69ed' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2690)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1648)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1729)
at org.nw.dao.impl.mysql.BaseDAO.executeUpdate(BaseDAO.java:103)
... 24 more
The query executes correctly on the MySQL prompt. What can be the problem ?