當前位置: 首頁>>代碼示例>>Java>>正文


Java JdbcTemplate類代碼示例

本文整理匯總了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'''"));
  }
 
開發者ID:zhoushineyoung,項目名稱:zookeeper-edit,代碼行數:30,代碼來源:H2DaoTest.java

示例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));
}
 
開發者ID:icode,項目名稱:ameba,代碼行數:8,代碼來源:SqlMigrationExecutor.java


注:本文中的org.flywaydb.core.internal.dbsupport.JdbcTemplate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。