Simba JDBC 4.1 driver - question about number of columns in result


#1

Hello, I am trying out the Simba 4.1 JDBC driver. I had a question about my ResultSet. It seems that each time I run my N1QL query, I may get a different number of columns. I ran this test using Java 8 for my client, against a 1 node cluster running version 4.0.0-dp.

For example, here are two runs of the same program.

About to get connection to Couchbase…
About to create statement…
About to execute query…
executeQuery() took 3154 ms.
The result has 11 columns.
Found 7303 query results.
Goodbye.

And a different run…

About to get connection to Couchbase…
About to create statement…
About to execute query…
executeQuery() took 2961 ms.
The result has 9 columns.
Found 7303 query results.
Goodbye.

Here is my code,

    System.out.println("About to get connection to Couchbase...");

    conn = DriverManager.getConnection("jdbc:couchbase://hostname:8093/default;queryEnabled=1",
                   connectionProps);        

    System.out.println("About to create statement...");
    stmt = conn.createStatement();

    System.out.println("About to execute query...");

    t1 = System.currentTimeMillis();
    rs = stmt.executeQuery("select * from `beer-sample`;");
    t2 = System.currentTimeMillis();

    System.out.println("executeQuery() took " + ( t2 - t1 ) + " ms.");
    
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    System.out.println("The result has " + numberOfColumns + " columns.");
    
    int resultsFound = 0;
    
    while (rs.next()) {
            resultsFound++;
    }
        
    System.out.println("Found " + resultsFound + " query results." );
    
    }
    catch (Exception e) {
        System.out.println("Caught exception: " + e);
    }

    System.out.println("Goodbye." );

#2

We checked with Simba (the creators of this JDBC driver) - here is their answer:
“We cannot reproduce the issue with default beer-sample table with our Developer Preview Update 5. The row order should be random, but the column number should be remain the same. I am not sure the exact version that the customer is using, but the latest build should solve the problem.”

The latest refreshed build can be downloaded from
https://simba.box.com/couchbasedeveloperpreview

Please uninstall the older build, and try this and let us know.


#3

Thank you. I downloaded SimbaCouchbaseJDBC41_DeveloperPreview_update5.zip from your link above and unzipped it. I found that there is a CouchbaseJDBC4.jar where previously there was a CouchbaseJDBC41.jar. I was able to compile and run my program with the new jars and I did get a different result which is consistent over time.

About to get connection to Couchbase…
About to create statement…
About to execute query…
executeQuery() took 5378 ms.
The result has 12 columns.
Found 7303 query results.
Goodbye.

Thank you!