ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/tools/Script.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/tools/Script.java
Status
scanned
Type
file
Name
Script.java
Extension
.java
Programming language
Java
Mime type
text/html
File type
HTML document, ASCII text
Tag

      
    
Rootfs path

      
    
Size
5000 (4.9 KB)
MD5
e07271249900a71a16af7dae3f0e7349
SHA1
0a2de618bae5ed622688600c886630ad5410d906
SHA256
cd275f8d2b127c3825e5346745fbc7f7485e861ec02713f2a03ec97361418d93
SHA512

      
    
SHA1_git
73ac7731585a2c0517d6cd85e1ce28d9b61f6a87
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Script.java | 4.9 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.tools; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import org.h2.util.JdbcUtils; import org.h2.util.StringUtils; import org.h2.util.Tool; /** * Creates a SQL script file by extracting the schema and data of a database. */ public class Script extends Tool { /** * Options are case sensitive. * <table> * <caption>Supported options</caption> * <tr><td>[-help] or [-?]</td> * <td>Print the list of options</td></tr> * <tr><td>[-url "&lt;url&gt;"]</td> * <td>The database URL (jdbc:...)</td></tr> * <tr><td>[-user &lt;user&gt;]</td> * <td>The user name (default: sa)</td></tr> * <tr><td>[-password &lt;pwd&gt;]</td> * <td>The password</td></tr> * <tr><td>[-script &lt;file&gt;]</td> * <td>The target script file name (default: backup.sql)</td></tr> * <tr><td>[-options ...]</td> * <td>A list of options (only for embedded H2, see SCRIPT)</td></tr> * <tr><td>[-quiet]</td> * <td>Do not print progress information</td></tr> * </table> * * @param args the command line arguments * @throws SQLException on failure */ public static void main(String... args) throws SQLException { new Script().runTool(args); } @Override public void runTool(String... args) throws SQLException { String url = null; String user = ""; String password = ""; String file = "backup.sql"; String options1 = ""; String options2 = ""; for (int i = 0; args != null && i < args.length; i++) { String arg = args[i]; if (arg.equals("-url")) { url = args[++i]; } else if (arg.equals("-user")) { user = args[++i]; } else if (arg.equals("-password")) { password = args[++i]; } else if (arg.equals("-script")) { file = args[++i]; } else if (arg.equals("-options")) { StringBuilder buff1 = new StringBuilder(); StringBuilder buff2 = new StringBuilder(); i++; for (; i < args.length; i++) { String a = args[i]; String upper = StringUtils.toUpperEnglish(a); if ("SIMPLE".equals(upper) || upper.startsWith("NO") || "DROP".equals(upper)) { buff1.append(' '); buff1.append(args[i]); } else if ("BLOCKSIZE".equals(upper)) { buff1.append(' '); buff1.append(args[i]); i++; buff1.append(' '); buff1.append(args[i]); } else { buff2.append(' '); buff2.append(args[i]); } } options1 = buff1.toString(); options2 = buff2.toString(); } else if (arg.equals("-help") || arg.equals("-?")) { showUsage(); return; } else { showUsageAndThrowUnsupportedOption(arg); } } if (url == null) { showUsage(); throw new SQLException("URL not set"); } process(url, user, password, file, options1, options2); } /** * Backs up a database to a stream. * * @param url the database URL * @param user the user name * @param password the password * @param fileName the target file name * @param options1 the options before the file name (may be an empty string) * @param options2 the options after the file name (may be an empty string) * @throws SQLException on failure */ public static void process(String url, String user, String password, String fileName, String options1, String options2) throws SQLException { try (Connection conn = JdbcUtils.getConnection(null, url, user, password)) { process(conn, fileName, options1, options2); } } /** * Backs up a database to a stream. The stream is not closed. * The connection is not closed. * * @param conn the connection * @param fileName the target file name * @param options1 the options before the file name * @param options2 the options after the file name * @throws SQLException on failure */ public static void process(Connection conn, String fileName, String options1, String options2) throws SQLException { try (Statement stat = conn.createStatement()) { String sql = "SCRIPT " + options1 + " TO '" + fileName + "' " + options2; stat.execute(sql); } } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
1.91
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220