本文整理汇总了Java中org.springframework.test.jdbc.JdbcTestUtils.executeSqlScript方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcTestUtils.executeSqlScript方法的具体用法?Java JdbcTestUtils.executeSqlScript怎么用?Java JdbcTestUtils.executeSqlScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.test.jdbc.JdbcTestUtils
的用法示例。
在下文中一共展示了JdbcTestUtils.executeSqlScript方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeScript
import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
public static void executeScript(DataSource dataSource, String... sqlResourcePaths)
throws DataAccessException {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
for (String sqlResourcePath : sqlResourcePaths) {
Resource resource = resourceLoader.getResource(sqlResourcePath);
JdbcTestUtils.executeSqlScript(jdbcTemplate, new EncodedResource(resource,
DEFAULT_ENCODING), true);
}
}
示例2: executeScript
import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
public static void executeScript(DataSource dataSource, String... sqlResourcePaths) throws DataAccessException {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
for (String sqlResourcePath : sqlResourcePaths) {
JdbcTestUtils.executeSqlScript(jdbcTemplate, resourceLoader, sqlResourcePath, true);
}
}
示例3: executeScript
import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
* 批量执行sql文件
*
* @param dataSource dataSource
* @param sqlResourcePaths sql文件路径
*
* @throws DataAccessException
*/
public void executeScript(DataSource dataSource, String... sqlResourcePaths) throws DataAccessException {
for (String sqlResourcePath : sqlResourcePaths) {
JdbcTestUtils.executeSqlScript(jdbcTemplate, resourceLoader, sqlResourcePath, true);
}
}
示例4: executeScript
import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
* 批量执行sql文件
*
* @param dataSource dataSource
* @param sqlResourcePaths sql文件路径
*
* @throws DataAccessException
*/
public static void executeScript(DataSource dataSource, String... sqlResourcePaths) throws DataAccessException {
for (String sqlResourcePath : sqlResourcePaths) {
JdbcTestUtils.executeSqlScript(jdbcTemplate, resourceLoader, sqlResourcePath, true);
}
}
示例5: executeSqlScript
import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
* Execute the given SQL script. Use with caution outside of a transaction!
* <p>The script will normally be loaded by classpath. There should be one
* statement per line. Any semicolons will be removed. <b>Do not use this
* method to execute DDL if you expect rollback.</b>
* @param sqlResourcePath the Spring resource path for the SQL script
* @param continueOnError whether or not to continue without throwing an
* exception in the event of an error
* @throws DataAccessException if there is an error executing a statement
* and continueOnError was {@code false}
*/
protected void executeSqlScript(String sqlResourcePath, boolean continueOnError) throws DataAccessException {
Resource resource = this.applicationContext.getResource(sqlResourcePath);
JdbcTestUtils.executeSqlScript(this.jdbcTemplate, new EncodedResource(resource,
this.sqlScriptEncoding), continueOnError);
}