Buggy code:
public static final String clientDbURL = new String ( ( ( ( NsTest . clientURL ) + ( NsTest . dbName ) ) + ";create=true" ) ) ; public static final String retrieveMessagePart = "retrieveMessagesFromServerOnGetMessage=true;" ; public static final String embedDbURL = new String ( ( ( ( NsTest . embedURL ) + ( NsTest . dbName ) ) + ";create=true" ) ) ; public static boolean embeddedMode = false ; public static final String driver = new String ( "org.apache.derby.jdbc.ClientDriver" ) ; public static final String embedDriver = new String ( "org.apache.derby.jdbc.EmbeddedDriver" ) ; public static Properties prop = new Properties ( ) ; public static int INIT = 0 ; public static int TESTER1 = 1 ; public static int TESTER2 = 2 ; public static int TESTER3 = 3 ; public static int BACKUP = 4 ; public static String BACKUPDIR = "backupdir" ; public static String RESTOREDIR = "restoredir" ; public static boolean START_SERVER_IN_SAME_VM = false ; public static boolean AUTO_COMMIT_OFF = false ; public static boolean CREATE_DATABASE_ONLY = false ; public static boolean schemaCreated = false ; public static int INIT_THREADS = 6 ; public static int MAX_INITIAL_ROWS = 6000 ; public static int MAX_ITERATIONS = 2000 ; public static int MAX_LOW_STRESS_ROWS = 30 ; public static int MAX_OPERATIONS_PER_CONN = 25 ; public static int NUMTESTER1 = 15 ; public static int NUMTESTER2 = 45 ; public static int NUMTESTER3 = 10 ; public static int NUM_HIGH_STRESS_ROWS = 25000 ; public static int NUM_UNTOUCHED_ROWS = 6000 ; public static int numInserts = 0 ; public static int numUpdates = 0 ; public static int numDeletes = 0 ; public static int numSelects = 0 ; public static int numFailedInserts = 0 ; public static int numFailedUpdates = 0 ; public static int numFailedDeletes = 0 ; public static int numFailedSelects = 0 ; public static int numConnections = 0 ; public static int INSERT = 0 ; public static int UPDATE = 1 ; public static int DELETE = 2 ; public static int SELECT = 3 ; public static int FAILED_INSERT = 4 ; public static int FAILED_UPDATE = 5 ; public static int FAILED_DELETE = 6 ; public static int FAILED_SELECT = 7 ; public static int CONNECTIONS_MADE = 8 ; public static final String SUCCESS = "<seq2seq4repair_space>***<seq2seq4repair_space>SUCCESS<seq2seq4repair_space>***<seq2seq4repair_space>" ; public static String driver_type = null ; private int type ; public static synchronized void addStats ( int type , int addValue ) { } NsTest ( int ttype , int k ) throws Exception { } public static void main ( String [ ] args ) throws IOException , Exception , InterruptedException , Throwable , SQLException { Connection conn = null ; if ( ( args . length ) == 1 ) { NsTest . driver_type = args [ 0 ] ; if ( ! ( ( NsTest . driver_type . equalsIgnoreCase ( "DerbyClient" ) ) || ( NsTest . driver_type . equalsIgnoreCase ( "Embedded" ) ) ) ) { NsTest . printUsage ( ) ; return ; } System . out . println ( ( "Test<seq2seq4repair_space>nstest<seq2seq4repair_space>starting.....,<seq2seq4repair_space>using<seq2seq4repair_space>driver:<seq2seq4repair_space>" + ( NsTest . driver_type ) ) ) ; } else { NsTest . driver_type = "DerbyClient" ; } String jdbcUrl = "" ; try { if ( NsTest . driver_type . equalsIgnoreCase ( "Embedded" ) ) { System . out . println ( "Loading<seq2seq4repair_space>the<seq2seq4repair_space>embedded<seq2seq4repair_space>driver..." ) ; Class . forName ( NsTest . embedDriver ) . newInstance ( ) ; jdbcUrl = ( ( ( ( NsTest . embedDbURL ) + ";" ) + ( NsTest . dataEncypt ) ) + ";" ) + ( NsTest . bootPwd ) ; NsTest . embeddedMode = true ; } else { System . out . println ( ( "Driver<seq2seq4repair_space>type<seq2seq4repair_space>:<seq2seq4repair_space>" + ( NsTest . driver_type ) ) ) ; System . out . println ( ( "Loading<seq2seq4repair_space>the<seq2seq4repair_space>Derby<seq2seq4repair_space>Client<seq2seq4repair_space>driver..." + ( NsTest . driver ) ) ) ; Class . forName ( NsTest . driver ) . newInstance ( ) ; System . out . println ( "Client<seq2seq4repair_space>Driver<seq2seq4repair_space>loaded" ) ; jdbcUrl = ( ( ( ( NsTest . clientDbURL ) + ";" ) + ( NsTest . dataEncypt ) ) + ";" ) + ( NsTest . bootPwd ) ; } if ( ( ! ( NsTest . embeddedMode ) ) && ( NsTest . START_SERVER_IN_SAME_VM ) ) { NsTest . startNetworkServer ( ) ; } NsTest . prop . setProperty ( "user" , NsTest . user ) ; NsTest . prop . setProperty ( "password" , NsTest . password ) ; System . out . println ( ( "Getting<seq2seq4repair_space>a<seq2seq4repair_space>connection<seq2seq4repair_space>using<seq2seq4repair_space>the<seq2seq4repair_space>url:<seq2seq4repair_space>" + jdbcUrl ) ) ; System . out . println ( ( "JDBC<seq2seq4repair_space>url=<seq2seq4repair_space>" + jdbcUrl ) ) ; conn = DriverManager . getConnection ( jdbcUrl , NsTest . prop ) ; } catch ( SQLException sqe ) { System . out . println ( ( ( ( ( "\n\n<seq2seq4repair_space>" + sqe ) + ( sqe . getErrorCode ( ) ) ) + "<seq2seq4repair_space>" ) + ( sqe . getSQLState ( ) ) ) ) ; <START_BUG> if ( ( ( sqe . getErrorCode ( ) ) == ( - 4499 ) ) || ( sqe . getSQLState ( ) . equalsIgnoreCase ( "08001" ) ) ) { <END_BUG> System . out . println ( "\n<seq2seq4repair_space>Unable<seq2seq4repair_space>to<seq2seq4repair_space>connect,<seq2seq4repair_space>test<seq2seq4repair_space>cannot<seq2seq4repair_space>proceed.<seq2seq4repair_space>Please<seq2seq4repair_space>verify<seq2seq4repair_space>if<seq2seq4repair_space>the<seq2seq4repair_space>Network<seq2seq4repair_space>Server<seq2seq4repair_space>is<seq2seq4repair_space>started<seq2seq4repair_space>on<seq2seq4repair_space>port<seq2seq4repair_space>1900." ) ; return ; } } catch ( ClassNotFoundException cnfe ) { System . out . println ( ( "Driver<seq2seq4repair_space>not<seq2seq4repair_space>found:<seq2seq4repair_space>" + ( cnfe . getMessage ( ) ) ) ) ; cnfe . printStackTrace ( ) ; return ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . out . println ( "Unexpected<seq2seq4repair_space>Failure" ) ; NsTest . printException ( "nstest.main()<seq2seq4repair_space>method<seq2seq4repair_space>==><seq2seq4repair_space>" , e ) ; } if ( ( DbSetup . doIt ( conn ) ) == false ) { System . out . println ( "Error<seq2seq4repair_space>in<seq2seq4repair_space>dbSetup,<seq2seq4repair_space>test<seq2seq4repair_space>will<seq2seq4repair_space>exit" ) ; System . exit ( 1 ) ; } try { conn . close ( ) ; } catch ( Exception e ) { System . out . println ( "FAIL<seq2seq4repair_space>-<seq2seq4repair_space>Error<seq2seq4repair_space>closing<seq2seq4repair_space>the<seq2seq4repair_space>connection<seq2seq4repair_space>in<seq2seq4repair_space>nstest.main():" ) ; NsTest . printException ( "Closing<seq2seq4repair_space>connection<seq2seq4repair_space>in<seq2seq4repair_space>nstest.main()" , e ) ; } System . out . println ( "Starting<seq2seq4repair_space>memory<seq2seq4repair_space>checker<seq2seq4repair_space>thread" ) ; MemCheck mc = new MemCheck ( 200000 ) ; mc . start ( ) ;

Fix:
if ( ( ( sqe . getErrorCode ( ) ) == 40000 ) || ( sqe . getSQLState ( ) . equalsIgnoreCase ( "08001" ) ) ) {