private static void createScript() throws Exception {
  Class.forName("org.h2.Driver");
  Connection conn=DriverManager.getConnection("jdbc:h2:mem:test");
  Statement stat=conn.createStatement();
  stat.execute("CREATE TABLE TEST(NAME VARCHAR)");
  stat.execute("INSERT INTO TEST VALUES('Hello World')");
  stat.execute("SCRIPT TO 'script.sql'");
  stat.close();
  conn.close();
}

private static void createScript ( ) throws Exception { Class . forName ( "org.h2.Driver" ) ; Connection conn = DriverManager . getConnection ( "jdbc:h2:mem:test" ) ; Statement stat = conn . createStatement ( ) ; stat . execute ( "CREATE TABLE TEST(NAME VARCHAR)" ) ; stat . execute ( "INSERT INTO TEST VALUES('Hello World')" ) ; stat . execute ( "SCRIPT TO 'script.sql'" ) ; stat . close ( ) ; conn . close ( ) ; }
create a script from a new database .
