本文整理汇总了Java中org.hsqldb.cmdline.SqlFile类的典型用法代码示例。如果您正苦于以下问题:Java SqlFile类的具体用法?Java SqlFile怎么用?Java SqlFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlFile类属于org.hsqldb.cmdline包,在下文中一共展示了SqlFile类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public boolean isHandled(SQLException e, String sql, SqlFile file, Connection newConnection) {
String lowerCaseSql = sql.toLowerCase();
switch (e.getErrorCode()) {
case 3701:
if (lowerCaseSql.contains("drop")) {
// droping not existing object
LOG.warn("Cannot %S_MSG the %S_MSG '%.*ls', because it does not exist or you do not have permission. Ignoring error.");
return true;
}
return false;
case 2627:
if (lowerCaseSql.contains("values")) {
// insert existing row
LOG.warn("Cannot insert duplicate key in object. Ignoring error.");
return true;
}
return false;
case 2714:
// create existing object
LOG.warn("There is already an object named. Ignoring error.");
return true;
default:
return false;
}
}
开发者ID:nortal,项目名称:DataBata,代码行数:26,代码来源:MicrosoftSQLExceptionHandler.java
示例2: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
@Override
public boolean isHandled(SQLException e, String sql, SqlFile sqlFile, Connection newConnection) {
String lowerCaseSql = sql.toLowerCase();
LOG.info("ErrorCode = [" + e.getErrorCode() + "]; SQLState = [" + e.getSQLState() + "]");
try {
//IGNORED_SQL_STATE state = IGNORED_SQL_STATE.valueOf("_" + e.getSQLState());
// O1 class is ignored because it is of warning class.
boolean ignored = e.getSQLState().startsWith("01"); //|| state.isIgnored(lowerCaseSql);
if (sqlFile != null && ignored) {
// In case an error was handled e.g. script execution should continue we must reset connection
sqlFile.getConnection().rollback();
// XXX: do we need to close old connection here?
sqlFile.setConnection(newConnection);
}
return ignored;
} catch (IllegalArgumentException iae) {
return e.getSQLState().startsWith("01");
} catch (SQLException sqlException) {
LOG.error(sqlException);
return false;
}
}
开发者ID:nortal,项目名称:DataBata,代码行数:26,代码来源:PostgreSQLExceptionHandler.java
示例3: createSchema
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
private void createSchema(Connection conn) throws IOException, SqlToolError, SQLException {
// Note that the character set should match the encoding in pom.xml
Charset charset = Charset.forName("Cp1252");
SqlFile sqlFile = new SqlFile(
new InputStreamReader(LogAnalyzer.class.getResourceAsStream("/create_schema.sql"), charset),
"create schema", null, null, false, null);
sqlFile.setConnection(conn);
sqlFile.setAutoClose(true);
sqlFile.execute();
}
开发者ID:erik-wramner,项目名称:JmsTools,代码行数:11,代码来源:LogAnalyzer.java
示例4: setUpClass
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws IOException, SqlToolError, SQLException {
// On crée la connection vers la base de test "in memory"
myDataSource = getDataSource();
myConnection = myDataSource.getConnection();
// On initialise la base avec le contenu d'un fichier de test
String sqlFilePath = GeneralDAO_Test.class.getResource("sample.sql").getFile();
SqlFile sqlFile = new SqlFile(new File(sqlFilePath));
sqlFile.setConnection(myConnection);
sqlFile.execute();
sqlFile.closeReader();
}
开发者ID:VieVie31,项目名称:vigilant-pancake,代码行数:14,代码来源:GeneralDAO_Test.java
示例5: deployDatabaseSchemaAndData
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
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);
}
}
开发者ID:vibur,项目名称:vibur-dbcp,代码行数:16,代码来源:HsqldbUtils.java
示例6: runSQLScript
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
@Given("^Dataset (.*) loaded.$")
public void runSQLScript(String fileName) {
try {
SqlFile sqlFile = new SqlFile(new File(fileName));
Connection c = getConnectionOnIntegration();
c.setAutoCommit(false);
sqlFile.setConnection(c);
sqlFile.execute();
c.commit();
c.close();
} catch (Exception e) {
_log.error("Error when loading the Dataset: " + fileName, e);
Assert.fail();
}
}
开发者ID:groupon,项目名称:Novie,代码行数:16,代码来源:HSQLDBRequestDeclarative.java
示例7: initDatabase
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
@Before
public void initDatabase() throws IOException, SQLException, SqlToolError {
Properties props = new Properties();
props.load(this.getClass().getResourceAsStream("/unittest-db.properties"));
conn = DriverManager.getConnection(props.getProperty("jdbc.url"), props.getProperty("username"), props.getProperty("password"));
repo = new StatsRepository(conn);
String sqlFilePath = getClass().getResource("/test.sql").getFile();
SqlFile sqlFile = new SqlFile(new File(sqlFilePath));
sqlFile.setConnection(conn);
sqlFile.execute();
sqlFile.closeReader();
conn.commit();
}
开发者ID:alphagov,项目名称:pp-db-collector-template,代码行数:15,代码来源:StatsRepositoryTest.java
示例8: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public boolean isHandled(SQLException e, String sql, SqlFile file, Connection newConnection) {
Scanner words = new Scanner(sql.toLowerCase());
try {
return isHandled(e, sql, words);
} finally {
words.close();
}
}
开发者ID:nortal,项目名称:DataBata,代码行数:9,代码来源:OracleSQLExceptionHandler.java
示例9: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public boolean isHandled(SQLException e, String sql, SqlFile sqlFile, Connection newConnection) {
switch (e.getErrorCode()) {
case -141:
LOG.warn("Table not found. Ignoring error.");
return true;
case -110:
LOG.warn("Item already exists. Ignoring error.");
return true;
default:
return false;
}
}
开发者ID:nortal,项目名称:DataBata,代码行数:13,代码来源:SybaseSQLExceptionHandler.java
示例10: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public boolean isHandled(SQLException e, String sql, SqlFile sqlFile, Connection newConnection) {
boolean ignored = handler.isHandled(e, sql, sqlFile, newConnection);
String logMessage = (ignored ? "IGNORED:" : "FATAL:") + e.getMessage();
log(sql, 0, e.getErrorCode(), logMessage, -0.01);
return ignored;
}
开发者ID:nortal,项目名称:DataBata,代码行数:8,代码来源:DBHistoryLogger.java
示例11: handleDataAccessException
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public static void handleDataAccessException(SQLException e, String sql, SQLExceptionHandler handler, SqlFile sqlFile, Connection newConnection)
throws SQLException {
if (!handler.isHandled(e, sql, sqlFile, newConnection)) {
LOG.info("\n\nERROR is not handled\n\n");
throw e;
}
}
开发者ID:nortal,项目名称:DataBata,代码行数:8,代码来源:PropagationUtils.java
示例12: openCommandPrompt
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
private void openCommandPrompt(Connection conn) throws IOException, SqlToolError, SQLException {
SqlFile sqlFile = new SqlFile(null, true);
sqlFile.setConnection(conn);
sqlFile.execute();
}
开发者ID:erik-wramner,项目名称:JmsTools,代码行数:6,代码来源:LogAnalyzer.java
示例13: setSqlFile
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
public void setSqlFile(SqlFile sqlFile) {
this.sqlFile = sqlFile;
}
开发者ID:nortal,项目名称:DataBata,代码行数:4,代码来源:StandardSqlExecutionCallback.java
示例14: isHandled
import org.hsqldb.cmdline.SqlFile; //导入依赖的package包/类
boolean isHandled(SQLException e, String sql, SqlFile sqlFile, Connection newConnection);
开发者ID:nortal,项目名称:DataBata,代码行数:2,代码来源:SQLExceptionHandler.java
注:本文中的org.hsqldb.cmdline.SqlFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论