db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piet Blok (JIRA)" <derby-...@db.apache.org>
Subject [jira] Created: (DERBY-1355) ClientDriver ResultSetMetaData.isAutoIncrement(column) always returns false
Date Sat, 27 May 2006 12:06:29 GMT
ClientDriver ResultSetMetaData.isAutoIncrement(column) always returns false
---------------------------------------------------------------------------

         Key: DERBY-1355
         URL: http://issues.apache.org/jira/browse/DERBY-1355
     Project: Derby
        Type: Bug

  Components: Network Client  
    Versions: 10.1.2.1    
 Environment: Windows XP
    Reporter: Piet Blok


With ClientDriver, resultSet.getMetaData().isAutoIncrement(column) always returns false. 

EmbeddedDriver correctly returns the true value (true or false)

The following code demonstrates the problem:
===================================================================================
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.derby.jdbc.ClientDriver;
import org.apache.derby.jdbc.EmbeddedDriver;

public class TestAutoIncrement {
    private static final String URL_EMBEDDED = "jdbc:derby:EmbeddedTestBase;";

    private static final String URL_CLIENT = "jdbc:derby://localhost:1527/ClientTestBase;";

    public TestAutoIncrement() {
        super();
    }

    public static void main(String[] args) throws SQLException {
        System.out.println(new ClientDriver().getClass().getName()
                + " registered");
        System.out.println(new EmbeddedDriver().getClass().getName()
                + " registered");
        new TestAutoIncrement().test();
    }

    private void test() throws SQLException {
        if (test(URL_EMBEDDED) != test(URL_CLIENT)) {
            System.out.println("Embedded and client driver behave differently for isAutoIncrement().");
        } else {
            System.out.println("Embedded and client driver behave the same for isAutoIncrement().");
        }
    }

    private boolean test(String url) throws SQLException {
        boolean ai = false;
        Connection connection = DriverManager.getConnection(url
                + "create=true;");
        Statement statement = connection.createStatement();
        statement
                .execute("CREATE TABLE TEST_TABEL ("
                        + "ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),"
                        + "VALUE INTEGER NOT NULL, PRIMARY KEY (ID))");
        statement.execute("INSERT INTO TEST_TABEL (VALUE) VALUES(1)");
        ResultSet resultSet = statement
                .executeQuery("SELECT * FROM TEST_TABEL");
        ResultSetMetaData meta = resultSet.getMetaData();
        ai = meta.isAutoIncrement(1);
        System.out.println("For " + url + " " + meta.getColumnName(1)
                + " isAutoIncrement: " + ai);
        connection.close();
        try {
            DriverManager.getConnection(url + "shutdown=true;");
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
        return ai;
    }

}
===================================================================================
The output I receive from the above program is:

org.apache.derby.jdbc.ClientDriver registered
org.apache.derby.jdbc.EmbeddedDriver registered
For jdbc:derby:EmbeddedTestBase; ID isAutoIncrement: true
Database 'EmbeddedTestBase' shutdown.
For jdbc:derby://localhost:1527/ClientTestBase; ID isAutoIncrement: false
DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 
'ClientTestBase' shutdown.
Embedded and client driver behave differently for isAutoIncrement().
===================================================================================
Ouput from sysinfo:

------------------ Java Information ------------------
Java Version:    1.5.0_06
Java Vendor:     Sun Microsystems Inc.
Java home:       C:\Program Files\Java\jre1.5.0_06
Java classpath: 
.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;C:\WINDOWS\java\classes;C:\WorkSpace\PB

3.0\bin;C:\WorkSpace\Filipe\bin;C:\Documents and Settings\Piet\My 
Documents\Resources\Jars\ImgrRdr130.jar;C:\Documents and Settings\Piet\My 
Documents\Resources\Jars\lucene-1.4.1.jar;C:\Documents and Settings\Piet\My 
Documents\Resources\Jars\Multivalent20040415.jar;C:\Workspace\Stick\bin;
OS name:         Windows XP
OS architecture: x86
OS version:      5.1
Java user name:  Piet
Java user home:  C:\Documents and Settings\Piet
Java user dir:   C:\StickFolder
java.specification.name: Java Platform API Specification
java.specification.version: 1.5
--------- Derby Information --------
JRE - JDBC: J2SE 5.0 - JDBC 3.0
[/org/apache/derby/info/DBMS.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/tools.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/net.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/dnc.properties] 10.1.2.1 - (330608)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale :  [Nederlands/Nederland [nl_NL]]
Found support for locale: [de_DE]
  version: 10.1.2.1 - (330608)
Found support for locale: [es]
  version: 10.1.2.1 - (330608)
Found support for locale: [fr]
  version: 10.1.2.1 - (330608)
Found support for locale: [it]
  version: 10.1.2.1 - (330608)
Found support for locale: [ja_JP]
  version: 10.1.2.1 - (330608)
Found support for locale: [ko_KR]
  version: 10.1.2.1 - (330608)
Found support for locale: [pt_BR]
  version: 10.1.2.1 - (330608)
Found support for locale: [zh_CN]
  version: 10.1.2.1 - (330608)
Found support for locale: [zh_TW]
  version: 10.1.2.1 - (330608)
------------------------------------------------------


-- 
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