本文整理汇总了Java中org.flywaydb.core.internal.dbsupport.JdbcTemplate类的典型用法代码示例。如果您正苦于以下问题:Java JdbcTemplate类的具体用法?Java JdbcTemplate怎么用?Java JdbcTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JdbcTemplate类属于org.flywaydb.core.internal.dbsupport包,在下文中一共展示了JdbcTemplate类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dollarQuotedString
import org.flywaydb.core.internal.dbsupport.JdbcTemplate; //导入依赖的package包/类
@Test
public void dollarQuotedString() throws SQLException {
OpenConnectionCountDriverDataSource dataSource = OpenConnectionCountDriverDataSource.getInstance(null);
DbSupport dbSupport = DbSupportFactory.createDbSupport(dataSource.getConnection(), true);
JdbcTemplate jdbcTemplate = dbSupport.getJdbcTemplate();
System.out.println(dataSource.getOpenConnectionCount());
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql/h2");
flyway.migrate();
MigrationVersion version = flyway.info().current().getVersion();
System.out.println(version.toString());
System.out.println(flyway.info().current().getDescription());
// 'Mr. Semicolon+Linebreak;\nanother line'
jdbcTemplate.execute("INSERT INTO test_user (name) VALUES (?)", "martin.zhou");
List<String> strings = jdbcTemplate.query("select name from test_user", null);
if (null != strings && strings.size() > 0) {
for (String string : strings) {
System.out.println("string = " + string);
}
}else {
System.out.println("no data.");
}
System.out.println(jdbcTemplate.queryForString("select name from test_user where name like '%line'''"));
}
示例2: execute
import org.flywaydb.core.internal.dbsupport.JdbcTemplate; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void execute(Connection connection) {
SqlScript sqlScript = new SqlScript(info.getApplyDdl(), DbSupportFactory.createDbSupport(connection, true));
sqlScript.execute(new JdbcTemplate(connection, 0));
}