help with database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flavourofbru
    New Member
    • May 2007
    • 48

    #1

    help with database

    Hi,

    I am using MS access for database.

    I am using java as the programming language and able to connect to the database and insert the values into the database.

    The following is the code used for inserting the values into the database:

    public void storeDB (String insertSQL){
    try {
    Statement st = dbConn.createSt atement();

    st.executeUpdat e(insertSQL);

    } catch (Exception e) {
    System.err.prin tln("Got an exception! ");
    System.err.prin tln(e.getMessag e());
    }
    }

    This method is always called from main function whenever I am inserting some values into the database tables.

    Now I need to perform "Select" statement where I would like to select some values from the database rows depending on the condition and then either store or return that value to my main program.

    generally st.executeQuery (Select * from table_name) always returns a result set.

    But I am extracting a set of integer values from a database table and would like to return each of these values or store them in a temporary variable.

    How can I do that.

    Pls help!!

    Thanks!!
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by flavourofbru
    generally st.executeQuery (Select * from table_name) always returns a result set.

    But I am extracting a set of integer values from a database table and would like to return each of these values or store them in a temporary variable.

    How can I do that.

    Pls help!!

    Thanks!!
    Read the API documentation for the ResultSet interface; it has methods that can
    extract individual column values (of any type) from the rows of the set.

    kind regards,

    Jos

    Comment

    • dav3
      New Member
      • Nov 2006
      • 94

      #3
      I highly recommend the following link. It was a great article (as is the following article on the site) on how to use JDBC

      click here

      Comment

      Working...