public Object querySingleObject ( Collection queryParams , String sqlquery ) throws Exception { Debug . logVerbose ( "[JdonFramework]--> enter getSingleObject " , module ) ; Connection c = null ; PreparedStatement ps = null ; ResultSet rs = null ; Object o = null ; try { c = dataSource . getConnection ( ) ; ps = c . prepareStatement ( sqlquery , ResultSet . TYPE_SCROLL_INSENSITIVE , ResultSet . CONCUR_READ_ONLY ) ; Debug . logVerbose ( sqlquery , module ) ; jdbcUtil . setQueryParams ( queryParams , ps ) ; rs = ps . executeQuery ( ) ; if ( rs . first ( ) ) { o = rs . getObject ( 1 ) ; Debug . logVerbose ( "[JdonFramework]-->in db found it:" + o . getClass ( ) . getName ( ) , module ) ; } } catch ( SQLException se ) { throw new SQLException ( "SQLException: " + se . getMessage ( ) ) ; } catch ( Exception ex ) { Debug . logError ( ex , module ) ; throw new Exception ( ex ) ; } finally { if ( rs != null ) try { rs . close ( ) ; } catch ( SQLException quiet ) { } if ( ps != null ) try { ps . close ( ) ; } catch ( SQLException quiet ) { } if ( c != null ) try { c . close ( ) ; } catch ( SQLException quiet ) { } } return o ; }
get a single object from database