Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 29397 invoked from network); 30 Aug 2005 15:14:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Aug 2005 15:14:01 -0000 Received: (qmail 68566 invoked by uid 500); 30 Aug 2005 15:14:00 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 68545 invoked by uid 500); 30 Aug 2005 15:14:00 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 68532 invoked by uid 99); 30 Aug 2005 15:13:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2005 08:13:59 -0700 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_60_70,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.134.35.149] (HELO smtp08.wanadoo.nl) (194.134.35.149) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2005 08:14:14 -0700 Received: from DB35TT0J (c53755738.cable.wanadoo.nl [83.117.87.56]) by smtp8.wanadoo.nl (Postfix) with SMTP id 77BCD53D5B for ; Tue, 30 Aug 2005 17:13:55 +0200 (CEST) Message-ID: <002101c5ad75$713a1d20$38577553@DB35TT0J> From: "Piet Blok" To: "Derby Discussion" References: <000601c5aaf0$63a86360$38577553@DB35TT0J> Subject: Re: Client driver fails to provide all DriverPropertyInfo's Date: Tue, 30 Aug 2005 17:13:56 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_001E_01C5AD86.349CC780" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_001E_01C5AD86.349CC780 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Jira issue DERBY-546 created. Piet Blok----- Original Message -----=20 From: Piet Blok=20 To: Derby Discussion=20 Sent: Saturday, August 27, 2005 12:16 PM Subject: Client driver fails to provide all DriverPropertyInfo's Hi, The Client Driver, in contrast to Embedded Driver, fails to report all = DriverPropertyInfo's. It seems that it not only ignores the Properties = object (see Jira DERBY_530), but it also ignores connection attributes = appended to the connection url. If no one objects I will create a Jira issue. See below a piece of code that demonstrates this behaviour: Piet Blok import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.DriverPropertyInfo; import java.sql.SQLException; import java.util.Enumeration; import java.util.Properties; import org.apache.derby.jdbc.ClientDriver; import org.apache.derby.jdbc.EmbeddedDriver; public class DerbyConnector { private static final String DERBY_CONNECTION_PREFIX =3D = "jdbc:derby:"; private static final String MY_DATABASE =3D "MyDatabase"; private static final String MY_HOST =3D "//127.0.0.1:1527/"; static { new ClientDriver(); new EmbeddedDriver(); } public static void main(String[] args) { DerbyConnector connector =3D new DerbyConnector(); try { Properties connectionProperties =3D new Properties(); connectionProperties.setProperty("create", "true"); connectionProperties.setProperty("dataEncryption", = "true"); connector.printInfo(MY_HOST + MY_DATABASE, = connectionProperties); connector.printInfo(MY_DATABASE, connectionProperties); } catch (SQLException e) { e.printStackTrace(); } } public Connection connect(String url) throws SQLException { return DriverManager.getConnection(DERBY_CONNECTION_PREFIX + = url); } public Connection connect(String url, Properties = connectionProperties) throws SQLException { return connect(DERBY_CONNECTION_PREFIX + url + connectionPropertiesString(connectionProperties)); } public DriverPropertyInfo[] getPropertyInfos(String url, = Properties props) throws SQLException { String connectionString =3D DERBY_CONNECTION_PREFIX + url + connectionPropertiesString(props); System.out.println("ConnectionString =3D " + = connectionString); Driver driver =3D DriverManager.getDriver(connectionString); return driver.getPropertyInfo(connectionString, props); } private String connectionPropertiesString(Properties = connectionProperties) { StringBuffer sb =3D new StringBuffer(); for (Enumeration enumeration =3D = connectionProperties.propertyNames(); enumeration .hasMoreElements();) { String key =3D (String) enumeration.nextElement(); sb.append(';'); sb.append(key); sb.append('=3D'); sb.append(connectionProperties.getProperty(key)); } return sb.toString(); } =20 private void printInfo(String url, Properties = connectionProperties) throws SQLException { System.out.println("=3D=3D=3D=3D=3D=3D=3D=3D=3D " + url + " = =3D=3D=3D=3D=3D=3D=3D=3D=3D"); DriverPropertyInfo[] infos =3D getPropertyInfos(url, = connectionProperties); for (int i =3D 0; i < infos.length; i++) { System.out.println("DriverPropertyInfo " + i); System.out.println(" description: " + = infos[i].description); System.out.println(" " + infos[i].name + " =3D " + = infos[i].value); System.out.println(" required =3D " + infos[i].required); if (infos[i].choices !=3D null) { for (int j =3D 0; j < infos[i].choices.length; j++) { System.out.println(" choice " + j + ": " + infos[i].choices[j]); } } } } } ------=_NextPart_000_001E_01C5AD86.349CC780 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Jira issue DERBY-546 = created.
 
Piet Blok----- Original Message -----
From:=20 Piet = Blok=20
Sent: Saturday, August 27, 2005 = 12:16=20 PM
Subject: Client driver fails to = provide=20 all DriverPropertyInfo's

Hi,
 
The Client Driver, in contrast to = Embedded=20 Driver, fails to report all DriverPropertyInfo's. It seems that it not = only=20 ignores the Properties object (see Jira DERBY_530), but it also = ignores=20 connection attributes appended to the connection url.
 
If no one objects I will create a = Jira=20 issue.
 
See below a piece of code that = demonstrates this=20 behaviour:
 
Piet Blok
 
 
 
import java.sql.Connection;
import java.sql.Driver;
import=20 java.sql.DriverManager;
import = java.sql.DriverPropertyInfo;
import=20 java.sql.SQLException;
import java.util.Enumeration;
import=20 java.util.Properties;
 
import org.apache.derby.jdbc.ClientDriver;
import=20 org.apache.derby.jdbc.EmbeddedDriver;
 
public class DerbyConnector {
 
    private static final String = DERBY_CONNECTION_PREFIX =3D=20 "jdbc:derby:";
 
    private static final String MY_DATABASE =3D=20 "MyDatabase";
 
    private static final String MY_HOST =3D=20 "//127.0.0.1:1527/";
 
    static = {
       =20 new ClientDriver();
        new=20 EmbeddedDriver();
    }
 
    public static void main(String[] args)=20 {
        DerbyConnector = connector =3D new=20 DerbyConnector();
        try=20 = {
           =20 Properties connectionProperties =3D new=20 = Properties();
         &n= bsp; =20 connectionProperties.setProperty("create",=20 = "true");
          &= nbsp;=20 connectionProperties.setProperty("dataEncryption",=20 = "true");
          &= nbsp;=20 connector.printInfo(MY_HOST + MY_DATABASE,=20 = connectionProperties);
        = ;   =20 connector.printInfo(MY_DATABASE,=20 connectionProperties);
        } = catch=20 (SQLException e)=20 = {
           =20 e.printStackTrace();
       =20 }
    }
 
    public Connection connect(String url) throws=20 SQLException {
        return=20 DriverManager.getConnection(DERBY_CONNECTION_PREFIX +=20 url);
    }
 
    public Connection connect(String url, = Properties=20 = connectionProperties)
        =    =20 throws SQLException {
        = return=20 connect(DERBY_CONNECTION_PREFIX +=20 = url
           =     =20 + = connectionPropertiesString(connectionProperties));
    = }
 
    public DriverPropertyInfo[] = getPropertyInfos(String=20 url, Properties=20 = props)
          &nb= sp;=20 throws SQLException {
        = String=20 connectionString =3D DERBY_CONNECTION_PREFIX +=20 = url
           =     =20 +=20 = connectionPropertiesString(props);
      = ; =20 System.out.println("ConnectionString =3D " +=20 connectionString);
        = Driver driver=20 =3D=20 = DriverManager.getDriver(connectionString);
    &nb= sp;  =20 return driver.getPropertyInfo(connectionString, = props);
   =20 }
 
    private String = connectionPropertiesString(Properties=20 connectionProperties) {
       =20 StringBuffer sb =3D new=20 StringBuffer();
        for = (Enumeration=20 enumeration =3D connectionProperties.propertyNames();=20 = enumeration
         &nbs= p;     =20 .hasMoreElements();)=20 = {
            = String=20 key =3D (String)=20 = enumeration.nextElement();
       &= nbsp;   =20 = sb.append(';');
         =   =20 = sb.append(key);
         =   =20 = sb.append('=3D');
        &nbs= p;  =20 = sb.append(connectionProperties.getProperty(key));
   &n= bsp;   =20 }
        return = sb.toString();
 
    }
   
    = private=20 void printInfo(String url, Properties=20 = connectionProperties)
        =    =20 throws SQLException {
       =20 System.out.println("=3D=3D=3D=3D=3D=3D=3D=3D=3D " + url + "=20 = =3D=3D=3D=3D=3D=3D=3D=3D=3D");
      &nb= sp;=20 DriverPropertyInfo[] infos =3D getPropertyInfos(url,=20 connectionProperties);
        = for (int=20 i =3D 0; i < infos.length; i++)=20 = {
           =20 System.out.println("DriverPropertyInfo " +=20 = i);
           = =20 System.out.println("  description: " +=20 = infos[i].description);
        = ;   =20 System.out.println("  " + infos[i].name + " =3D " +=20 = infos[i].value);
         = ;  =20 System.out.println("  required =3D " +=20 = infos[i].required);
        &n= bsp;  =20 if (infos[i].choices !=3D null)=20 = {
           &n= bsp;   =20 for (int j =3D 0; j < infos[i].choices.length; j++)=20 = {
           &n= bsp;       =20 System.out.println("    choice " + j + ":=20 = "
           &n= bsp;           &nb= sp;   =20 +=20 = infos[i].choices[j]);
        =        =20 = }
           =20 }
        = }
   =20 }
 
}
 
------=_NextPart_000_001E_01C5AD86.349CC780--