Where can I find a good (maybe official) source (list) of non-db specific properties (keys)?
Properties props = new Properties(); props.put(key, value); props.put(key, value); props.put(key, value); props.put(key, value); props.put(key, value); props.put(key, value); connection = DriverManager.getConnection(path, props);
Advertisement
Answer
See the DriverManager.getConnection(String url, Properties info)
Javadoc:
info
– a list of arbitrary string tag/value pairs as connection arguments; normally at least a “user” and “password” property should be included
Other than that, neither the Java API documentation nor the JDBC 4.3 Specification make any mention of properties that must be supported for DriverManager.getConnection
.
Section 9.6.1 does specify a number of properties for javax.sql.DataSource
objects, but of those, only "roleName"
, "user"
and "password"
make sense for DriverManager.getConnection
.
In short, the list of non-db specific properties is "user"
and "password"
(established by the Javadoc), and maybe "roleName"
(though that requires inferring behaviour based on requirements for javax.sql.DataSource
). Everything else is driver-specific and you will need to check the documentation of the driver you’re using for the properties it supports.
In theory, you can discover properties through Driver.getPropertyInfo​(String url, Properties info)
. However, its behaviour is – in my opinion – not specified clearly, so support and behaviour varies by driver (some return all properties, some only the minimum set of properties required to connect).