Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Using a resultset to write to a .txt file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am new to Java and I am trying to write from a SQL resultset("SELECT RecordID,ARNumber,DateUpdated,REVCHANGES FROM Updates") is ther a way I can write the results stright to a database on the mainframe? If this is not possible then I will need to write the result set from resultset query toa text file. Is there any way to write the entire resultset out The only thing I have found is the ability to select individuals fields.

Thanks,
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,
Welcome to CodeRanch!

Yes. You would loop through all the columns in the result set writing them to a text file. Unless you are running your program on the mainframe, it isn't possible to write directly there.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Bryant wrote:Hello,
I am new to Java and I am trying to write from a SQL resultset("SELECT RecordID,ARNumber,DateUpdated,REVCHANGES FROM Updates") is ther a way I can write the results stright to a database on the mainframe? If this is not possible then I will need to write the result set from resultset query toa text file. Is there any way to write the entire resultset out The only thing I have found is the ability to select individuals fields.

Thanks,



I didn't understand well your question, if you want to write resultSet to txt . etc file , you can you OutputStream. If you want to show ReslutSet on Frame , you can use Jtable or JList.
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Unless you are running your program on the mainframe, it isn't possible to write directly there.



Unless there's a JDBC driver for the mainframe database, of course. Which is quite likely. Then you would just use JDBC to write data into tables on the mainframe.
 
Tim Bryant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use a resultset from an SQL query to write out to a tempory file. Here is a sample of the code I am trying to use. It seems I am running into a couple of problems
1. My output is not formated correctly .
2. I had to comment this line out to get it to run (out.write(rs.getTimestamp(3));) can you not write timestamp?
3. I was expecting my output to look like this: 142 123456 2011-07-28 00:00:00.0 test
4. Instead my output looks like this Žtest




 
Paul Clapham
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll want to format those things as strings before you write them. Check out the API documentation for BufferedWriter, too, I suspect you haven't seen that yet.
 
There's a city wid manhunt for this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic