private void createPreparedStatement ( final String name , final String query , final int timeout , final boolean recovering ) throws NameAlreadyExistsException , DatabaseEngineException { if ( ! recovering ) { if ( stmts . containsKey ( name ) ) { throw new NameAlreadyExistsException ( String . format ( "There's already a PreparedStatement with the name '%s'" , name ) ) ; } try { getConnection ( ) ; } catch ( final Exception e ) { throw new DatabaseEngineException ( "Could not create prepared statement" , e ) ; } } PreparedStatement ps ; try { ps = conn . prepareStatement ( query ) ; if ( timeout > 0 ) { ps . setQueryTimeout ( timeout ) ; } stmts . put ( name , new PreparedStatementCapsule ( query , ps , timeout ) ) ; } catch ( final SQLException e ) { throw new DatabaseEngineException ( "Could not create prepared statement" , e ) ; } }
Creates a prepared statement .