• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList to JDBC

 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All trying to get this code working,

I have some code that i wish to place the ArrayList into a Database Table



I am getting the Following Errors
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:497)
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yeah. An INSERT statement doesn't return a ResultSet, so writing code which acts as if it does is an error. So the method you want to use isn't executeQuery (which returns a ResultSet), but something else which you should be able to find very quickly by consulting the API documentation.

You seem to have mixed up your original requirements (Write the entries of a List into a database table) with some code which reads those entries from a database table into a List.
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got a link to the API doc with this information would help a lot .
 
bala nannaka
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use the executeUpdate which returns an int value pointing to number of rows effected with your statement. Generally for all INSERT,UPDATE and DELETE operations we can use executeUpdate which they don't return any result set but the number of rows affected with those operations.
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bala nannaka wrote:Try to use the executeUpdate which returns an int value pointing to number of rows effected with your statement. Generally for all INSERT,UPDATE and DELETE operations we can use executeUpdate which they don't return any result set but the number of rows affected with those operations.



OK..

I have INSERT, UPDATE, DELETE on the Database, I am able to Save the Database using Serialization but am looking for a Way to Drop Everything inside the Database and Reload the database with the saved information that is inside the Array List or the Serialized File.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic