A
ali.alauoubiy
Hi All..
I am new to Enterprise Java Development and I have question? I am
trying to develop system that been in written in very bad way(i.e. no
Framework, Desigen Patterns). The question is I would like to run SQL
statement from a java class and I would like to store the result set
into a file, however I don't know what how to extract the rows from the
result set (specially don't know what data type to use) to write to a
file.. the code I written so far is:
//creat 4 different files and split the result set into 4
parts and store them into 4 files
FileOutputStream fout1 = new
FileOutputStream("test1.out");
FileOutputStream fout2 = new
FileOutputStream("test2.out");
FileOutputStream fout3 = new
FileOutputStream("test3.out");
FileOutputStream fout4 = new
FileOutputStream("test4.out");
// now to the FileOutputStream into a PrintStream
PrintStream myOutput1 = new PrintStream(fout1);
PrintStream myOutput2 = new PrintStream(fout2);
PrintStream myOutput3 = new PrintStream(fout3);
PrintStream myOutput4 = new PrintStream(fout4);
//Added by Ali
query = "select * from ExportFlatDaily where viewId = '0' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput1.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '1' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput2.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '2' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput3.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '3' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput1.print(rs.toString());
}
Any Suggestions.. Many thanks...
Ali
I am new to Enterprise Java Development and I have question? I am
trying to develop system that been in written in very bad way(i.e. no
Framework, Desigen Patterns). The question is I would like to run SQL
statement from a java class and I would like to store the result set
into a file, however I don't know what how to extract the rows from the
result set (specially don't know what data type to use) to write to a
file.. the code I written so far is:
//creat 4 different files and split the result set into 4
parts and store them into 4 files
FileOutputStream fout1 = new
FileOutputStream("test1.out");
FileOutputStream fout2 = new
FileOutputStream("test2.out");
FileOutputStream fout3 = new
FileOutputStream("test3.out");
FileOutputStream fout4 = new
FileOutputStream("test4.out");
// now to the FileOutputStream into a PrintStream
PrintStream myOutput1 = new PrintStream(fout1);
PrintStream myOutput2 = new PrintStream(fout2);
PrintStream myOutput3 = new PrintStream(fout3);
PrintStream myOutput4 = new PrintStream(fout4);
//Added by Ali
query = "select * from ExportFlatDaily where viewId = '0' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput1.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '1' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput2.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '2' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput3.print(rs.toString());
}
query = "select * from ExportFlatDaily where viewId = '3' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
myOutput1.print(rs.toString());
}
Any Suggestions.. Many thanks...
Ali