2 Replies Latest reply: Mar 20, 2007 11:58 AM by 796447 RSS

    Getting data from a database

      In my program I have to print some data that I take from a database.

      I have done the following query from the table "data_table":
      insertStr = "select data from data_table where id > 0";
      ResultSet rs = stmt.executeQuery(insertStr);
      How can I get the results of the query?
        • 1. Re: Getting data from a database
          you really need to read the docs for this, but as a starter: (I'm making up column names etc but you get the idea)
          String id = rs.getString("id"); // "id" is the column name in the database
          int size = rs.getInt("size");
          // etc
          • 2. Re: Getting data from a database
            Please look up the documentation of the API:

            Find the ResultSet interface in that documentation. Read it.

            Also see the JDBC tutorial: