List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate()
From source file:com.mycompany.airportdatabasebuilder.Dao.java
public Dao() { datasource = new DriverManagerDataSource(); datasource.setDriverClassName("com.mysql.jdbc.Driver"); datasource.setUrl("jdbc:mysql://localhost:3306/flights"); datasource.setUsername("root"); datasource.setPassword(""); jdbcTemplate = new JdbcTemplate(); jdbcTemplate.setDataSource(datasource); }
From source file:com.hp.autonomy.frontend.find.core.AbstractDatabaseInitIT.java
/** * Check connection to our configured datasource. * * Depending on the datasource a dummy statement must sometimes * be executed to ensure a valid connection. *//*w ww .j a va2 s. c o m*/ @Test public void connectToDatabase() { final JdbcTemplate jdbcTemplate = new JdbcTemplate(); jdbcTemplate.setDataSource(dataSource); jdbcTemplate.execute("SELECT true"); }
From source file:com.ewcms.component.comment.dao.CommentDAO.java
@Autowired public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(); jdbcTemplate.setDataSource(dataSource); }
From source file:com.nortal.petit.orm.statement.UpdateStatementTest.java
@Test public void test__sqlCreatedEqual() { UpdateStmtBean bean = UpdateStatementFixture.getDefaultBean(); bean.setDescription("DESC"); UpdateStatement<UpdateStmtBean> update1 = new UpdateStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), bean); update1.setBy("description").where(Where.eq("id", 1L)); UpdateStatement<UpdateStmtBean> update2 = new UpdateStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), UpdateStmtBean.class); update2.setBy("description").where(Where.eq("id", 1L)).setBeans(Arrays.asList(bean)); System.out.println(update1.getSqlWithParams()); System.out.println(update2.getSqlWithParams()); MatcherAssert.assertThat(update1.getSqlWithParams(), Matchers.equalTo(update2.getSqlWithParams())); }
From source file:com.nortal.petit.orm.statement.DeleteStatementTest.java
@Test public void test__sqlCreatedEqual() { UpdateStmtBean bean = UpdateStatementFixture.getDefaultBean(); bean.setDescription("DESC"); DeleteStatement<UpdateStmtBean> update1 = new DeleteStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), bean); update1.setBy("description").where(Where.eq("id", 1L)); DeleteStatement<UpdateStmtBean> update2 = new DeleteStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), UpdateStmtBean.class); update2.setBy("description").where(Where.eq("id", 1L)).setBeans(Arrays.asList(bean)); System.out.println(update1.getSqlWithParams()); System.out.println(update2.getSqlWithParams()); MatcherAssert.assertThat(update1.getSqlWithParams(), Matchers.equalTo(update2.getSqlWithParams())); }
From source file:com.nortal.petit.orm.statement.LoadStatementTest.java
private <B> LoadStatement<B> load(JdbcTemplate jdbcTemplate, Class<B> type) { return new LoadStatement<B>(jdbcTemplate == null ? new JdbcTemplate() : jdbcTemplate, new OracleStatementBuilder(), type); }
From source file:ar.com.zauber.commons.gis.street.GuessStreetTest.java
/** test */ public final void testFoo() throws Exception { final String[] alternativas = { "24 DE NOVIEMBRE", "ALBERTI", "BOLIVAR", "BRASIL AV.", "CATAMARCA", "CEVALLOS, Virrey", "CHACABUCO", "COMBATE DE LOS POZOS", "DEAN FUNES", "ENTRE RIOS AV.", "ESQUEL", "GIORELLO, PABLO", "HORNOS, Gral.", "IRIGOYEN, BERNARDO de", "JUJUY AV.", "LA RIOJA", "LIMA", "LUCA, ESTEBAN de", "MATHEU", "MOMPOX", "PERU", "PICHINCHA AV.", "PIEDRAS", "SAENZ PE?A, LUIS, PRES.", "SALTA", "SAN JOSE", "SANCHEZ DE LORIA AV.", "SANTIAGO DEL ESTERO", "SOLIS", "TACUARI", "URQUIZA, Gral.", }; SQLStreetsDAO streetsDAO = new SQLStreetsDAO(new JdbcTemplate()); final List<GuessStreetResult> l = streetsDAO.guessStreetName(Arrays.asList(alternativas), " GENERAL, HORNOS ."); System.out.println(l);/*from w w w . jav a 2 s . com*/ }
From source file:com.nortal.petit.orm.statement.StatementsTest.java
private <B> LoadStatement<B> load(Class<B> type) { return new LoadStatement<B>(new JdbcTemplate(), new OracleStatementBuilder(), type); }
From source file:com.nortal.petit.orm.statement.StatementsTest.java
@Test public void testInsert2() { Bean b = new Bean(); b.setSuperProp(1L);//from w ww .j a va 2 s . c o m b.setSuperProp(5L); InsertStatement<Bean> i1 = insert(b); InsertStatement<Bean> i2 = new InsertStatement<BeanMappingFactoryTest.Bean>(new JdbcTemplate(), new PostgreStatementBuilder(), b); String sql1 = i1.getSql(); String sql2 = i2.getSql(); String sql3 = i1.getSqlWithParams(); String sql4 = i2.getSqlWithParams(); System.out.println("OHO"); }
From source file:com.nortal.petit.orm.statement.UpdateStatementTest.java
@Test public void test__impliedSqlCreatedEqual() { UpdateStmtBean bean = UpdateStatementFixture.getDefaultBean(); bean.setId(1L);/* w w w. jav a 2 s . com*/ bean.setDescription("DESC"); UpdateStatement<UpdateStmtBean> update1 = new UpdateStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), bean); update1.setBy("description"); UpdateStatement<UpdateStmtBean> update2 = new UpdateStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), UpdateStmtBean.class); update2.setBy("description").setBeans(Arrays.asList(bean)); UpdateStatement<UpdateStmtBean> update3 = new UpdateStatement<UpdateStmtBean>(new JdbcTemplate(), new OracleStatementBuilder(), bean); update3.setBy("description").where(Where.eq("id", 1L)); System.out.println(update1.getSqlWithParams()); System.out.println(update2.getSqlWithParams()); System.out.println(update3.getSqlWithParams()); MatcherAssert.assertThat(update1.getSqlWithParams(), Matchers.equalTo(update2.getSqlWithParams())); MatcherAssert.assertThat(update1.getSqlWithParams(), Matchers.equalTo(update3.getSqlWithParams())); }