Exemplo n.º 1
0
 /**
  * Backs up a database to a stream. The stream is not closed.
  *
  * @param url the database URL
  * @param user the user name
  * @param password the password
  * @param out the output stream
  */
 public static void execute(String url, String user, String password, OutputStream out)
     throws SQLException {
   Connection conn = null;
   try {
     com.codefollower.h2.Driver.load();
     conn = DriverManager.getConnection(url, user, password);
     process(conn, out);
   } finally {
     JdbcUtils.closeSilently(conn);
   }
 }
Exemplo n.º 2
0
 private static void processScript(
     String url, String user, String password, String fileName, String options1, String options2)
     throws SQLException {
   Connection conn = null;
   Statement stat = null;
   try {
     com.codefollower.h2.Driver.load();
     conn = DriverManager.getConnection(url, user, password);
     stat = conn.createStatement();
     String sql = "SCRIPT " + options1 + " TO '" + fileName + "' " + options2;
     stat.execute(sql);
   } finally {
     JdbcUtils.closeSilently(stat);
     JdbcUtils.closeSilently(conn);
   }
 }