Moved initial opening of output so that files aren't created if the connection
fails.
This commit is contained in:
parent
048b527c10
commit
4abd15d18e
@ -66,8 +66,6 @@ public class JDBCJSON
|
|||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
JsonWriter writer = null;
|
JsonWriter writer = null;
|
||||||
try {
|
try {
|
||||||
writer = new JsonWriter(new FileWriter(out, false));
|
|
||||||
|
|
||||||
conn = DriverManager.getConnection(url);
|
conn = DriverManager.getConnection(url);
|
||||||
|
|
||||||
Statement st = conn.createStatement(
|
Statement st = conn.createStatement(
|
||||||
@ -79,6 +77,7 @@ public class JDBCJSON
|
|||||||
ResultSetMetaData rsmd = rs.getMetaData();
|
ResultSetMetaData rsmd = rs.getMetaData();
|
||||||
int columns = rsmd.getColumnCount();
|
int columns = rsmd.getColumnCount();
|
||||||
|
|
||||||
|
writer = new JsonWriter(new FileWriter(out, false));
|
||||||
writer.beginArray();
|
writer.beginArray();
|
||||||
while(rs.next()){
|
while(rs.next()){
|
||||||
writer.beginObject();
|
writer.beginObject();
|
||||||
|
Loading…
Reference in New Issue
Block a user