/** * Options are case sensitive. Supported options are: * <table> * <tr><td>[-help] or [-?]</td> * <td>Print the list of options</td></tr> * <tr><td>[-urlSource "<url>"]</td> * <td>The database URL of the source database (jdbc:h2:...)</td></tr> * <tr><td>[-urlTarget "<url>"]</td> * <td>The database URL of the target database (jdbc:h2:...)</td></tr> * <tr><td>[-user <user>]</td> * <td>The user name (default: sa)</td></tr> * <tr><td>[-password <pwd>]</td> * <td>The password</td></tr> * <tr><td>[-serverList <list>]</td> * <td>The comma separated list of host names or IP addresses</td></tr> * </table> * @h2.resource * * @param args the command line arguments */ public static void main(String... args) throws SQLException { new CreateCluster().runTool(args); }
serverList = args[++i]; } else if (arg.equals("-help") || arg.equals("-?")) { showUsage(); return; } else { showUsageAndThrowUnsupportedOption(arg); showUsage(); throw new SQLException("Source URL, target URL, or server list not set"); process(urlSource, urlTarget, user, password, serverList);
private static void process(String urlSource, String urlTarget, String user, String password, String serverList) throws SQLException { org.h2.Driver.load(); // use cluster='' so connecting is possible // even if the cluster is enabled try (Connection connSource = DriverManager.getConnection(urlSource + ";CLUSTER=''", user, password); Statement statSource = connSource.createStatement()) { // enable the exclusive mode and close other connections, // so that data can't change while restoring the second database statSource.execute("SET EXCLUSIVE 2"); try { performTransfer(statSource, urlTarget, user, password, serverList); } finally { // switch back to the regular mode statSource.execute("SET EXCLUSIVE FALSE"); } } }
/** * Creates a cluster. * * @param urlSource the database URL of the original database * @param urlTarget the database URL of the copy * @param user the user name * @param password the password * @param serverlist the server list * @throws SQLException */ public void execute(String urlSource, String urlTarget, String user, String password, String serverlist) throws SQLException { new CreateCluster().process(urlSource, urlTarget, user, password, serverlist); }
tool = new ConvertTraceFile(); } else if ("CreateCluster".equals(toolName)) { tool = new CreateCluster(); } else { throw DbException.throwInternalError(toolName);
/** * Creates a cluster. * * @param urlSource the database URL of the original database * @param urlTarget the database URL of the copy * @param user the user name * @param password the password * @param serverList the server list */ public void execute(String urlSource, String urlTarget, String user, String password, String serverList) throws SQLException { process(urlSource, urlTarget, user, password, serverList); }
/** * The command line interface for this tool. The options must be split into * strings like this: "-urlSource", "jdbc:h2:test",... Options are case * sensitive. The following options are supported: * <ul> * <li>-help or -? (print the list of options) </li> * <li>-urlSource jdbc:h2:... (the database URL of the source database) * </li> * <li>-urlTarget jdbc:h2:... (the database URL of the target database) * </li><li>-user (the user name) * </li><li>-password (the password) * </li><li>-serverlist (the server list) * </li></ul> * * @param args the command line arguments * @throws SQLException */ public static void main(String[] args) throws SQLException { new CreateCluster().run(args); }
tool = new ConvertTraceFile(); } else if ("CreateCluster".equals(toolName)) { tool = new CreateCluster(); } else { throw DbException.throwInternalError(toolName);
/** * Creates a cluster. * * @param urlSource the database URL of the original database * @param urlTarget the database URL of the copy * @param user the user name * @param password the password * @param serverList the server list */ public void execute(String urlSource, String urlTarget, String user, String password, String serverList) throws SQLException { process(urlSource, urlTarget, user, password, serverList); }
serverList = args[++i]; } else if (arg.equals("-help") || arg.equals("-?")) { showUsage(); return; } else { showUsageAndThrowUnsupportedOption(arg); showUsage(); throw new SQLException("Source URL, target URL, or server list not set"); process(urlSource, urlTarget, user, password, serverList);
/** * Options are case sensitive. Supported options are: * <table> * <tr><td>[-help] or [-?]</td> * <td>Print the list of options</td></tr> * <tr><td>[-urlSource "<url>"]</td> * <td>The database URL of the source database (jdbc:h2:...)</td></tr> * <tr><td>[-urlTarget "<url>"]</td> * <td>The database URL of the target database (jdbc:h2:...)</td></tr> * <tr><td>[-user <user>]</td> * <td>The user name (default: sa)</td></tr> * <tr><td>[-password <pwd>]</td> * <td>The password</td></tr> * <tr><td>[-serverList <list>]</td> * <td>The comma separated list of host names or IP addresses</td></tr> * </table> * @h2.resource * * @param args the command line arguments */ public static void main(String... args) throws SQLException { new CreateCluster().runTool(args); }
tool = new ConvertTraceFile(); } else if ("CreateCluster".equals(toolName)) { tool = new CreateCluster(); } else { throw Message.getInternalError(toolName);
/** * Creates a cluster. * * @param urlSource the database URL of the original database * @param urlTarget the database URL of the copy * @param user the user name * @param password the password * @param serverList the server list */ public void execute(String urlSource, String urlTarget, String user, String password, String serverList) throws SQLException { process(urlSource, urlTarget, user, password, serverList); }
serverList = args[++i]; } else if (arg.equals("-help") || arg.equals("-?")) { showUsage(); return; } else { showUsageAndThrowUnsupportedOption(arg); showUsage(); throw new SQLException("Source URL, target URL, or server list not set"); process(urlSource, urlTarget, user, password, serverList);
/** * Options are case sensitive. Supported options are: * <table> * <tr><td>[-help] or [-?]</td> * <td>Print the list of options</td></tr> * <tr><td>[-urlSource "<url>"]</td> * <td>The database URL of the source database (jdbc:h2:...)</td></tr> * <tr><td>[-urlTarget "<url>"]</td> * <td>The database URL of the target database (jdbc:h2:...)</td></tr> * <tr><td>[-user <user>]</td> * <td>The user name (default: sa)</td></tr> * <tr><td>[-password <pwd>]</td> * <td>The password</td></tr> * <tr><td>[-serverList <list>]</td> * <td>The comma separated list of host names or IP addresses</td></tr> * </table> * @h2.resource * * @param args the command line arguments */ public static void main(String... args) throws SQLException { new CreateCluster().runTool(args); }
tool = new ConvertTraceFile(); } else if ("CreateCluster".equals(toolName)) { tool = new CreateCluster(); } else { throw DbException.throwInternalError(toolName);