Jeetesh Nataraj Jeetesh Nataraj - 11 months ago 80
Java Question

Java and Database Query?

Using Derby as my data base driver and tying to execute SQL query through java,
there was a error that was encounter, when tried to execute this particular query

stmt.executeQuery("insert into " + "TEST " + "values (" + dataTimeRev + ", "
+ dataType + "," + obj + ")" );

Here dataTimeRev, dataType and obj are variables with data.

The error that was stated was like this

java.sql.SQLSyntaxErrorException: VALUES clause must contain at least one element. Empty elements are not allowed.


if the column data type is VARCHAR you will have to pass the value in qoutes like 'value' for that you should do as below

String query = "insert into TEST values('"+dataTimeRev+"', '"+dataType+"','"+obj+"')";