public static < T > T queryScalar ( String poolName , String sql , Class < T > scalarType , Object [ ] params ) throws SQLStatementNotFoundException , YankSQLException { T returnObject = null ; try { ScalarHandler < T > resultSetHandler ; if ( scalarType . equals ( Integer . class ) ) { resultSetHandler = ( ScalarHandler < T > ) new IntegerScalarHandler ( ) ; } else if ( scalarType . equals ( Long . class ) ) { resultSetHandler = ( ScalarHandler < T > ) new LongScalarHandler ( ) ; } else if ( scalarType . equals ( Float . class ) ) { resultSetHandler = ( ScalarHandler < T > ) new FloatScalarHandler ( ) ; } else if ( scalarType . equals ( Double . class ) ) { resultSetHandler = ( ScalarHandler < T > ) new DoubleScalarHandler ( ) ; } else if ( scalarType . equals ( BigDecimal . class ) ) { resultSetHandler = ( ScalarHandler < T > ) new BigDecimalScalarHandler ( ) ; } else { resultSetHandler = new ScalarHandler < T > ( ) ; } returnObject = new QueryRunner ( YANK_POOL_MANAGER . getConnectionPool ( poolName ) ) . query ( sql , resultSetHandler , params ) ; } catch ( SQLException e ) { handleSQLException ( e , poolName , sql ) ; } return returnObject ; }
Return just one scalar given a an SQL statement