List of usage examples for org.springframework.jdbc.core JdbcTemplate execute
@Override public void execute(final String sql) throws DataAccessException
From source file:AddressBookDaoTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = ctx.getBean("addressBookDAO", AddressBookDAO.class); a1 = new Address(); a1.setResidentLastName("Rymal"); a1.setStreetAddress("10953 Garfield"); a1.setCityName("Coopersville"); a1.setState("MI"); a1.setZipCode("49404"); a2 = new Address(); a2.setResidentLastName("Smith"); a2.setStreetAddress("10234 Samson"); a2.setCityName("Coopersville"); a2.setState("OH"); a2.setZipCode("49411"); a3 = new Address(); a3.setResidentLastName("Jones"); a3.setStreetAddress("123 Main"); a3.setCityName("Thompsonville"); a3.setState("IN"); a3.setZipCode("12334"); JdbcTemplate cleaner = ctx.getBean("jdbcTemplate", JdbcTemplate.class); cleaner.execute("DELETE FROM addresses"); }
From source file:com.swcguild.vendingmachinemvc.dao.VendingMachineDaoDbImplTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = ctx.getBean("VendingMachineDao", VendingMachineDao.class); JdbcTemplate cleaner = (JdbcTemplate) ctx.getBean("jdbcTemplate"); cleaner.execute("delete from items"); }
From source file:com.swcguild.dvdlibraryv4.dao.DvdLibraryDaoTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = (DvdLibraryDao) ctx.getBean("dvdLibraryDao"); JdbcTemplate cleaner = (JdbcTemplate) ctx.getBean("jdbcTemplate"); cleaner.execute("delete from dvds"); }
From source file:com.tsg.dvdlibrarymvc.dao.DvdLibraryDAOTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = ctx.getBean("dvdLibraryDAO", DvdLibraryDAO.class); JdbcTemplate cleaner = (JdbcTemplate) ctx.getBean("jdbcTemplate"); cleaner.execute("delete from dvds"); dvd1 = new DVD(); dvd1.setDvdTitle("Fargo"); dvd1.setDirectorsName("Joel Cohen"); dvd1.setMpaaRating("R"); dvd1.setStudio("Miramax"); dvd1.setReleaseDate("1996"); dvd2 = new DVD(); dvd2.setDvdTitle("Raising Arizona"); dvd2.setDirectorsName("Ethan Cohen"); dvd2.setMpaaRating("R"); dvd2.setStudio("STUDIO"); dvd2.setReleaseDate("1989"); dvd3 = new DVD(); dvd3.setDvdTitle("O brother, where art thou"); dvd3.setDirectorsName("Joel Cohen"); dvd3.setMpaaRating("pg-13"); dvd3.setStudio("Universal"); dvd3.setReleaseDate("2000"); }
From source file:com.tsg.contactlistmvc.dao.ContactListDaoTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = ctx.getBean("contactListDAO", ContactListDAO.class); JdbcTemplate cleaner = (JdbcTemplate) ctx.getBean("jdbcTemplate"); cleaner.execute("delete from contacts"); nc1 = new Contact(); nc1.setFirstName("Jimmy"); nc1.setLastName("Smith"); nc1.setCompany("Sun"); nc1.setEmail("jimmy@smith.com"); nc1.setPhone("1112223333"); nc2 = new Contact(); nc2.setFirstName("John"); nc2.setLastName("Jones"); nc2.setCompany("Apple"); nc2.setEmail("john@jones.com"); nc2.setPhone("5556667777"); nc3 = new Contact(); nc3.setFirstName("Steve"); nc3.setLastName("Smith"); nc3.setCompany("Microsoft"); nc3.setEmail("steve@msft.com"); nc3.setPhone("5552221234"); }
From source file:net.sourceforge.subsonic.dao.schema.hsql.Schema33.java
public void execute(JdbcTemplate template) { if (template.queryForInt("select count(*) from version where version = 9") == 0) { LOG.info("Updating database schema to version 9."); template.execute("insert into version values (9)"); }//from www .j a va 2s . co m if (!columnExists(template, "client_side_playlist", "player")) { LOG.info("Database column 'player.client_side_playlist' not found. Creating it."); template.execute("alter table player add client_side_playlist boolean default false not null"); LOG.info("Database column 'player.client_side_playlist' was added successfully."); } }
From source file:net.sourceforge.subsonic.dao.schema.hsql.Schema40.java
@Override public void execute(JdbcTemplate template) { if (template.queryForInt("select count(*) from version where version = 15") == 0) { LOG.info("Updating database schema to version 15."); template.execute("insert into version values (15)"); // Reset stream byte count since they have been wrong in earlier releases. template.execute("update user set bytes_streamed = 0"); LOG.info("Reset stream byte count statistics."); }/*from ww w. j a v a2 s. c o m*/ }
From source file:edu.hm.cs.goetz1.seminar.db.SpringUserDAO.java
@Autowired public SpringUserDAO(JdbcTemplate jdbcTemplate, RowMapper<User> rowMapper) { this.jdbcTemplate = jdbcTemplate; this.rowMapper = rowMapper; if (!tableExists()) { jdbcTemplate.execute(CREATE_TABLE); }/*from w w w.j ava2 s .c o m*/ }
From source file:net.sourceforge.subsonic.dao.schema.hsql.Schema36.java
@Override public void execute(JdbcTemplate template) { if (template.queryForInt("select count(*) from version where version = 12") == 0) { LOG.info("Updating database schema to version 12."); template.execute("insert into version values (12)"); }/*from w w w. j a va2s. c om*/ if (!columnExists(template, "technology", "player")) { LOG.info("Database column 'player.technology' not found. Creating it."); template.execute("alter table player add technology varchar default 'WEB' not null"); LOG.info("Database column 'player.technology' was added successfully."); } }
From source file:com.thesoftwareguild.addressbook.AddressBookDaoTest.java
@Before public void setUp() { ApplicationContext ctx = new ClassPathXmlApplicationContext("test-applicationContext.xml"); dao = (AddressBookDao) ctx.getBean("addressBookDao"); JdbcTemplate cleaner = (JdbcTemplate) ctx.getBean("jdbcTemplate"); cleaner.execute("delete from addresses"); // dao = ctx.getBean("addressBookDao", AddressBookDao.class); }