JDBC updatable ResultSet help!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: JDBC updatable ResultSet help!

  1. #1
    Join Date
    Dec 2002
    Posts
    1

    JDBC updatable ResultSet help!

    Hi everyone. I'm using JDBC to write a class in Java that connects to a mySQL database (through the Connector/J driver). When I try to execute the code below it throws an exception that my ResultSet in not updatable. I understand that this might have to do with setting the Primary Key, etc. but I'm not sure how to do this in Java. Any help would be greatly appreciated!

    J. Ciolkosz

    try{
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    srs.absolute(position);
    element = srs.getString(field);
    }catch(SQLException ex){
    System.err.println("----SQLException----");
    System.err.println("SQLState: " + ex.getSQLState());
    System.err.println("Message: " + ex.getMessage());
    System.err.println("Vendor: " + ex.getErrorCode());}

  2. #2
    Join Date
    Nov 2002
    Posts
    59
    I'm guessing that srs is your ResultSet, here...the problem probably lies in this: Don't forget to do an executeQuery before trying to use a ResultSet. For example

    srs = stmt.executeQuery("select........");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center