Index: jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnection.java =================================================================== --- jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnection.java (revision 47843) +++ jdbc-ra/jdbc-core/src/main/java/com/sun/gjc/spi/ManagedConnection.java (working copy) @@ -63,6 +63,7 @@ import java.util.logging.Logger; import java.sql.PreparedStatement; import java.sql.CallableStatement; +import java.sql.DatabaseMetaData; import com.sun.gjc.spi.base.*; import com.sun.gjc.spi.base.CacheObjectKey; import com.sun.gjc.spi.base.datastructure.Cache; @@ -141,6 +142,9 @@ private boolean aborted = false; + private DatabaseMetaData cachedDatabaseMetaData = null; + private Boolean isSupportClientInfo = null; + /** * Constructor for ManagedConnection. The pooledConn parameter is expected * to be null and sqlConn parameter is the actual connection in case where @@ -915,6 +919,31 @@ public void setLastTransactionIsolationLevel(int isolationLevel) { lastTransactionIsolationLevel = isolationLevel; } + + /** + * Returns the cached DatabaseMetaData. + * + * @return DatabaseMetaData + */ + public DatabaseMetaData getCachedDatabaseMetaData() throws ResourceException { + if(cachedDatabaseMetaData == null){ + try { + cachedDatabaseMetaData = getActualConnection().getMetaData(); + } catch (SQLException sqle) { + throw new ResourceException(sqle.getMessage(), sqle); + } + } + return cachedDatabaseMetaData; + } + + public Boolean isSupportClientInfo() { + return isSupportClientInfo; + } + + public void setSupportClientInfo(Boolean isSupportClientInfo) { + this.isSupportClientInfo = isSupportClientInfo; + } + private void logFine(String logMessage){ if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, logMessage); Index: jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java =================================================================== --- jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java (revision 47843) +++ jdbc-ra/jdbc40/src/main/java/com/sun/gjc/spi/jdbc40/ConnectionHolder40.java (working copy) @@ -93,8 +93,10 @@ */ protected void init() { try { - defaultClientInfo = getClientInfo(); - } catch (SQLException e) { + if (isSupportClientInfo()) { + defaultClientInfo = getClientInfo(); + } + } catch (Throwable e) { _logger.log(Level.INFO, "jdbc.unable_to_get_client_info", e.getMessage()); if(_logger.isLoggable(Level.FINEST)) { _logger.log(Level.FINEST, "jdbc.unable_to_get_client_info", e); @@ -372,6 +374,41 @@ } /** + * Returns true if the client info properties are supported. + * The application server calls the getClientInfo method and the setClientInfo method + * only if the driver supports the client info properties. + * The DatabaseMetaData#getClientInfoProperties method is used to determine + * whether the driver supports the client info properties or not. + * Note that the DatabaseMetaData will be cached by ManagedConnection. + *

+ * + * @return true if the client info properties are supported, false otherwise + *

+ * @throws javax.resource.ResourceException if the access to connection is failed. + *

+ * @throws java.sql.SQLException if the database server returns an error when retrieving + * a list of the client info properties. + *

+ * @see java.sql.DatabaseMetaData#getClientInfoProperties + * @since 1.6 + */ + private boolean isSupportClientInfo() throws ResourceException, SQLException { + Boolean isSupportClientInfo = getManagedConnection().isSupportClientInfo(); + if (isSupportClientInfo != null) { + return isSupportClientInfo; + } else { + ResultSet rs = getManagedConnection().getCachedDatabaseMetaData().getClientInfoProperties(); + try { + isSupportClientInfo = rs.next(); + getManagedConnection().setSupportClientInfo(isSupportClientInfo); + return isSupportClientInfo; + } finally { + rs.close(); + } + } + } + + /** * Factory method for creating Array objects. * * @param typeName the SQL name of the type the elements of the array map to. The typeName is a @@ -526,12 +563,14 @@ if (!jdbc30Connection) { try { checkValidity(); - if (defaultClientInfo == null) { - setClientInfo(new Properties()); - } else { - setClientInfo(defaultClientInfo); + if (isSupportClientInfo()) { + if (defaultClientInfo == null) { + setClientInfo(new Properties()); + } else { + setClientInfo(defaultClientInfo); + } } - } catch (SQLClientInfoException e) { + } catch (Throwable e) { _logger.log(Level.INFO, "jdbc.unable_to_set_client_info", e.getMessage()); if(_logger.isLoggable(Level.FINEST)) { _logger.log(Level.FINEST, "jdbc.unable_to_set_client_info", e);