List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate
public JdbcTemplate(DataSource dataSource)
From source file:ru.org.linux.user.ProfileDao.java
@Autowired private void setDataSource(DataSource ds) { jdbcTemplate = new JdbcTemplate(ds); }
From source file:com.dai.dao.EscalaoDaoImpl.java
public void inserirEscalao(Escalao escalao) { JdbcTemplate template = new JdbcTemplate(dataSource); String sql = "INSERT INTO escalao " + "(designacaoEscalao) VALUES (?)"; template.update(sql, new Object[] { escalao.getDesignacao() }); }
From source file:org.smart.migrate.dao.impl.DefaultImportDao.java
public DefaultImportDao(MigratePlan migratePlan, DataSource targetDataSource, ImportLogger importLogger) { sourceJdbcTemplate = null;/* ww w.j av a 2 s . co m*/ targetJdbcTemplate = null; if (targetDataSource != null) { targetJdbcTemplate = new JdbcTemplate(targetDataSource); } this.importLogger = importLogger; }
From source file:com.dai.dao.SelecaoJogoDaoImpl.java
public List<SelecaoJogo> listaSL(int idJogo) { List<SelecaoJogo> slList = new ArrayList(); String sql = "select * from selecaoJogo where jogo_idjogo=" + idJogo; JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); slList = jdbcTemplate.query(sql, new SelecaoJogoRowMapper()); return slList; }
From source file:job_agency.job_agency.beans.DatabaseBean.java
public void create() throws Exception { JdbcTemplate jdbc = new JdbcTemplate(dataSource); String sqlperson = "create table Person (\n" + " id integer primary key GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),\n" + " username varchar(20),\n" + " firstname varchar(20),\n" + " lastname varchar(20),\n" + " sex varchar(10),\n" + " birthday Date,\n" + " postalcode varchar(20),\n" + " city varchar(20),\n" + " country varchar(3),\n" + " educationself varchar(30),\n" + " educationmother varchar(30),\n" + " educationfather varchar(30),\n" + " email varchar(30),\n" + " location varchar(30),\n" + " interest varchar(30),\n" + " newsletter boolean\n" + ")"; String sqljoboffer = "create table joboffer (\n" + " id integer primary key GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),\n" + " title varchar(20),\n" + " postalcode varchar(20),\n" + " city varchar(20),\n" + " country varchar(3),\n" + " phone varchar(30),\n" + " email varchar(30),\n" + " jobdescription varchar(300),\n" + " salary varchar(30),\n" + " keyword varchar(200),\n" + " newsletter boolean\n" + ")"; LOG.info("Creating table Person ..."); LOG.info("Creating table Joboffer ..."); try {// w w w .jav a2 s . c o m jdbc.execute("drop table person"); jdbc.execute("drop table joboffer"); } catch (Throwable e) { // ignore } jdbc.execute(sqlperson); jdbc.execute(sqljoboffer); LOG.info("... created table person"); LOG.info("... created table joboffer"); }
From source file:name.marcelomorales.siqisiqi.examples.simple.init.InitialData.java
@Inject public InitialData(DataSource dataSource) throws SQLException, IOException { jdbcTemplate = new JdbcTemplate(dataSource); try (Connection c = dataSource.getConnection()) { URL resource = Resources.getResource("ddl.sql"); String s = Resources.toString(resource, Charsets.US_ASCII); Iterable<String> split = Splitter.on(';').omitEmptyStrings().trimResults().split(s); for (String sql : split) { try (Statement st = c.createStatement()) { st.execute(sql);//from w ww.ja v a 2s . c o m } } c.commit(); // this is needed because we don't use @TransactionAttribute } }
From source file:cn.edu.hfut.dmic.webcollector.util.MysqlHelper.java
public MysqlHelper(String url, String username, String password, int initialSize, int maxActive) { dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl(url);/*w ww .j a va 2s . c o m*/ dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setInitialSize(initialSize); dataSource.setMaxActive(maxActive); template = new JdbcTemplate(dataSource); }
From source file:orz.neptune.prospring3.ch8.JdbcContactDao.java
public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; this.jdbcTemplate = new JdbcTemplate(dataSource); this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); this.updateContact = new UpdateContact(dataSource); this.insertContact = new InsertContact(dataSource); this.storeFunctionQuery = new StoreFunctionQuery(dataSource); }
From source file:net.gplatform.spring.social.base.JdbcUsersConnectionRepositoryTableCreator.java
public void createTableIfNotExist() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); try {// ww w . j a v a 2 s. c o m jdbcTemplate.queryForList("select count(*) from UserConnection"); } catch (Exception e) { LOG.debug("Create table UserConnection"); try { ResourceDatabasePopulator rdp = new ResourceDatabasePopulator(); rdp.addScript(new ClassPathResource( "/org/springframework/social/connect/jdbc/JdbcUsersConnectionRepository.sql")); DatabasePopulatorUtils.execute(rdp, dataSource); } catch (Exception e1) { LOG.error("Error create table UserConnection", e1); } } }