db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Satheesh Bandaram (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-142) ResultSetMetaData.isReadOnly() also returns wrong results
Date Wed, 12 Oct 2005 22:15:35 GMT
    [ http://issues.apache.org/jira/browse/DERBY-142?page=comments#action_12331930 ] 

Satheesh Bandaram commented on DERBY-142:
-----------------------------------------

Correcting the previous comment. The test was run on 8.1.5 DB2 server using bundled JCC driver.

It seems FOR UPDATE/FOR READ ONLY specification overwrites statement concurrency.

DerbyTest142 starting ...
Default resultSetType and default concurrancy
        Query: SELECT id, name FROM readonlytest
                ID column isReadOnly = true
                Name column isReadOnly = true
        Query: SELECT id, name FROM readonlytest FOR UPDATE
                ID column isReadOnly = false
                Name column isReadOnly = false
        Query: SELECT id, name FROM readonlytest FOR READ ONLY
                ID column isReadOnly = true
                Name column isReadOnly = true

Forward-only resultSetType and CONCUR_UPDATABLE
        Query: SELECT id, name FROM readonlytest
                ID column isReadOnly = false
                Name column isReadOnly = false
        Query: SELECT id, name FROM readonlytest FOR UPDATE
                ID column isReadOnly = false
                Name column isReadOnly = false
        Query: SELECT id, name FROM readonlytest FOR READ ONLY
                ID column isReadOnly = true
                Name column isReadOnly = true

Forward-only resultSetType and CONCUR_READONLY
        Query: SELECT id, name FROM readonlytest
                ID column isReadOnly = true
                Name column isReadOnly = true
        Query: SELECT id, name FROM readonlytest FOR UPDATE
                ID column isReadOnly = false
                Name column isReadOnly = false
        Query: SELECT id, name FROM readonlytest FOR READ ONLY
                ID column isReadOnly = true
                Name column isReadOnly = true

Here is the program:

public class DB2Test
{
    public String protocol = "jdbc:db2://localhost:50000/";

    public static void main(String[] args) throws Exception
    {
        System.out.println("DerbyTest142 starting ...");

        Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
        Connection conn = DriverManager.getConnection("jdbc:db2://localhost:50000/tdb",
                    "USER", "PASSWORD");

        System.out.println("Default resultSetType and default concurrancy");
        Statement s = conn.createStatement();
        printQueryInfo("SELECT id, name FROM readonlytest", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
        s.close();

        System.out.println("\nForward-only resultSetType and CONCUR_UPDATABLE");
        s = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
        printQueryInfo("SELECT id, name FROM readonlytest", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
        s.close();

        System.out.println("\nForward-only resultSetType and CONCUR_READONLY");
        s = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        printQueryInfo("SELECT id, name FROM readonlytest", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
        printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
        s.close();
        conn.close();
    }

    public static void printQueryInfo(String query, Statement s) throws SQLException
    {
        ResultSet rs = s.executeQuery(query);
        ResultSetMetaData metaData = rs.getMetaData();
        System.out.println("\tQuery: "+query);
        System.out.println("\t\tID column isReadOnly = " +metaData.isReadOnly(1));
        System.out.println("\t\tName column isReadOnly = " +metaData.isReadOnly(2));
        rs.close();
    }
}

> ResultSetMetaData.isReadOnly() also returns wrong results
> ---------------------------------------------------------
>
>          Key: DERBY-142
>          URL: http://issues.apache.org/jira/browse/DERBY-142
>      Project: Derby
>         Type: Sub-task
>   Components: JDBC
>     Versions: 10.0.2.1
>  Environment: Using DB2 universal driver with standalone derby server
>     Reporter: Thomas Fischer
>  Attachments: DerbyTest.java, DerbyTest142.java
>
> ResultSetMetaData.isReadOnly() always returns true, even when writing to the table is
possible.  
> The JDBC 2.0 spec says: "ResultSetMetaData.isReadOnly() : Indicates whether the designated
column is definitely not writable.", so the method should return false for a table.
> I will attach a testcase for this behaviour.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message