Buggy code:
public abstract class EmbedConnection implements EngineConnection { private static final StandardException exceptionClose = StandardException . closeException ( ) ; public static final SQLException NO_MEM = Util . generateCsSQLException ( LOGIN_FAILED , "java.lang.OutOfMemoryError" ) ; public static final LowMemory memoryState = new LowMemory ( ) ; DatabaseMetaData dbMetadata ; TransactionResourceImpl tr ; private HashMap lobHashMap = null ; private int lobHMKey = 0 ; private boolean active ; boolean autoCommit = true ; boolean needCommit ; private boolean usingNoneAuth ; private int connectionHoldAbility = JDBC30Translation . HOLD_CURSORS_OVER_COMMIT ; final EmbedConnection rootConnection ; private SQLWarning topWarning ; private InternalDriver factory ; private Connection applicationConnection ; private int resultSetId ; private String connString ; public EmbedConnection ( InternalDriver driver , String url , Properties info ) throws SQLException { } private boolean createBoot ( Properties p ) throws SQLException { } private boolean isEncryptionBoot ( Properties p ) { } private boolean isHardUpgradeBoot ( Properties p ) { } private Properties removePhaseTwoProps ( Properties p ) { } public EmbedConnection ( EmbedConnection inputConnection ) { } private void checkUserCredentials ( String dbname , Properties userInfo ) throws SQLException { } private static final int OP_ENCRYPT = 0 ; private static final int OP_SHUTDOWN = 1 ; private static final int OP_HARD_UPGRADE = 2 ; private void checkIsDBOwner ( int operation ) throws SQLException { } public int getEngineType ( ) { } public final Statement createStatement ( ) throws SQLException { } public final Statement createStatement ( int resultSetType , int resultSetConcurrency ) throws SQLException { } public final Statement createStatement ( int resultSetType , int resultSetConcurrency , int resultSetHoldability ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql , int resultSetType , int resultSetConcurrency ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql , int resultSetType , int resultSetConcurrency , int resultSetHoldability ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql , int [ ] columnIndexes ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql , String [ ] columnNames ) throws SQLException { } public final PreparedStatement prepareStatement ( String sql , int autoGeneratedKeys ) throws SQLException { } private PreparedStatement prepareStatement ( String sql , int resultSetType , int resultSetConcurrency , int resultSetHoldability , int autoGeneratedKeys , int [ ] columnIndexes , String [ ] columnNames ) throws SQLException { } public final CallableStatement prepareCall ( String sql ) throws SQLException { } public final CallableStatement prepareCall ( String sql , int resultSetType , int resultSetConcurrency ) throws SQLException { } public final CallableStatement prepareCall ( String sql , int resultSetType , int resultSetConcurrency , int resultSetHoldability ) throws SQLException { } public String nativeSQL ( String sql ) throws SQLException { } public void setAutoCommit ( boolean autoCommit ) throws SQLException { } public boolean getAutoCommit ( ) throws SQLException { } public void commit ( ) throws SQLException { } public void rollback ( ) throws SQLException { } public void close ( ) throws SQLException { if ( ( ( ! ( isClosed ( ) ) ) && ( ( rootConnection ) == ( this ) ) ) && ( ( ! ( autoCommit ) ) && ( ! ( transactionIsIdle ( ) ) ) ) ) { <START_BUG> throw newSQLException ( LANG_INVALID_TRANSACTION_STATE ) ; <END_BUG> } close ( EmbedConnection . exceptionClose ) ; } private void close ( StandardException e ) throws SQLException { } public final boolean isClosed ( ) { } public DatabaseMetaData getMetaData ( ) throws SQLException { } public final int getHoldability ( ) throws SQLException { } public final void setHoldability ( int holdability ) throws SQLException { } public final void setReadOnly ( boolean readOnly ) throws SQLException { } public final boolean isReadOnly ( ) throws SQLException { } public void setCatalog ( String catalog ) throws SQLException { } public String getCatalog ( ) throws SQLException { } public void setTransactionIsolation ( int level ) throws SQLException { } public final int getTransactionIsolation ( ) throws SQLException { } public final synchronized SQLWarning getWarnings ( ) throws SQLException { } public final synchronized void clearWarnings ( ) throws SQLException { } public Map getTypeMap ( ) throws SQLException { } public final void setTypeMap ( Map map ) throws SQLException { } public final synchronized void addWarning ( SQLWarning newWarning ) { } public String getDBName ( ) { } public final LanguageConnectionContext getLanguageConnection ( ) { } protected final void checkIfClosed ( ) throws SQLException { } SQLException handleException ( Throwable thrownException ) throws SQLException { } final SQLException handleException ( Throwable thrownException , boolean rollbackOnAutoCommit ) throws SQLException { } public final void setInactive ( ) { } protected void finalize ( ) throws Throwable { } protected void needCommit ( ) { } protected void commitIfNeeded ( ) throws SQLException { } protected void commitIfAutoCommit ( ) throws SQLException { } protected final Object getConnectionSynchronization ( ) { } protected final void setupContextStack ( ) throws SQLException { } protected final void restoreContextStack ( ) throws SQLException { } private Database createDatabase ( String dbname , Properties info ) throws SQLException { } private boolean bootDatabase ( Properties info , boolean softAuthenticationBoot ) throws Throwable { } PreparedStatement prepareMetaDataStatement ( String sql ) throws SQLException { } public final InternalDriver getLocalDriver ( ) { } public final ContextManager getContextManager ( ) { } private Properties filterProperties ( Properties inputSet ) { } protected Database getDatabase ( ) { } protected final TransactionResourceImpl getTR ( ) { } private EmbedConnectionContext pushConnectionContext ( ContextManager cm ) { } public final void setApplicationConnection ( Connection applicationConnection ) { } public final Connection getApplicationConnection ( ) { } public void setDrdaID ( String drdaID ) { } public void resetFromPool ( ) throws SQLException { } public final int xa_prepare ( ) throws SQLException { }

Fix:
throw newSQLException ( CANNOT_CLOSE_ACTIVE_CONNECTION ) ;