I had this situation reported to me with Informix over Payara (Glassfish).
Is there any cases where we could get a valid connection but DatabaseMetaData getURL could return null?
If you create an Informix JDBC connection from a DataSource, then from the driver's perspective there is no URL, and DatabaseMetaData.getURL()
will return null.
If you make a connection using DriverManager
and pass in a URL, then you should get that URL back from the metadata.
One could argue that the connection could 'build' a URL from the DataSource
to give back to you, but the Informix JDBC driver today does not do that.
Returning null
from DatabaseMetaData.getURL()
is allowed, as stated in the Javadoc:
Returns: the URL for this DBMS or
null
if it cannot be generated
The DatabaseMetaData.getURL()
method is primarily intended for informational purposes, so you shouldn't rely on its result in any way.
Probably the Informix driver has no way to obtain the original URL used for the connection and simply returns null
in its implementation of DatabaseMetaData.getURL()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.