Example usage for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

List of usage examples for org.springframework.jdbc.core JdbcTemplate JdbcTemplate

Introduction

In this page you can find the example usage for org.springframework.jdbc.core JdbcTemplate JdbcTemplate.

Prototype

public JdbcTemplate(DataSource dataSource) 

Source Link

Document

Construct a new JdbcTemplate, given a DataSource to obtain connections from.

Usage

From source file:kniznica.SQLScenarista.java

public SQLScenarista() {
    MysqlDataSource dataSource = new MysqlDataSource();
    dataSource.setUrl("jdbc:mysql://localhost/databaza_filmov");
    dataSource.setUser("root");
    dataSource.setPassword("Rastislav1");

    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:com.dai.dao.JogoDaoImpl.java

@Override
public void novoJogo(Jogo jogo) {

    String sql = "INSERT INTO jogo "
            + "( localJogo, dataJogo,resultadoJogo, horaJogo,competicao) VALUES (?, ?, ?, ?, ?)";

    JdbcTemplate template = new JdbcTemplate(dataSource);

    template.update(sql, new Object[] { jogo.getLocal(), jogo.getData(), jogo.getResultado(), jogo.getHora(),
            jogo.getCompeticao() });//from  w ww  .ja  va  2  s  .c  o m

}

From source file:com.recber.dao.UserDaoImpl.java

@Override
public void insertData(User user) {

    String sql = "INSERT INTO user " + "(first_name,last_name, face, city) VALUES (?, ?, ?,?)";

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    jdbcTemplate.update(sql,//from www.j  ava2  s.co  m
            new Object[] { user.getFirstName(), user.getLastName(), user.getFace(), user.getCity() });

}

From source file:com.dai.dao.SelecaoJogoDaoImpl.java

@Override
public void adicionaSL(SelecaoJogo sl) {

    String sql = "INSERT INTO selecaoJogo " + "( utilizador_idutilizador, jogo_idjogo) VALUES (?, ?)";

    JdbcTemplate template = new JdbcTemplate(dataSource);

    template.update(sql, new Object[] { sl.getIdUtilizador(), sl.getIdJogo() });

}

From source file:database.ExerciseDAOImpl.java

public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    this.template = new JdbcTemplate(dataSource);
}

From source file:wiki.DbConnector.java

public DbConnector(String url) {

    //        DataSource pcpds = new PGPoolingDataSource();
    HikariConfig config = new HikariConfig();
    config.setMaximumPoolSize(20);/*ww w.jav a 2s.  c o  m*/
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    config.addDataSourceProperty("serverName", url);
    config.addDataSourceProperty("databaseName", "wikip");
    config.addDataSourceProperty("user", "wikiuser");
    config.addDataSourceProperty("password", "testing");

    jdbcTemplate = new JdbcTemplate(new HikariDataSource(config));
}

From source file:kniznica.SQLFilm.java

public SQLFilm() {
    MysqlDataSource dataSource = new MysqlDataSource();
    dataSource.setUrl("jdbc:mysql://localhost/databaza_filmov");
    dataSource.setUser("root");
    dataSource.setPassword("Rastislav1");

    jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:com.dai.dao.CompeticaoDaoImpl.java

@Override
public void adicionaCompeticao(Competicao competicao) {

    String sql = "INSERT INTO competicao " + "( designacaoCompeticao, escalao_idEscalao_c) VALUES (?,?)";

    JdbcTemplate template = new JdbcTemplate(dataSource);

    template.update(sql, new Object[] { competicao.getDesignacao(), competicao.getIdEscalao() });

}

From source file:com.univocity.app.utils.DatabaseImpl.java

public DatabaseImpl(DataSource dataSource, File dirWithCreateTableScripts) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    createTables(dirWithCreateTableScripts);
}

From source file:com.beezas.dao.EventDaoImpl.java

public void insertData(User user) {

    String sql = "insert into events"
            + "(title,paidevent,privateevent,webinar,weburl,sub_category_id,description) VALUES (?,?,?,?,?,?,?)";

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    jdbcTemplate.update(sql, new Object[] { user.getTitle(), user.getPaidEvent(), user.getPrivateEvent(),
            user.getWebinar(), user.getWeburl(), user.getCategoryId(), user.getEventDescription(),
            //user.getWebAttend(),

    });/*from  w ww. jav  a  2  s .co m*/

    System.out.println("get category id" + user.getSubCategoryId());

}