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
.
+ *