Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
10.1.1.0
-
None
-
Windows XP professional, JRE 1.5.0_04
-
Normal
-
Newcomer
-
Embedded/Client difference
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
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
public DriverPropertyInfo[] getPropertyInfos(String url, Properties props)
throws SQLException
private String connectionPropertiesString(Properties connectionProperties) {
StringBuffer sb = new StringBuffer();
for (Enumeration enumeration = connectionProperties.propertyNames(); enumeration
.hasMoreElements()
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++)
}
}
}
}