P
philip.kluss
Greetings,
I'm writing a little job to do a SQL query and dump the data into a
flatfile. For some reason it cuts off before finishing the whole
thing. I don't know of any limitations on the objects that I'm using,
but maybe I've missed something. Here is the code..
--------------------------
import java.io.*;
import java.sql.*;
public class getList {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url =
"jdbc:Microsoft:sqlserver://hal:1433;DatabaseName=Test";
Connection conn =
DriverManager.getConnection(url,"thisis","superfake");
String query = "select ITEMNMBR from IV00101";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
int rows = 0;
PrintWriter out = new PrintWriter(new
FileOutputStream("FullItemList.doc"));
while (rs.next()) {
String itemNumber = rs.getString("ITEMNMBR");
out.println(itemNumber);
rows++;
}
System.out.println(rows + " rows");
} catch (Exception e) {
System.err.println(e);
}
}
}
----------------------------------
As I said, it pretends to have returned all the rows and finishes
running without an exception, but the output file cuts off in the
middle of the same line every time.
Thanks for your time and thought.
-Phil
I'm writing a little job to do a SQL query and dump the data into a
flatfile. For some reason it cuts off before finishing the whole
thing. I don't know of any limitations on the objects that I'm using,
but maybe I've missed something. Here is the code..
--------------------------
import java.io.*;
import java.sql.*;
public class getList {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url =
"jdbc:Microsoft:sqlserver://hal:1433;DatabaseName=Test";
Connection conn =
DriverManager.getConnection(url,"thisis","superfake");
String query = "select ITEMNMBR from IV00101";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
int rows = 0;
PrintWriter out = new PrintWriter(new
FileOutputStream("FullItemList.doc"));
while (rs.next()) {
String itemNumber = rs.getString("ITEMNMBR");
out.println(itemNumber);
rows++;
}
System.out.println(rows + " rows");
} catch (Exception e) {
System.err.println(e);
}
}
}
----------------------------------
As I said, it pretends to have returned all the rows and finishes
running without an exception, but the output file cuts off in the
middle of the same line every time.
Thanks for your time and thought.
-Phil