Moved initial opening of output so that files aren't created if the connection

fails.
This commit is contained in:
Christopher Ramey 2012-08-22 14:45:56 +00:00 committed by cdramey
parent 048b527c10
commit 4abd15d18e

View File

@ -66,8 +66,6 @@ public class JDBCJSON
Connection conn = null;
JsonWriter writer = null;
try {
writer = new JsonWriter(new FileWriter(out, false));
conn = DriverManager.getConnection(url);
Statement st = conn.createStatement(
@ -79,6 +77,7 @@ public class JDBCJSON
ResultSetMetaData rsmd = rs.getMetaData();
int columns = rsmd.getColumnCount();
writer = new JsonWriter(new FileWriter(out, false));
writer.beginArray();
while(rs.next()){
writer.beginObject();