public Trace getTrace_v4(int xStart, int yStart, int sourceID, int threshold)
    {
        // a query to be created based on threshold:
        String query = "locking row for access SELECT " 
                        + X_COLUMN + "," + Y_COLUMN + "," + PROPERTY_VALUE_COLUMN
                        + " FROM " + DATABASE + "." + TRACE_TABLE;
        
        // build the combination of x and y values:
        String s = "(?";
        for (int i=1; i < threshold; i++){
            s += ",?";
        }
        s += ")";
        
        // complete the query:
        query += " WHERE " + X_COLUMN + " in " + s 
               + " and " + Y_COLUMN + " in " + s
               + " and " + SOURCE_ID_COLUMN + "=?"
               + " and " + PROPERTY_ID_COLUMN + "=" + AMPLITUDE_PROPERTY_ID + ";";
        
        // [TEST]:
        //System.out.println("query: \n" + query);
        
        // the returned Trace object:
        Trace trace = null;

        // ResultSet objects:
        ResultSet resultSet;

        try
        {
            // Creating a PreparedStatement object
            PreparedStatement pStatement = con.prepareStatement(query);
            
            try
            {
                // set parameters of the statement:
                // x values:
                for (int i=0; i < threshold; i++){
                    pStatement.setInt((i+1), (xStart+i));
                }
                // y values:
                for (int i=0; i < threshold; i++){
                    pStatement.setInt((threshold+i+1), (yStart+i));
                }
                // source id:
                pStatement.setInt((threshold*2+1), sourceID);
                
                // [TEST] measure execution time:
                long startTime = System.currentTimeMillis();

                // run the multiple query in one go:
                pStatement.execute();

                // [TEST] get end time and print:
                long endTime = System.currentTimeMillis(); 
                //FESVoSystem.out.println("Executed query in: " + (endTime - startTime) + " ms.");
                FESVoSystem.out.print((endTime - startTime) + " ");
                
                
                
                // get result set:
                resultSet = pStatement.getResultSet();

                // only interested in one trace if available, 
                // so no need to go throw all returned rows:
                // if no row is available, return null
                if (resultSet.next()){
                    int x = resultSet.getInt(1);
                    int y = resultSet.getInt(2);
                    byte [] samples = resultSet.getBytes(3);
                    trace = new Trace(x, y, sourceID);
                    trace.setSamples(samples);
                }//if

                        


            }//try

            finally
            {
                // Close the statement
                pStatement.close();
                //System.out.println("Statement object closed. \n");
            }//finally


        }//try

        catch(SQLException ex)
        {
            // A SQLException was generated.  Catch it and display
            // the error information.
            // Note that there could be multiple error objects chained
            // together.
            System.out.println();
            System.out.println("*** SQLException caught ***");

            while (ex != null)
            {
                System.out.println(" Error code: " + ex.getErrorCode());
                System.out.println(" SQL State: " + ex.getSQLState());
                System.out.println(" Message: " + ex.getMessage());
                ////ex.printStackTrace();
                System.out.println();
                ex = ex.getNextException();
            }

            throw new IllegalStateException ("Sample failed.") ;

        }//catch

        // return the retrieved samples as a byte array
        return trace;
    }//getTrace