#fixed code
                                @Test
    public void testDeleteRowFromTableWithImmutableIndex() throws SQLException {
        testDeleteRowFromTableWithImmutableIndex(false);
    }
#vulnerable code 
                                @Test
    public void testDeleteRowFromTableWithImmutableIndex() throws SQLException {
        Connection con = null;
        try {
            boolean autoCommit = false;
            con = DriverManager.getConnection(getUrl());
            con.setAutoCommit(autoCommit);

            Statement stm = con.createStatement();
            stm.execute("CREATE TABLE IF NOT EXISTS web_stats (" +
                    "HOST CHAR(2) NOT NULL," +
                    "DOMAIN VARCHAR NOT NULL, " +
                    "FEATURE VARCHAR NOT NULL, " +
                    "DATE DATE NOT NULL, \n" + 
                    "USAGE.CORE BIGINT," +
                    "USAGE.DB BIGINT," +
                    "STATS.ACTIVE_VISITOR INTEGER " +
                    "CONSTRAINT PK PRIMARY KEY (HOST, DOMAIN, FEATURE, DATE)) IMMUTABLE_ROWS=true");
            stm.execute("CREATE INDEX web_stats_idx ON web_stats (DATE, FEATURE)");
            stm.close();

            Date date = new Date(0);
            PreparedStatement psInsert = con
                    .prepareStatement("UPSERT INTO web_stats(HOST, DOMAIN, FEATURE, DATE, CORE, DB, ACTIVE_VISITOR) VALUES(?,?, ? , ?, ?, ?, ?)");
            psInsert.setString(1, "AA");
            psInsert.setString(2, "BB");
            psInsert.setString(3, "CC");
            psInsert.setDate(4, date);
            psInsert.setLong(5, 1L);
            psInsert.setLong(6, 2L);
            psInsert.setLong(7, 3);
            psInsert.execute();
            psInsert.close();
            if (!autoCommit) {
                con.commit();
            }
            
            psInsert = con.prepareStatement("DELETE FROM web_stats WHERE (HOST, DOMAIN, FEATURE, DATE) = (?,?,?,?)");
            psInsert.setString(1, "AA");
            psInsert.setString(2, "BB");
            psInsert.setString(3, "CC");
            psInsert.setDate(4, date);
            psInsert.execute();
            if (!autoCommit) {
                con.commit();
            }
            
            ResultSet rs = con.createStatement().executeQuery("SELECT /*+ NO_INDEX */ count(*) FROM web_stats");
            assertTrue(rs.next());
            assertEquals(0, rs.getLong(1));

            rs = con.createStatement().executeQuery("SELECT count(*) FROM web_stats_idx");
            assertTrue(rs.next());
            assertEquals(0, rs.getLong(1));

        } finally {
            try {
                con.close();
            } catch (Exception ex) {
            }
        }
    } 
                            #location 58 
                            #vulnerability type NULL_DEREFERENCE