List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource DriverManagerDataSource
public DriverManagerDataSource(String url)
From source file:paillard.florent.springframework.simplejdbcupdate.SimpleJdbcUpdateTestCase.java
@Test public void testSqlParameterSource() { DataSource dataSource = new DriverManagerDataSource("jdbc:hsqldb:mem:testdb"); SimpleJdbcTemplate createTableTemplate = new SimpleJdbcTemplate(dataSource); createTableTemplate.update(//from w w w . ja v a 2 s .c o m "create table dummy_table (key_1 VARCHAR(50), key_2 INT, a_string VARCHAR(50), an_int INTEGER, a_bool BIT) "); SimpleJdbcUpdate simpleJdbcUpdate = new SimpleJdbcUpdate(dataSource).withTableName("dummy_table") .updatingColumns("a_string", "an_int", "a_bool").restrictingColumns("key_1", "key_2"); SqlParameterSource mapSqlParameterSource1 = new MapSqlParameterSource().addValue("a_string", "Hello") .addValue("an_int", 42).addValue("a_bool", true); SqlParameterSource mapSqlParameterSource2 = new MapSqlParameterSource().addValue("key_1", "Pwet") .addValue("key_2", 3); simpleJdbcUpdate.execute(mapSqlParameterSource1, mapSqlParameterSource2); }
From source file:paillard.florent.springframework.simplejdbcupdate.SimpleJdbcUpdateTestCase.java
@Test public void testMap() { DataSource dataSource = new DriverManagerDataSource("jdbc:hsqldb:mem:testdb"); SimpleJdbcUpdate simpleJdbcUpdate = new SimpleJdbcUpdate(dataSource).withTableName("dummy_table") .updatingColumns("a_string", "an_int", "a_bool").restrictingColumns("key_1", "key_2"); Map<String, Object> map1 = new HashMap<String, Object>(); map1.put("a_string", "Hello"); map1.put("an_int", 42); map1.put("a_bool", true); Map<String, Object> map2 = new HashMap<String, Object>(); map2.put("key_1", "Pwet"); map2.put("key_2", 3); simpleJdbcUpdate.execute(map1, map2); }
From source file:info.naiv.lab.java.tool.sqlite.exporter.component.Destination.java
/** * * @param props// ww w . j a v a2 s .c o m * @param dataAccess */ public Destination(Properties props, DataAccess dataAccess) { String dir = props.getProperty("export.directory"); String base = props.getProperty("export.basename"); String ext = props.getProperty("export.extension"); Calendar date = ClassicDateUtils.now(); String ts = (new SimpleDateFormat("yyyyMMdd-HHmmss")).format(date.getTime()); String p = concatnate(dir, base, "-", ts, ".", ext); String url = "jdbc:sqlite:" + p; this.props = props; logger.info("dest url = {}", url); DriverManagerDataSource dataSource = new DriverManagerDataSource(url); this.jdbcTemplate = new JdbcTemplate(dataSource); this.dataAccess = dataAccess; }
From source file:paillard.florent.springframework.simplejdbcupdate.SimpleJdbcUpdateTestCase.java
@Test public void testWhereOperator() { DataSource dataSource = new DriverManagerDataSource("jdbc:hsqldb:mem:testdb"); Map<String, Operator> where = new HashMap<String, Operator>(); where.put("key_1", Operator.EQUALS); where.put("key_2", Operator.LESS_THAN); SimpleJdbcUpdate simpleJdbcUpdate = new SimpleJdbcUpdate(dataSource).withTableName("dummy_table") .updatingColumns("a_string", "an_int", "a_bool").restrictingColumns(where); Map<String, Object> map1 = new HashMap<String, Object>(); map1.put("a_string", "Hello"); map1.put("an_int", 42); map1.put("a_bool", true); Map<String, Object> map2 = new HashMap<String, Object>(); map2.put("key_1", "Pwet"); map2.put("key_2", 3); simpleJdbcUpdate.execute(map1, map2); }