当前位置: 首页>>代码示例>>Java>>正文


Java ScriptUtils类代码示例

本文整理汇总了Java中org.springframework.jdbc.datasource.init.ScriptUtils的典型用法代码示例。如果您正苦于以下问题:Java ScriptUtils类的具体用法?Java ScriptUtils怎么用?Java ScriptUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScriptUtils类属于org.springframework.jdbc.datasource.init包,在下文中一共展示了ScriptUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeJiraDataBaseForSla

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForSla() throws SQLException {
	final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();
	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:JiraExportPluginResourceTest.java

示例2: initializeJiraDataBase

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBase() throws SQLException {
	datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
		jdbcTemplate.queryForList("SELECT * FROM pluginversion WHERE ID = 10075");
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:AbstractJiraTest.java

示例3: initializeJiraDataBaseForImport

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForImport() throws SQLException {
	datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-2/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/upload/jira-create.sql"), StandardCharsets.UTF_8));

		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-2/jira.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:23,代码来源:JiraUpdateDaoTest.java

示例4: executeSql

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
@RequestMapping(value = "/executeSql", method = RequestMethod.POST)
public void executeSql(MultipartFile file, HttpServletResponse response) throws SQLException, IOException {
    Connection connection = DriverManager.getConnection(url + "mysql", username, password);
    String db = ("SC" + UUID.randomUUID().toString().substring(0, 5)).toLowerCase();
    List<String> sqls = Arrays.asList("CREATE DATABASE IF NOT EXISTS " + db + " DEFAULT CHARSET utf8",
            "CREATE USER '" + db + "'@'%' IDENTIFIED BY '" + db + "'",
            "grant all privileges on " + db + ".* to '" + db + "'@'%' identified by '" + db + "'");
    for (String sql : sqls) {
        Statement statement = connection.createStatement();
        statement.execute(sql);
        statement.close();
    }

    connection.close();

    String jdbcUrl = url + db;
    connection = DriverManager.getConnection(url, db, db);
    ScriptUtils.executeSqlScript(connection, new InputStreamResource(file.getInputStream()));
    connection.close();

    datasourceService.save(new Datasource()
            .setJdbcUrl(jdbcUrl)
            .setName(file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")))
            .setUsername(db)
            .setPassword(db)
            .setDriver("com.mysql.jdbc.Driver"));
    response.sendRedirect("/");
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:29,代码来源:GeneratorController.java

示例5: cleanJiraDataBaseForSla

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBaseForSla() throws SQLException {
	final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/sla/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:JiraExportPluginResourceTest.java

示例6: cleanJiraDataBase

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBase() throws SQLException {
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:AbstractJiraTest.java

示例7: initializeJiraDataBaseForImport

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBaseForImport() throws SQLException {
	final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/upload/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:16,代码来源:AbstractJiraUploadTest.java

示例8: cleanJiraDataBaseForImport

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBaseForImport() throws SQLException {
	final DataSource datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:AbstractJiraUploadTest.java

示例9: initializeJiraDataBase3

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBase3() throws SQLException {
	final Connection connection = datasource.getConnection();
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-3/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-3/jira.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:AbstractJiraData3Test.java

示例10: cleanJiraDataBase3

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBase3() throws SQLException {
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-3/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:14,代码来源:AbstractJiraData3Test.java

示例11: cleanJiraDataBaseForImport

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBaseForImport() throws SQLException {
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-1/jira-drop.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-2/jira-drop.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/upload/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:16,代码来源:JiraUpdateDaoTest.java

示例12: initializeJiraDataBase2

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBase2() throws SQLException {
	final Connection connection = datasource.getConnection();
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-2/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-2/jira.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:15,代码来源:AbstractJiraDataTest.java

示例13: cleanJiraDataBase2

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Clean data base with 'MDA' JIRA project.
 */
@AfterClass
public static void cleanJiraDataBase2() throws SQLException {
	final Connection connection = datasource.getConnection();

	try {
		ScriptUtils.executeSqlScript(connection, new EncodedResource(new ClassPathResource("sql/base-2/jira-drop.sql"), StandardCharsets.UTF_8));
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:14,代码来源:AbstractJiraDataTest.java

示例14: MergedSqlConfig

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
/**
 * Construct a {@code MergedSqlConfig} instance by merging the configuration
 * from the supplied local (potentially method-level) {@code @SqlConfig} annotation
 * with class-level configuration discovered on the supplied {@code testClass}.
 * <p>Local configuration overrides class-level configuration.
 * <p>If the test class is not annotated with {@code @SqlConfig}, no merging
 * takes place and the local configuration is used "as is".
 */
MergedSqlConfig(SqlConfig localSqlConfig, Class<?> testClass) {
	Assert.notNull(localSqlConfig, "Local @SqlConfig must not be null");
	Assert.notNull(testClass, "testClass must not be null");

	// Get global attributes, if any.
	AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(testClass,
		SqlConfig.class.getName(), false, false);

	// Override global attributes with local attributes.
	if (attributes != null) {
		for (String key : attributes.keySet()) {
			Object value = AnnotationUtils.getValue(localSqlConfig, key);
			if (value != null) {
				// Is the value explicit (i.e., not a 'default')?
				if (!value.equals("") && (value != TransactionMode.DEFAULT) && (value != ErrorMode.DEFAULT)) {
					attributes.put(key, value);
				}
			}
		}
	}
	else {
		// Otherwise, use local attributes only.
		attributes = AnnotationUtils.getAnnotationAttributes(localSqlConfig, false, false);
	}

	this.dataSource = attributes.getString("dataSource");
	this.transactionManager = attributes.getString("transactionManager");
	this.transactionMode = getEnum(attributes, "transactionMode", TransactionMode.DEFAULT, TransactionMode.INFERRED);
	this.encoding = attributes.getString("encoding");
	this.separator = getString(attributes, "separator", ScriptUtils.DEFAULT_STATEMENT_SEPARATOR);
	this.commentPrefix = getString(attributes, "commentPrefix", ScriptUtils.DEFAULT_COMMENT_PREFIX);
	this.blockCommentStartDelimiter = getString(attributes, "blockCommentStartDelimiter",
		ScriptUtils.DEFAULT_BLOCK_COMMENT_START_DELIMITER);
	this.blockCommentEndDelimiter = getString(attributes, "blockCommentEndDelimiter",
		ScriptUtils.DEFAULT_BLOCK_COMMENT_END_DELIMITER);
	this.errorMode = getEnum(attributes, "errorMode", ErrorMode.DEFAULT, ErrorMode.FAIL_ON_ERROR);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:46,代码来源:MergedSqlConfig.java

示例15: executeScript

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入依赖的package包/类
public static void executeScript(DataSource dataSource, String... sqlResourcePaths) throws DataAccessException,
		SQLException {
	for (String sqlResourcePath : sqlResourcePaths) {
		Resource resource = resourceLoader.getResource(sqlResourcePath);
		ScriptUtils.executeSqlScript(dataSource.getConnection(), new EncodedResource(resource, DEFAULT_ENCODING));
	}
}
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:8,代码来源:DataFixtures.java


注:本文中的org.springframework.jdbc.datasource.init.ScriptUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。