Hi,
I'm quite new to java and I am trying to extract data from a table and place into a *.csv file.
The methods I'm using work fine when printing to screen:
System.out.println(record set)
but when trying to write the same data into a csv file, all the data is shoved into 1 field. My code is below, could anyone tell me where I'm going wrong?
Cheers,
Skeen.
Code:
try{
Connection C = DriverManager.getConnection("jdbcdbc:eds");
try{
FileOutputStream FOS = new FileOutputStream("C:\\Testy\\Data_Migration.csv");
DataOutputStream DataOut=new DataOutputStream(FOS);
try {
Statement Stmt = C.createStatement();
String qs = "select * from contacts";
ResultSet RS = Stmt.executeQuery(qs);
while (RS.next()) {
}
try{
Statement Stmt2 = C.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String qs2 = "select * from contacts";
ResultSet RS2 = Stmt2.executeQuery(qs2);
while (RS2.next()) {
String name = RS2.getString("FirstName");
DataOut.writeBytes(name);
System.out.println(name);
}
I have all of the relevant catch statements and the code compiles and executes without error, it just dosn't do what I want it to do.
Any help appreciated.


dbc:eds");
Reply With Quote