List of usage examples for org.apache.commons.dbutils QueryRunner update
public int update(Connection conn, String sql, Object... params) throws SQLException
From source file:org.kitodo.data.database.persistence.apache.MySQLHelper.java
/** * Remove filter from user.//from w ww . j a v a 2 s . com * * @param userId * id of user * @param filterstring * String */ public static void removeFilterFromUser(int userId, String filterstring) throws SQLException { Connection connection = helper.getConnection(); try { QueryRunner run = new QueryRunner(); Object[] param = { userId, filterstring }; String sql = "DELETE FROM userProperty WHERE title = '_filter' AND user_id = ? AND value = ?"; if (logger.isDebugEnabled()) { logger.debug(sql + ", " + Arrays.toString(param)); } run.update(connection, sql, param); } finally { closeConnection(connection); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerLocus(final Locus locus) { checkNotNull(locus);//from w ww . j a v a2 s . c o m // todo: use transaction QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_LOCUS_SQL, locus.getId(), locus); queryRunner.update(INSERT_LOCUS_ID_SQL, locus.getGlstring(), JdbcUtils.hash(locus.getGlstring()), locus.getId()); } catch (SQLException e) { logger.warn("could not register locus " + locus.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerAllele(final Allele allele) { checkNotNull(allele);//from www.java 2 s .c o m QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_ALLELE_SQL, allele.getId(), allele); queryRunner.update(INSERT_ALLELE_ID_SQL, allele.getGlstring(), JdbcUtils.hash(allele.getGlstring()), allele.getId()); } catch (SQLException e) { logger.warn("could not register allele " + allele.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerAlleleList(final AlleleList alleleList) { checkNotNull(alleleList);// w w w. java 2 s .co m QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_ALLELE_LIST_SQL, alleleList.getId(), alleleList); queryRunner.update(INSERT_ALLELE_LIST_ID_SQL, alleleList.getGlstring(), JdbcUtils.hash(alleleList.getGlstring()), alleleList.getId()); } catch (SQLException e) { logger.warn("could not register allele list " + alleleList.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerHaplotype(final Haplotype haplotype) { checkNotNull(haplotype);/*from www . j a va 2 s . co m*/ QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_HAPLOTYPE_SQL, haplotype.getId(), haplotype); queryRunner.update(INSERT_HAPLOTYPE_ID_SQL, haplotype.getGlstring(), JdbcUtils.hash(haplotype.getGlstring()), haplotype.getId()); } catch (SQLException e) { logger.warn("could not register haplotype " + haplotype.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerGenotype(final Genotype genotype) { checkNotNull(genotype);/*from ww w . ja va 2 s . c om*/ QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_GENOTYPE_SQL, genotype.getId(), genotype); queryRunner.update(INSERT_GENOTYPE_ID_SQL, genotype.getGlstring(), JdbcUtils.hash(genotype.getGlstring()), genotype.getId()); } catch (SQLException e) { logger.warn("could not register genotype " + genotype.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerGenotypeList(final GenotypeList genotypeList) { checkNotNull(genotypeList);// w ww.ja va2 s. c o m QueryRunner queryRunner = new QueryRunner(dataSource); try { queryRunner.update(INSERT_GENOTYPE_LIST_SQL, genotypeList.getId(), genotypeList); queryRunner.update(INSERT_GENOTYPE_LIST_ID_SQL, genotypeList.getGlstring(), JdbcUtils.hash(genotypeList.getGlstring()), genotypeList.getId()); } catch (SQLException e) { logger.warn("could not register genotype list " + genotypeList.getId(), e); } }
From source file:org.nmdp.gl.service.jdbc.JdbcGlRegistry.java
@Override public void registerMultilocusUnphasedGenotype(final MultilocusUnphasedGenotype multilocusUnphasedGenotype) { checkNotNull(multilocusUnphasedGenotype); QueryRunner queryRunner = new QueryRunner(dataSource); try {//from w w w.j av a 2 s . c om queryRunner.update(INSERT_MULTILOCUS_UNPHASED_GENOTYPE_SQL, multilocusUnphasedGenotype.getId(), multilocusUnphasedGenotype); queryRunner.update(INSERT_MULTILOCUS_UNPHASED_GENOTYPE_ID_SQL, multilocusUnphasedGenotype.getGlstring(), JdbcUtils.hash(multilocusUnphasedGenotype.getGlstring()), multilocusUnphasedGenotype.getId()); } catch (SQLException e) { logger.warn("could not register multilocus unphased genotype " + multilocusUnphasedGenotype.getId(), e); } }
From source file:org.okinawaopenlabs.orientdb.client.ConnectionUtilsJdbcImpl.java
@Override public int update(Connection conn, String sql, Object[] params) throws SQLException { if (logger.isDebugEnabled()) { logger.debug(String.format("update(conn=%s, sql=%s, params=%s) - start ", conn, sql, params)); }/*from ww w . j a v a 2 s .c om*/ QueryRunner qRunner = new QueryRunner(); int rows = qRunner.update(conn, sql, params); if (logger.isDebugEnabled()) { logger.debug(String.format("update(rows=%s) - end ", rows)); } return rows; }
From source file:org.openlogics.gears.jdbc.DataStore.java
/** * Executes the given statement using the {@link org.apache.commons.dbutils.QueryRunner} class * * @param query/*from www .ja v a 2 s . c o m*/ * @param data * @return * @throws SQLException */ private int update(String query, List data) throws SQLException { try { QueryRunner qr = new QueryRunner(); return qr.update(getConnection(), query, data.toArray()); } finally { closeDBConn(); } }