List of usage examples for org.apache.commons.dbutils.handlers ScalarHandler ScalarHandler
public ScalarHandler()
From source file:com.fluke.database.dataservice.IntraDayDao.java
public Float getPrevsDayPrice(String equity, String date) { String query = " select closePrice from EOD where equity=? and date < ? order by date desc limit 1"; ScalarHandler rsh = new ScalarHandler(); try {//from w w w .ja v a 2s . c o m //System.out.println(""+equity); return (Float) runner.query(query, rsh, equity, date); } catch (Throwable ex) { throw new RuntimeException(); } }
From source file:com.ruihu.easyshop.book.dao.BookDao.java
/** * /*from w ww. j a va 2s.c o m*/ * @param cid * @return * @throws SQLException */ public int findCountByCategory(String cid) throws SQLException { String sql = "select count(1) from t_book where cid=?"; Number cnt = (Number) qr.query(sql, new ScalarHandler(), cid); return cnt == null ? 0 : cnt.intValue(); }
From source file:com.fluke.data.processor.ReatimeDBReader.java
public Timestamp getLastTimeStamp(String equity) { try {// w w w. j av a 2s . c om String query = "select max(time) from realtime where equity='" + equity + "'"; ScalarHandler rsh = new ScalarHandler(); return (Timestamp) runner.query(query, rsh); } catch (SQLException ex) { throw new RuntimeException(ex); } }
From source file:io.stallion.dataAccess.db.postgres.PostgresTickets.java
public void refillQueue() throws SQLException { QueryRunner q = db.newQuery();//www.j a va2 s.co m ScalarHandler<Long> scalar = new ScalarHandler<Long>(); Long nextId = q.query("SELECT nextval('stallion_tickets_seq')", scalar); for (int x = 0; x < 300; x++) { loadedIds.add(nextId + x); } }
From source file:com.erikw.libraryloan.DatabaseBookDataAccessObject.java
@Override public boolean insertBook(Book book) { try {//from w w w .ja v a 2 s .c o m dbAccess.insert(myConn, "INSERT INTO Books(name, authors," + "publishedYear, available) VALUES (?, ?, ?, ?)", new ScalarHandler<BigDecimal>(), book.getName(), book.getAuthors(), book.getPublishedYear(), book.isAvailable()).longValue(); return true; } catch (Exception ex) { ex.printStackTrace(); } return false; }
From source file:io.dockstore.client.cli.WorkflowET.java
public static ApiClient getWebClient() throws IOException, TimeoutException { final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); File configFile = FileUtils.getFile("src", "test", "resources", "config2"); HierarchicalINIConfiguration parseConfig = Utilities.parseConfig(configFile.getAbsolutePath()); ApiClient client = new ApiClient(); client.setBasePath(parseConfig.getString(Constants.WEBSERVICE_BASE_PATH)); client.addDefaultHeader("Authorization", "Bearer " + (testingPostgres.runSelectStatement("select content from token where tokensource='dockstore';", new ScalarHandler<>()))); return client; }
From source file:com.fluke.data.processor.ReatimeDBReader.java
public Timestamp getMaxtimeNoted() { try {//from w w w . j a v a 2 s. co m String query = "select max(time) from realtime "; ScalarHandler rsh = new ScalarHandler(); return (Timestamp) runner.query(query, rsh); } catch (SQLException ex) { throw new RuntimeException(ex); } }
From source file:io.dockstore.client.cli.GeneralET.java
/** * Checks that all automatic containers have been found by dockstore and are not registered/published *///from w w w . j av a 2s .c o m @Test public void testListAvailableContainers() { final CommonTestUtilities.TestingPostgres testingPostgres = getTestingPostgres(); final long count = testingPostgres.runSelectStatement("select count(*) from tool where ispublished='f'", new ScalarHandler<>()); Assert.assertTrue("there should be 4 entries, there are " + count, count == 4); }
From source file:com.ruihu.easyshop.user.dao.UserDao.java
public boolean findByUidAndPassword(String uid, String password) throws SQLException { String sql = "select count(1) from t_user where uid=? and loginpass=?"; Number number = (Number) qr.query(sql, new ScalarHandler(), uid, password); return number.intValue() > 0; //find result }
From source file:io.stallion.dataAccess.db.mysql.MySqlTickets.java
public void refillQueue() { QueryRunner q = db.newQuery();/*from ww w . j ava 2s .c om*/ //String sql = "insert into users (username) values (?)"; String sql = "REPLACE INTO stallion_tickets (ticket_name) VALUES('a')"; long nextId = 0; try { nextId = q.insert(sql, new ScalarHandler<Long>()); } catch (SQLException e) { throw new RuntimeException(e); } Log.fine("Next ticket id {0}", nextId); nextId = nextId * 1000; //ScalarHandler<Long> scalar = new ScalarHandler<Long>(); //Long nextId = q.query("SELECT nextval('stallion_tickets_seq')", scalar); for (int x = 0; x < 1000; x++) { loadedIds.add(nextId + x); } }