db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (DERBY-546) In contrast to EmbeddedDriver, ClientDriver fails to report all DriverPropertyInfo's
Date Mon, 05 Sep 2011 07:11:15 GMT

     [ https://issues.apache.org/jira/browse/DERBY-546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kristian Waagan updated DERBY-546:
----------------------------------

         Description: 
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.
 
See below a piece of code that demonstrates this behaviour:
 
 
 
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 = "jdbc:derby:";
 
    private static final String MY_DATABASE = "MyDatabase";
 
    private static final String MY_HOST = "//127.0.0.1:1527/";
 
    static {
        new ClientDriver();
        new EmbeddedDriver();
    }
 
    public static void main(String[] args) {
        DerbyConnector connector = new DerbyConnector();
        try {
            Properties connectionProperties = 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 = DERBY_CONNECTION_PREFIX + url
                + connectionPropertiesString(props);
        System.out.println("ConnectionString = " + connectionString);
        Driver driver = DriverManager.getDriver(connectionString);
        return driver.getPropertyInfo(connectionString, props);
    }
 
    private String connectionPropertiesString(Properties connectionProperties) {
        StringBuffer sb = new StringBuffer();
        for (Enumeration enumeration = connectionProperties.propertyNames(); enumeration
                .hasMoreElements();) {
            String key = (String) enumeration.nextElement();
            sb.append(';');
            sb.append(key);
            sb.append('=');
            sb.append(connectionProperties.getProperty(key));
        }
        return sb.toString();
 
    }
    
    private void printInfo(String url, Properties connectionProperties)
            throws SQLException {
        System.out.println("========= " + url + " =========");
        DriverPropertyInfo[] infos = getPropertyInfos(url, connectionProperties);
        for (int i = 0; i < infos.length; i++) {
            System.out.println("DriverPropertyInfo " + i);
            System.out.println("  description: " + infos[i].description);
            System.out.println("  " + infos[i].name + " = " + infos[i].value);
            System.out.println("  required = " + infos[i].required);
            if (infos[i].choices != null) {
                for (int j = 0; j < infos[i].choices.length; j++) {
                    System.out.println("    choice " + j + ": "
                            + infos[i].choices[j]);
                }
            }
        }
    }
 
}


  was:
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.
 
See below a piece of code that demonstrates this behaviour:
 
 
 
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 = "jdbc:derby:";
 
    private static final String MY_DATABASE = "MyDatabase";
 
    private static final String MY_HOST = "//127.0.0.1:1527/";
 
    static {
        new ClientDriver();
        new EmbeddedDriver();
    }
 
    public static void main(String[] args) {
        DerbyConnector connector = new DerbyConnector();
        try {
            Properties connectionProperties = 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 = DERBY_CONNECTION_PREFIX + url
                + connectionPropertiesString(props);
        System.out.println("ConnectionString = " + connectionString);
        Driver driver = DriverManager.getDriver(connectionString);
        return driver.getPropertyInfo(connectionString, props);
    }
 
    private String connectionPropertiesString(Properties connectionProperties) {
        StringBuffer sb = new StringBuffer();
        for (Enumeration enumeration = connectionProperties.propertyNames(); enumeration
                .hasMoreElements();) {
            String key = (String) enumeration.nextElement();
            sb.append(';');
            sb.append(key);
            sb.append('=');
            sb.append(connectionProperties.getProperty(key));
        }
        return sb.toString();
 
    }
    
    private void printInfo(String url, Properties connectionProperties)
            throws SQLException {
        System.out.println("========= " + url + " =========");
        DriverPropertyInfo[] infos = getPropertyInfos(url, connectionProperties);
        for (int i = 0; i < infos.length; i++) {
            System.out.println("DriverPropertyInfo " + i);
            System.out.println("  description: " + infos[i].description);
            System.out.println("  " + infos[i].name + " = " + infos[i].value);
            System.out.println("  required = " + infos[i].required);
            if (infos[i].choices != null) {
                for (int j = 0; j < infos[i].choices.length; j++) {
                    System.out.println("    choice " + j + ": "
                            + infos[i].choices[j]);
                }
            }
        }
    }
 
}


    Issue & fix info: [Newcomer]

Happened to look at the relevant code and found this issue. As far as I understand, there
are multiple things to address:
 a) Determine the expected/correct behavior of the Driver.getPropertyInfo method.
 b) Implement the method in the client driver
 c) Verify that all (relevant) attributes are accounted for
 d) Convert old-style test to JUnit

I'm marking this as a newcomer issue. The first thing to do would probably be to log separate
JIRAs for the various issues.
With some help from the community it could be a good exercise for someone wanting to get to
know Derby development better :)

> In contrast to EmbeddedDriver, ClientDriver fails to report all DriverPropertyInfo's
> ------------------------------------------------------------------------------------
>
>                 Key: DERBY-546
>                 URL: https://issues.apache.org/jira/browse/DERBY-546
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.1.1.0
>         Environment: Windows XP professional, JRE 1.5.0_04
>            Reporter: Piet Blok
>              Labels: derby_triage10_5_2
>
> 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.
>  
> See below a piece of code that demonstrates this behaviour:
>  
>  
>  
> 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 = "jdbc:derby:";
>  
>     private static final String MY_DATABASE = "MyDatabase";
>  
>     private static final String MY_HOST = "//127.0.0.1:1527/";
>  
>     static {
>         new ClientDriver();
>         new EmbeddedDriver();
>     }
>  
>     public static void main(String[] args) {
>         DerbyConnector connector = new DerbyConnector();
>         try {
>             Properties connectionProperties = 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 = DERBY_CONNECTION_PREFIX + url
>                 + connectionPropertiesString(props);
>         System.out.println("ConnectionString = " + connectionString);
>         Driver driver = DriverManager.getDriver(connectionString);
>         return driver.getPropertyInfo(connectionString, props);
>     }
>  
>     private String connectionPropertiesString(Properties connectionProperties) {
>         StringBuffer sb = new StringBuffer();
>         for (Enumeration enumeration = connectionProperties.propertyNames(); enumeration
>                 .hasMoreElements();) {
>             String key = (String) enumeration.nextElement();
>             sb.append(';');
>             sb.append(key);
>             sb.append('=');
>             sb.append(connectionProperties.getProperty(key));
>         }
>         return sb.toString();
>  
>     }
>     
>     private void printInfo(String url, Properties connectionProperties)
>             throws SQLException {
>         System.out.println("========= " + url + " =========");
>         DriverPropertyInfo[] infos = getPropertyInfos(url, connectionProperties);
>         for (int i = 0; i < infos.length; i++) {
>             System.out.println("DriverPropertyInfo " + i);
>             System.out.println("  description: " + infos[i].description);
>             System.out.println("  " + infos[i].name + " = " + infos[i].value);
>             System.out.println("  required = " + infos[i].required);
>             if (infos[i].choices != null) {
>                 for (int j = 0; j < infos[i].choices.length; j++) {
>                     System.out.println("    choice " + j + ": "
>                             + infos[i].choices[j]);
>                 }
>             }
>         }
>     }
>  
> }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message