本文整理匯總了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));
}