org.hsqldb.cmdline.SqlFile Java Examples
The following examples show how to use
org.hsqldb.cmdline.SqlFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DBInit.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Executes a single sql file * * @param sqlFile Path of the file to execute(it can be a classpath * resource) * @throws IOException * @throws SqlToolError * @throws SQLException */ private void execute(String sqlFile) throws IOException, SQLException { log.debug("Execute " + sqlFile); System.out.println("Execute " + sqlFile); File file = new File(sqlFile); if (!file.exists() || !file.canRead()) { file = File.createTempFile(file.getName(), ".sql"); file.deleteOnExit(); FileUtil.copyResource(sqlFile, file); } SqlFile sFile = new SqlFile(file, "Cp1252", false); try { sFile.setContinueOnError(true); sFile.setConnection(con); sFile.execute(); } catch (SqlToolError e) { throw new SQLException(e.getMessage()); } }
Example #2
Source File: HsqldbUtils.java From vibur-dbcp with Apache License 2.0 | 5 votes |
public static void deployDatabaseSchemaAndData(String jdbcUrl, String username, String password) throws IOException, SqlToolError, SQLException { Connection connection = null; try { connection = DriverManager.getConnection(jdbcUrl, username, password); InputStreamReader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader() .getResourceAsStream(HSQLDB_SCHEMA_AND_DATA_SQL), System.getProperty("file.encoding")); SqlFile sqlFile = new SqlFile(isr, "--sql", System.out, null, false, null); sqlFile.setConnection(connection); sqlFile.execute(); } finally { quietClose(connection); } }