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


Java ScriptUtils.executeSqlScript方法代码示例

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


在下文中一共展示了ScriptUtils.executeSqlScript方法的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: 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

示例15: main

import org.springframework.jdbc.datasource.init.ScriptUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String url = "jdbc:postgresql://localhost:5432/quartz";

    Class.forName("org.postgresql.Driver");
    Connection db = DriverManager.getConnection(url, "quartz", "quartz");

    System.out.println("Initializing database and creating tables");
    db.setAutoCommit(false);
    ScriptUtils.executeSqlScript(db, new FileSystemResource("tables_postgres.sql"));
    db.setAutoCommit(true);

    db.close();

    System.out.println("Database initialized");
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:16,代码来源:InitDatabase.java


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