com.jdbwc.core
Class WCConnection
java.lang.Object
com.jdbwc.core.WCConnectionTransaction
com.jdbwc.core.WCConnectionInfo
com.jdbwc.core.WCConnection
- All Implemented Interfaces:
- java.sql.Connection, java.sql.Wrapper
public class WCConnection
- extends WCConnectionInfo
- implements Connection
Extended JDBC-API implementation for java.sql.Connection
NOTES:
One of the major hurdles with communication across the internet is latency.
It causes otherwise predictable behaviour to become unpredicatable.
Ive found through using a combination of sql transactions and stored sql procedures
the latency issue can be gracefully handled.
The retry handler this class implements will also help with some latency issues but not all.
Transactions are one of the safest ways to ensure data doesnt go missing in transit
and cannot duplicate itself in the remote database.
Even better are Stored-Procedures with nested Transactions;
this reduces bandwidth and increases reliability significantly.
Banks rely heavily on Stored-Procedures as part of thier
overall security and reliability strategies.
Your applications logic should be capable of recovering from missing data
(EG: by resending or re-requesting without triggering duplications).
Ultimately it will depend on what data your application is handling and
how critical the successfull transmission for each portion of your code is
as to what strategy your java interface and SQL queries implement.
- Version:
- 2008-06-29, 2010-04-09
- Author:
- Tim Gall (Oz-DevWorX)
- See Also:
interface for extension method details.
Field Summary |
protected org.apache.commons.httpclient.HttpMethodRetryHandler |
myretryhandler
|
Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
Constructor Summary |
protected |
WCConnection()
For the delegate only.
See WCConnection(String, String, int, String, String, String, String, int, String)
for the actual Connection initialiser routine. |
protected |
WCConnection(java.lang.String fullJdbcUrl,
java.lang.String domain,
int port,
java.lang.String url,
java.lang.String user,
java.lang.String password,
java.lang.String jdbwcCredentials,
int dbType,
java.lang.String database)
Initialises a jdbc connection.
Connection can use any standard http port. |
Methods inherited from class com.jdbwc.core.WCConnectionInfo |
getCaseSensitivity, getDatabase, getDatabaseInfo, getDatabaseMajorVersion, getDatabaseMicroVersion, getDatabaseMinorVersion, getDatabaseProductName, getDatabaseProductVersion, getDbType, getDriverMajorVersion, getDriverMinorVersion, getDriverName, getDriverVersion, getMyTimeZone, getVersion, versionMeetsMinimum |
Methods inherited from class com.jdbwc.core.WCConnectionTransaction |
commit, getTransactionIsolation, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setSavepoint, setSavepoint, setTransactionIsolation, setTransConnection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.sql.Connection |
commit, getTransactionIsolation, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setSavepoint, setSavepoint, setTransactionIsolation |
myretryhandler
protected org.apache.commons.httpclient.HttpMethodRetryHandler myretryhandler
WCConnection
protected WCConnection()
- For the delegate only.
See WCConnection(String, String, int, String, String, String, String, int, String)
for the actual Connection initialiser routine.
WCConnection
protected WCConnection(java.lang.String fullJdbcUrl,
java.lang.String domain,
int port,
java.lang.String url,
java.lang.String user,
java.lang.String password,
java.lang.String jdbwcCredentials,
int dbType,
java.lang.String database)
throws java.sql.SQLException
- Initialises a jdbc connection.
Connection can use any standard http port. They are: 80 http, 443 https).
Custom ports are not supported in this release.
- Parameters:
fullJdbcUrl
- domain
- port
- url
- user
- password
- jdbwcCredentials
- dbType
- database
-
- Throws:
java.sql.SQLException
getConnection
protected WCConnection getConnection()
getScriptUrl
protected java.lang.String getScriptUrl()
getCredentials
public java.lang.String getCredentials()
- Description copied from interface:
Connection
- Get the database credentials required to gain access to the remote database server.
- Returns:
- A one way hash that includes this Connections database login details
as supplied when this Connection was created.
getUrl
public java.lang.String getUrl()
- Description copied from interface:
Connection
- Gets the remote URL this Connection is connected to.
- Returns:
- The URL this Connection instance is using.
getUser
public java.lang.String getUser()
getClient
public org.apache.commons.httpclient.HttpClient getClient()
- Returns:
- this HttpClient
getTimeOut
public int getTimeOut()
- Returns:
- get the current timeout in ms
setTimeOut
public void setTimeOut(int timeOut)
- Parameters:
timeOut
- the timeout period in ms
getSessLimit
public boolean getSessLimit()
- Returns:
- current Session limit
setSessLimit
public void setSessLimit(boolean sessLimit)
createStatement
public java.sql.Statement createStatement()
throws java.sql.SQLException
- Specified by:
createStatement
in interface java.sql.Connection
- Throws:
java.sql.SQLException
createStatement
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
- Specified by:
createStatement
in interface java.sql.Connection
- Throws:
java.sql.SQLException
createStatement
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
- Specified by:
createStatement
in interface java.sql.Connection
- Throws:
java.sql.SQLException
clearWarnings
public void clearWarnings()
throws java.sql.SQLException
- Specified by:
clearWarnings
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.clearWarnings()
close
public void close()
throws java.sql.SQLException
- Specified by:
close
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.close()
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName,
java.lang.Object[] elements)
throws java.sql.SQLException
- Specified by:
createArrayOf
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createArrayOf(java.lang.String, java.lang.Object[])
createBlob
public java.sql.Blob createBlob()
throws java.sql.SQLException
- Specified by:
createBlob
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createBlob()
createClob
public java.sql.Clob createClob()
throws java.sql.SQLException
- Specified by:
createClob
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createClob()
createNClob
public java.sql.NClob createNClob()
throws java.sql.SQLException
- Specified by:
createNClob
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createNClob()
createSQLXML
public java.sql.SQLXML createSQLXML()
throws java.sql.SQLException
- Specified by:
createSQLXML
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createSQLXML()
createStruct
public java.sql.Struct createStruct(java.lang.String typeName,
java.lang.Object[] attributes)
throws java.sql.SQLException
- Specified by:
createStruct
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.createStruct(java.lang.String, java.lang.Object[])
getAutoCommit
public boolean getAutoCommit()
throws java.sql.SQLException
- Specified by:
getAutoCommit
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getAutoCommit()
getCatalog
public java.lang.String getCatalog()
throws java.sql.SQLException
- Specified by:
getCatalog
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getCatalog()
getClientInfo
public java.util.Properties getClientInfo()
throws java.sql.SQLException
- Specified by:
getClientInfo
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getClientInfo()
getClientInfo
public java.lang.String getClientInfo(java.lang.String name)
throws java.sql.SQLException
- Specified by:
getClientInfo
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getClientInfo(java.lang.String)
getHoldability
public int getHoldability()
throws java.sql.SQLException
- Specified by:
getHoldability
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getHoldability()
getMetaData
public java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
- Specified by:
getMetaData
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getMetaData()
getTypeMap
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
throws java.sql.SQLException
- Specified by:
getTypeMap
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getTypeMap()
getWarnings
public java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
- Specified by:
getWarnings
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.getWarnings()
isClosed
public boolean isClosed()
throws java.sql.SQLException
- Specified by:
isClosed
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.isClosed()
isReadOnly
public boolean isReadOnly()
throws java.sql.SQLException
- Specified by:
isReadOnly
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.isReadOnly()
isValid
public boolean isValid(int timeout)
throws java.sql.SQLException
- Specified by:
isValid
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.isValid(int)
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
- Specified by:
nativeSQL
in interface java.sql.Connection
- Throws:
java.sql.SQLException
setAutoCommit
public void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
- Specified by:
setAutoCommit
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.setAutoCommit(boolean)
setCatalog
public void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
- Specified by:
setCatalog
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.setCatalog(java.lang.String)
setClientInfo
public void setClientInfo(java.util.Properties properties)
throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interface java.sql.Connection
- Throws:
java.sql.SQLClientInfoException
- See Also:
Connection.setClientInfo(java.util.Properties)
setClientInfo
public void setClientInfo(java.lang.String name,
java.lang.String value)
throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interface java.sql.Connection
- Throws:
java.sql.SQLClientInfoException
- See Also:
Connection.setClientInfo(java.lang.String, java.lang.String)
setHoldability
public void setHoldability(int holdability)
throws java.sql.SQLException
- Specified by:
setHoldability
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.setHoldability(int)
setReadOnly
public void setReadOnly(boolean readOnly)
throws java.sql.SQLException
- Specified by:
setReadOnly
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.setReadOnly(boolean)
setTypeMap
public void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> arg0)
throws java.sql.SQLException
- Specified by:
setTypeMap
in interface java.sql.Connection
- Throws:
java.sql.SQLException
- See Also:
Connection.setTypeMap(java.util.Map)
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
- Specified by:
isWrapperFor
in interface java.sql.Wrapper
- Throws:
java.sql.SQLException
- See Also:
Wrapper.isWrapperFor(java.lang.Class)
unwrap
public <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
- Specified by:
unwrap
in interface java.sql.Wrapper
- Throws:
java.sql.SQLException
- See Also:
Wrapper.unwrap(java.lang.Class)