Results 1 to 3 of 3
  1. #1
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Rep Power

    Default insert multiple rows in the table from List

    Im trying to insert multiple new rows in the table usr_pln_rghts from the List selected items.

    here is my code :
    try {
    Statement stmt = connection.connection.createStatement(ResultSet.TY PE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

    String[] items = queryResltList.getSelectedItems();
    for (int i = 0; i < items.length; i++) {
    ResultSet r = stmt.executeQuery("select * from usr_pln_rghts");
    r.updateString(1, items[i]);
    r.updateString(2, items[i]);
    r.updateString(3, items[i]);
    r.updateString(4, items[i]);
    r.updateString(5, items[i]);
    r.updateString(6, items[i]);
    JOptionPane.showMessageDialog(null, "The data has been successfully copied to the user");
    } catch (SQLException ex) {
    Logger.getLogger(userAccessUI.class.getName()).log (Level.SEVERE, null, ex);

    i keep on getting this error

    25 Aug 2010 1:54:38 PM SupportSubversion.userAccessUI actionPerformed
    SEVERE: null
    java.sql.SQLException: Invalid operation for read only resultset: moveToInsertRow
    at oracle.jdbc.driver.DatabaseError.throwSqlException (
    at oracle.jdbc.driver.DatabaseError.throwSqlException (
    at oracle.jdbc.driver.BaseResultSet.moveToInsertRow(B
    at SupportSubversion.userAccessUI.actionPerformed(use

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    Why are you inserting via a ResultSet that you do nothing else but insert with?
    Why not simply INSERT?

    You're also not closing the ResultSet r.
    Or the Statement stmt.

    And you're doing business logic in your GUI layer.

  3. #3
    Bulelakes is offline Member
    Join Date
    Jul 2010
    Rep Power

Similar Threads

  1. Highlighting Multiple Selected Rows
    By bigj in forum New To Java
    Replies: 2
    Last Post: 02-07-2010, 06:31 PM
  2. Replies: 1
    Last Post: 04-23-2009, 08:55 PM
  3. Updating Displayed Table Rows
    By raycini in forum JavaServer Faces (JSF)
    Replies: 2
    Last Post: 04-20-2009, 09:24 AM
  4. How to get multiple rows from Stored Procedure
    By SRJ1957 in forum Advanced Java
    Replies: 0
    Last Post: 08-11-2008, 09:26 PM
  5. Color cells and rows in SWT table
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts