Java Jdbc Sql Exception
I am currently working on a script in Java to import a bunch of books from a lengthy plain text file to a database. I have all of the books parsed into book objects and am trying t
Solution 1:
The error is obvious, you are missing a comma somewhere in your insert statement.
However, i strongly recommend you to use PreparedStatement rather than simple Statement when performing SQL queries using JDBC to prevent SQL INJECTION.
String query="Insert into table values(?,?);";
PreparedStatementstmnt= conn.preparedStatement(query);
stmnt.setString(1, "val1");
stmnt.setString(2, "val2");
Check here about How to use preparedstatement in java
Solution 2:
, 'This is for CRN's 15454 & 48456,
Right there. Notice how you missed a tick after (48456). Probably because the (CRN's) part.
Also, I recommend using a record for ease of programming. Inserting values like that is just messy. :) Keep up the good work.
Solution 3:
'Ember, Carol & Ember, Melvin,' is probably causing the problem
Try 'Ember, Carol &' || ' Ember, Melvin,'
Post a Comment for "Java Jdbc Sql Exception"