List of usage examples for org.apache.commons.dbutils QueryRunner query
public <T> T query(String sql, ResultSetHandler<T> rsh, Object... params) throws SQLException
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public Locus findLocus(final String id) { Locus locus = loci.getIfPresent(id); if (locus != null) { return locus; }//from ww w. j a v a 2s . c o m QueryRunner queryRunner = new QueryRunner(dataSource); try { locus = queryRunner.query(LOCUS_SQL, new LocusHandler(), id); if (locus != null) { loci.put(id, locus); } return locus; } catch (SQLException e) { logger.warn("could not find locus for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public Allele findAllele(final String id) { Allele allele = alleles.getIfPresent(id); if (allele != null) { return allele; }// ww w. j a v a 2 s . c o m QueryRunner queryRunner = new QueryRunner(dataSource); try { allele = queryRunner.query(ALLELE_SQL, new AlleleHandler(), id); if (allele != null) { alleles.put(id, allele); } return allele; } catch (SQLException e) { logger.warn("could not find allele for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public AlleleList findAlleleList(final String id) { QueryRunner queryRunner = new QueryRunner(dataSource); try {/*from www . j av a 2s . c o m*/ return queryRunner.query(ALLELE_LIST_SQL, new AlleleListHandler(), id); } catch (SQLException e) { logger.warn("could not find allele list for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public Haplotype findHaplotype(final String id) { QueryRunner queryRunner = new QueryRunner(dataSource); try {/* ww w. j a v a 2s . co m*/ return queryRunner.query(HAPLOTYPE_SQL, new HaplotypeHandler(), id); } catch (SQLException e) { logger.warn("could not find haplotype for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public Genotype findGenotype(final String id) { QueryRunner queryRunner = new QueryRunner(dataSource); try {/* w ww. j a v a 2s . c om*/ return queryRunner.query(GENOTYPE_SQL, new GenotypeHandler(), id); } catch (SQLException e) { logger.warn("could not find genotype for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public GenotypeList findGenotypeList(final String id) { QueryRunner queryRunner = new QueryRunner(dataSource); try {//from w w w . ja v a 2 s . c o m return queryRunner.query(GENOTYPE_LIST_SQL, new GenotypeListHandler(), id); } catch (SQLException e) { logger.warn("could not find genotype list for id " + id, e); return null; } }
From source file:org.nmdp.gl.service.jdbc.JdbcIdResolver.java
@Override public MultilocusUnphasedGenotype findMultilocusUnphasedGenotype(final String id) { QueryRunner queryRunner = new QueryRunner(dataSource); try {/*from w ww .j a v a 2 s . co m*/ return queryRunner.query(MULTILOCUS_UNPHASED_GENOTYPE_SQL, new MultilocusUnphasedGenotypeHandler(), id); } catch (SQLException e) { logger.warn("could not find multilocus unphased genotype for id " + id, e); return null; } }
From source file:org.okinawaopenlabs.orientdb.client.ConnectionUtilsJdbcImpl.java
@Override public void query(Connection conn, String sql) throws SQLException { if (logger.isDebugEnabled()) { logger.debug(String.format("query(conn=%s, sql=%s) - start ", conn, sql)); }//from ww w . j ava 2 s. com QueryRunner qRunner = new QueryRunner(); ResultSetHandler<Object> rsh = null; qRunner.query(conn, sql, rsh); if (logger.isDebugEnabled()) { logger.debug("query() - end "); } }
From source file:org.okinawaopenlabs.orientdb.client.ConnectionUtilsJdbcImpl.java
@Override public <T> T query(Connection conn, String sql, ResultSetHandler<T> handler) throws SQLException { if (logger.isDebugEnabled()) { logger.trace(String.format("query(conn=%s, sql=%s, handler=%s) - start ", conn, sql, handler)); }//w ww . java 2s. c o m QueryRunner qRunner = new QueryRunner(); T records = qRunner.query(conn, sql, handler); if (logger.isDebugEnabled()) { logger.trace(String.format("query(records=%s) - end ", records)); } return records; }
From source file:org.rti.zcore.dar.utils.DatabaseUtils.java
/** * Get a single value/*from w w w . j a v a2s . c o m*/ * String idSql = "SELECT LAST_INSERT_ID() AS id;"; * * @param sql * @return * @throws ServletException * @throws SQLException */ public static Object getScalar(Connection conn, String sql) throws ServletException, SQLException { ResultSetHandler h = new ScalarHandler(); //DataSource dataSource = null; //dataSource = DatabaseUtils.getZEPRSDataSource(); QueryRunner run = new QueryRunner(); Object result = run.query(conn, sql, h); return result; }