Results 1 to 4 of 4
Like Tree2Likes
  • 2 Post By Fubarable

Thread: rs.previous() &swing

  1. #1
    mohsen.noor is offline Member
    Join Date
    Dec 2012
    Posts
    28
    Rep Power
    0

    Default rs.previous() &swing

    Hi everybody
    I try execute the following code in my Jdbc programm but when I press Previous Button it dose not work
    *I have multiple record in table
    *The first and last button work correctly
    *NetBeans IDE
    I write code with while loop also
    Java Code:
                                         
    
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
               try{
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    		Connection con=null;
                    con=DriverManager.getConnection("jdbc:odbc:HOS");
    		Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    		ResultSet rs=st.executeQuery("Select * from ipdoc");
                    rs.previous();
                    jTextField1.setText(rs.getString(1));
                    jTextField2.setText(rs.getString(2));
                    jTextField3.setText(rs.getString(3));
                     st.close();
                         con.close();
                 }catch(  SQLException | ClassNotFoundException e){}
        }
    Last edited by DarrylBurke; 03-23-2013 at 11:31 AM. Reason: Removed annoying oversize font formatting

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: rs.previous() &swing

    How would you expect to have any idea of why it may not be working if you're going to just ignore exceptions:

    Java Code:
    catch(  SQLException | ClassNotFoundException e){}
    At least print out the stack trace.

    Java Code:
    catch(  SQLException | ClassNotFoundException e){
       e.printStackTrace();
    }
    DarrylBurke and Tolls like this.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: rs.previous() &swing

    And once you know what exception is being thrown, can you tell us what database you are using?
    I'm asking because the JDBC-ODBC bridge is not going to exist from Java 8 onwards and you ought to be looking for a proper driver for your database.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    mohsen.noor is offline Member
    Join Date
    Dec 2012
    Posts
    28
    Rep Power
    0

    Default Re: rs.previous() &swing

    Thanks every body I solved my problem
    con close() was my mistake
    Again THANKS

Similar Threads

  1. Next and Previous Buttons
    By kbgriggs in forum New To Java
    Replies: 2
    Last Post: 08-12-2009, 03:08 PM
  2. add previous jar library to new one
    By Farzaneh in forum Eclipse
    Replies: 1
    Last Post: 08-23-2008, 03:31 PM
  3. help..on Next n Previous Button
    By norazanita in forum New To Java
    Replies: 0
    Last Post: 06-12-2008, 06:58 AM
  4. Next and Previous Buttons
    By JavaNewb in forum New To Java
    Replies: 1
    Last Post: 05-09-2008, 02:23 AM
  5. Using previous with CardLayout
    By uncopywritable in forum New To Java
    Replies: 2
    Last Post: 08-05-2007, 10:43 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
  •