import java.sql.*;

public class DB {
  public static void main(String[] args) throws Exception {
    if (args.length != 1 || "".equals(args[0].trim())) {
      System.err.println("Error: <SQL>");
      System.exit(1);
    }
    String sql = args[0];
    Connection conn = null;
    try {
      String url = "jdbc:derby:/home/hashiwa/java/AccountBook/db_production;create=true;user=test;password=test";
      conn = DriverManager.getConnection(url);
      Statement stat = conn.createStatement();
      ResultSet result = stat.executeQuery(sql);
      //ResultSet result = stat.executeQuery("select t.tablename, t.tabletype, s.schemaname from sys.systables as t join sys.sysschemas as s on t.schemaid = s.schemaid");
      while (result.next()) {
        System.out.println(createRowString(result));
      }
    } finally {
      if (conn != null) conn.close();
    }
  }

  private static String createRowString(ResultSet result) {
    StringBuilder buf = new StringBuilder();
    for (int i=1 ;; i++) {
      try {
        String s = result.getString(i);
        buf.append(s);
        buf.append('\t');
      } catch(SQLException e) {
        break;
      }
    }
    return buf.toString();
  }
}

@@ -924,17 +924,141 @@
 result) 
-%7B
+throws SQLException %7B%0A    ResultSetMetaData metadata = result.getMetaData();%0A    int columnCount = metadata.getColumnCount();
 %0A    Str
@@ -1113,16 +1113,32 @@
 nt i=1 ;
+ i%3C=columnCount 
 ; i++) %7B
@@ -1142,22 +1142,8 @@
 ) %7B%0A
-      try %7B%0A  
     
@@ -1176,18 +1176,16 @@
 ing(i);%0A
-  
       bu
@@ -1199,26 +1199,24 @@
 d(s);%0A      
-  
 buf.append('
@@ -1225,63 +1225,8 @@
 ');%0A
-      %7D catch(SQLException e) %7B%0A        break;%0A      %7D%0A
     
@@ -1252,16 +1252,23 @@
 String()
+.trim()
 ;%0A  %7D%0A%7D%0A

update db tool