Skip to Main Content

looking for a method that reads in a whole row for data rather than using getString();

966239Feb 20 2015 — edited Feb 20 2015

Hi,

  I'm using java to read from oracle and Netezza and I'm wondering:

Is there a method for capturing a row in a variable in order to print that entire row out to a data file or a UNIX file in this case.

Right now I have this code I'm working with:

  //STEP 4: Execute a query
  System.out.println("Creating statement...");
  stmt = connection.createStatement();
  String sql;
  sql = "SELECT SRC_ID, SRC_CD, SRC_DSC, CKA_SUB_ID FROM SRC"; 
  ResultSet rs = stmt.executeQuery(sql);

  //STEP 5: Extract data from result set
  while(rs.next()){
//Retrieve by column name
String SRC_ID  = rs.getString("SRC_ID");
String FIRST_ROW  = SRC_ID+", "+SRC_CD+", "+SRC_DSC+", "+CKA_SUB_ID;

//Display values
System.out.print("SRC_ID: " + SRC_ID);
System.out.println(", FIRST_ROW: " + FIRST_ROW);
                     }

Is there a way I can replace the getString with a "getRow"?

Right now the best I can do is to create and use the FIRST_ROW variable. However I want to be able to do this generically so I can read different tables and write them to data files.

Thanks!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Mar 20 2015
Added on Feb 20 2015
1 comment
1,158 views