PreparedStatement getPreparedStatement(String sql, String key,
            int rsType, int rsConcurrency) throws SQLException {
        PreparedStatement ps = null;

        if (threadedPsMap.get().containsKey(key)) {
            ps = threadedPsMap.get().get(key);
            ps = checkValidity(ps, key);
        }

        if (ps == null) { // not in map or ps is null in map
            ps = getConnection().prepareStatement(sql, rsType, rsConcurrency);
            threadedPsMap.get().put(key, ps);
            threadedPsTimeMap.get().put(key, currentTimeMillis());
        }

        return ps;
    }
PreparedStatement getPreparedStatement ( String sql , String key , int rsType , int rsConcurrency ) throws SQLException { PreparedStatement ps = null ; if ( threadedPsMap . get ( ) . containsKey ( key ) ) { ps = threadedPsMap . get ( ) . get ( key ) ; ps = checkValidity ( ps , key ) ; } if ( ps == null ) { ps = getConnection ( ) . prepareStatement ( sql , rsType , rsConcurrency ) ; threadedPsMap . get ( ) . put ( key , ps ) ; threadedPsTimeMap . get ( ) . put ( key , currentTimeMillis ( ) ) ; } return ps ; }
Retrieve a {@link PreparedStatement} by a reference key.

@param sql {@link String} SQL statement
@param key {@link String} key as a means of identifying the {@code sql}
parameter
@param rsType Result set type (i.e.,
{@link java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE},
{@link java.sql.ResultSet#TYPE_SCROLL_SENSITIVE}, or
{@link java.sql.ResultSet#TYPE_FORWARD_ONLY})
@param rsConcurrency Result set constants (i.e.,
{@link java.sql.ResultSet#CONCUR_READ_ONLY},
{@link java.sql.ResultSet#CONCUR_UPDATABLE})
@return {@link PreparedStatement}
@throws SQLException Thrown if a database access error occurs, the
connection is closed, or the given parameters are not {@code ResultSet}
constants