public BigInteger calculateBalanceForAddress ( Address address ) throws BlockStoreException { maybeConnect ( ) ; PreparedStatement s = null ; try { s = conn . get ( ) . prepareStatement ( getBalanceSelectSQL ( ) ) ; s . setString ( 1 , address . toString ( ) ) ; ResultSet rs = s . executeQuery ( ) ; BigInteger balance = BigInteger . ZERO ; if ( rs . next ( ) ) { return BigInteger . valueOf ( rs . getLong ( 1 ) ) ; } return balance ; } catch ( SQLException ex ) { throw new BlockStoreException ( ex ) ; } finally { if ( s != null ) { try { s . close ( ) ; } catch ( SQLException e ) { throw new BlockStoreException ( "Could not close statement" ) ; } } } }
Calculate the balance for a coinbase to - address or p2sh address .