Methods Summary |
---|
public void | close()Closes the logical connection.
Cleans up client specific details
if (isClosed) {
if(_logger.isLoggable(Level.FINE)){
_logger.log(Level.FINE,"jdbc.duplicate_close_connection",this);
}
return;
}
if (!jdbc30Connection) {
try {
checkValidity();
if (defaultClientInfo == null) {
setClientInfo(new Properties());
} else {
setClientInfo(defaultClientInfo);
}
} catch (SQLClientInfoException e) {
_logger.log(Level.WARNING, "jdbc.unable_to_set_client_info", e);
}
}
super.close();
|
public java.sql.Array | createArrayOf(java.lang.String typeName, java.lang.Object[] elements)Factory method for creating Array objects.
checkValidity();
jdbcPreInvoke();
return con.createArrayOf(typeName, elements);
|
public java.sql.Blob | createBlob()Constructs an object that implements the Blob interface. The object
returned initially contains no data. The setBinaryStream and
setBytes methods of the Blob interface may be used to add data to
the Blob .
checkValidity();
jdbcPreInvoke();
return con.createBlob();
|
public java.sql.Clob | createClob()Constructs an object that implements the Clob interface. The object
returned initially contains no data. The setAsciiStream ,
setCharacterStream and setString methods of
the Clob interface may be used to add data to the Clob .
checkValidity();
jdbcPreInvoke();
return con.createClob();
|
public java.sql.NClob | createNClob()Constructs an object that implements the NClob interface. The object
returned initially contains no data. The setAsciiStream ,
setCharacterStream and setString methods of the NClob interface may
be used to add data to the NClob .
checkValidity();
jdbcPreInvoke();
return con.createNClob();
|
public java.sql.SQLXML | createSQLXML()Constructs an object that implements the SQLXML interface. The object
returned initially contains no data. The createXmlStreamWriter object and
setString method of the SQLXML interface may be used to add data to the SQLXML
object.
checkValidity();
jdbcPreInvoke();
return con.createSQLXML();
|
public java.sql.Struct | createStruct(java.lang.String typeName, java.lang.Object[] attributes)Factory method for creating Struct objects.
checkValidity();
jdbcPreInvoke();
return con.createStruct(typeName, attributes);
|
public java.lang.String | getClientInfo(java.lang.String name)Returns the value of the client info property specified by name. This
method may return null if the specified client info property has not
been set and does not have a default value. This method will also
return null if the specified client info property name is not supported
by the driver.
Applications may use the DatabaseMetaData.getClientInfoProperties
method to determine the client info properties supported by the driver.
checkValidity();
return con.getClientInfo(name);
|
public java.util.Properties | getClientInfo()Returns a list containing the name and current value of each client info
property supported by the driver. The value of a client info property
may be null if the property has not been set and does not have a
default value.
checkValidity();
return con.getClientInfo();
|
private T | getProxyObject(java.lang.Object actualObject, java.lang.Class[] ifaces)
T result ;
InvocationHandler ih;
try {
ih = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws SQLException,
IllegalAccessException, InvocationTargetException {
// When close() is called on proxy object, call close() on resource adapter's
// Connection Holder instead of physical connection.
if (method.getName().equals("close")
&& method.getParameterTypes().length == 0) {
String msg = localStrings.getString("jdbc.close_called_on_proxy_object", actualObject);
_logger.log(Level.FINE, msg);
ConnectionHolder40.this.close();
return null;
}
// default
return method.invoke(actualObject, args);
}
};
} catch (Exception e) {
throw new SQLException(e.fillInStackTrace());
}
result = (T) Proxy.newProxyInstance(actualObject.getClass().getClassLoader(), ifaces, ih);
return result;
|
protected void | init()cache the default client info which can will set back during close()
as this connection may be re-used by connection pool of application server
try {
defaultClientInfo = getClientInfo();
} catch (SQLException e) {
_logger.log(Level.WARNING, "jdbc.unable_to_get_client_info", e);
}
|
public boolean | isValid(int timeout)Returns true if the connection has not been closed and is still valid.
The driver shall submit a query on the connection or use some other
mechanism that positively verifies the connection is still valid when
this method is called.
The query submitted by the driver to validate the connection shall be
executed in the context of the current transaction.
checkValidity();
return con.isValid(timeout);
|
public boolean | isWrapperFor(java.lang.Class iface)Returns true if this either implements the interface argument or is directly or indirectly a wrapper
for an object that does. Returns false otherwise. If this implements the interface then return true,
else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped
object. If this does not implement the interface and is not a wrapper, return false.
This method should be implemented as a low-cost operation compared to unwrap so that
callers can use this method to avoid expensive unwrap calls that may fail. If this method
returns true then calling unwrap with the same argument should succeed.
checkValidity();
boolean result ;
if (iface.isInstance(this)) {
result = true;
}else{
result = con.isWrapperFor(iface);
}
return result;
|
public void | setClientInfo(java.lang.String name, java.lang.String value)Sets the value of the client info property specified by name to the
value specified by value.
Applications may use the DatabaseMetaData.getClientInfoProperties
method to determine the client info properties supported by the driver
and the maximum length that may be specified for each property.
The driver stores the value specified in a suitable location in the
database. For example in a special register, session parameter, or
system table column. For efficiency the driver may defer setting the
value in the database until the next time a statement is executed or
prepared. Other than storing the client information in the appropriate
place in the database, these methods shall not alter the behavior of
the connection in anyway. The values supplied to these methods are
used for accounting, diagnostics and debugging purposes only.
The driver shall generate a warning if the client info name specified
is not recognized by the driver.
If the value specified to this method is greater than the maximum
length for the property the driver may either truncate the value and
generate a warning or generate a SQLClientInfoException . If the driver
generates a SQLClientInfoException , the value specified was not set on the
connection.
The following are standard client info properties. Drivers are not
required to support these properties however if the driver supports a
client info property that can be described by one of the standard
properties, the standard property name should be used.
- ApplicationName - The name of the application currently utilizing
the connection
- ClientUser - The name of the user that the application using
the connection is performing work for. This may
not be the same as the user name that was used
in establishing the connection.
- ClientHostname - The hostname of the computer the application
using the connection is running on.
try {
checkValidity();
} catch (SQLException sqe) {
SQLClientInfoException sce = new SQLClientInfoException();
sce.setStackTrace(sqe.getStackTrace());
throw sce;
}
con.setClientInfo(name, value);
|
public void | setClientInfo(java.util.Properties properties)Sets the value of the connection's client info properties. The
Properties object contains the names and values of the client info
properties to be set. The set of client info properties contained in
the properties list replaces the current set of client info properties
on the connection. If a property that is currently set on the
connection is not present in the properties list, that property is
cleared. Specifying an empty properties list will clear all of the
properties on the connection. See setClientInfo (String, String) for
more information.
If an error occurs in setting any of the client info properties, a
SQLClientInfoException is thrown. The SQLClientInfoException
contains information indicating which client info properties were not set.
The state of the client information is unknown because
some databases do not allow multiple client info properties to be set
atomically. For those databases, one or more properties may have been
set before the error occurred.
try {
checkValidity();
} catch (SQLException sqe) {
SQLClientInfoException sce = new SQLClientInfoException();
sce.setStackTrace(sqe.getStackTrace());
throw sce;
}
con.setClientInfo(properties);
|
public T | unwrap(java.lang.Class iface)Returns an object that implements the given interface to allow access to
non-standard methods, or standard methods not exposed by the proxy.
If the receiver implements the interface then the result is the receiver
or a proxy for the receiver. If the receiver is a wrapper
and the wrapped object implements the interface then the result is the
wrapped object or a proxy for the wrapped object. Otherwise return the
the result of calling unwrap recursively on the wrapped object
or a proxy for that result. If the receiver is not a
wrapper and does not implement the interface, then an SQLException is thrown.
checkValidity();
T result = null;
if (iface.isInstance(this)) { //if iface is "java.sql.Connection"
result = iface.cast(this);
} else if (iface.isInstance(con)) {
//if iface is not "java.sql.Connection" & implemented by native Connection
Class<T> listIntf[] = new Class[]{iface};
result = getProxyObject(con, listIntf);
} else {
//probably a proxy, delegating to native connection
result = con.unwrap(iface);
if(Connection.class.isInstance(result)){
// rare case : returned object implements both iface & java.sql.Connection
Class<T> listIntf[] = new Class[]{iface, Connection.class};
result = getProxyObject(result, listIntf);
}
}
return result;
|