Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Help with Java

RE: Help with Java

From: DENNIS WILLIAMS <DWILLIAMS_at_LIFETOUCH.COM>
Date: Tue, 03 Dec 2002 11:44:29 -0800
Message-ID: <F001.00511326.20021203114429@fatcity.com>


John - I forwarded your message to one of our newly-trained Java programmers. He replied with:

   The code is incomplete, how are they handling the connection.    Obviously the while loops are messing each other up.    There are multiple ways of handling this.    If I see the complete code I can be more specific.

Dennis Williams
DBA, 40%OCP
Lifetouch, Inc.
dwilliams_at_lifetouch.com

-----Original Message-----
Sent: Tuesday, December 03, 2002 12:25 PM To: Multiple recipients of list ORACLE-L

All,

I am beginning the journey into JAVA and have hit an odd behavior (well, probably not, but I can't see any reason for it). I am building a list of tablespaces and the datafiles that belong to them. The open to the database is working fine. When I use:

 ResultSet myTablespaces = myStatement.executeQuery(

"SELECT tablespace_name " +
"FROM dba_tablespaces " +
"WHERE contents = 'PERMANENT'"

  );

  while (myTablespaces.next()) {
    // retrieve the user from the row in the ResultSet using the     // getString() method
    ct = ct + 1;
    String tablespace = myTablespaces.getString(1);     System.out.println("Tablespace " + ct + " is: " + tablespace);   }
  myTablespace.close();

I am generating a list of tablespaces and the output is as expected. When I add a second result set, the first datafile of the first tablespace returns and then the program completes:

 ResultSet myTablespaces = myStatement.executeQuery(

"SELECT tablespace_name " +
"FROM dba_tablespaces " +
"WHERE contents = 'PERMANENT'"

  );
  while (myTablespaces.next()) {
    // retrieve the user from the row in the ResultSet using the     // getString() method
    ct = ct + 1;
    String tablespace = myTablespaces.getString(1);     System.out.println("Tablespace " + ct + " is: " + tablespace);  

    ResultSet myDataFiles = myStatement.executeQuery(

      "SELECT file_name " +
      "FROM   dba_data_files " +
      "WHERE  tablespace_name = '" + tablespace + "'"
    );   

    while (myDataFiles.next()) {

      String filename = myDataFiles.getString(1);
      System.out.println("  " + filename);
    }
    myDataFiles.close();
  }
  myTablespaces.close();

Anybody with some Java experience have any insite?

As always, TIA,

John P Weatherman
Database Administrator
Replacements Ltd.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: John Weatherman
  INET: john.weatherman_at_replacements.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: DENNIS WILLIAMS
  INET: DWILLIAMS_at_LIFETOUCH.COM

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Dec 03 2002 - 13:44:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US