Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnection.java @ 887:b757def3ff55
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
geo-backend/trunk@859 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 09:45:05 +0000 |
parents | 8b442223741c |
children | e9ca6be4dbd2 |
line wrap: on
line source
package de.intevation.gnv.geobackend.sde.datasources; import com.esri.sde.sdk.client.SeConnection; import com.esri.sde.sdk.client.SeException; import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException; import de.intevation.gnv.geobackend.sde.connectionpool.ArcSDEPoolableObjectFactory; import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.NClob; import java.sql.PreparedStatement; import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; import java.util.Map; import java.util.Properties; import org.apache.log4j.Logger; /** * Wrapperclass between an @see java.sql.Connection and an * @see com.esri.sde.sdk.client.SeConnection * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> */ public class ArcSDEConnection implements Connection { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); /** * The Connection to the ArcSDE-backend. */ private SeConnection seConnection = null; /** * Time that have to be gone until the Server will be requested if * the Connection is valid. */ private long serverRoundtripInterval ; /** * The Time which a Connection can be inactive until the Connection * will be set to invalid. */ private long inactiveInterval; /** * The TimeStamp of the last usage of this Connection. */ private long lastTouch; /** * Constructor * @param server the URL to the Server * @param port the Port of the Server * @param database the Name of the Database * @param username the Name of the User * @param credentials the Credentials to the User- * @param serverRoundtripInterval Time that have to be gone until the Server * will be requested if the Connection is valid. * @param inactiveInterval the Time which a Connection can be inactive until * the Connection will be set to invalid. * @throws ConnectionException */ public ArcSDEConnection( String server, String port, String database, String username, String credentials, long serverRoundtripInterval, long inactiveInterval ) throws ConnectionException { this.serverRoundtripInterval = serverRoundtripInterval; this.inactiveInterval = inactiveInterval; lastTouch = System.currentTimeMillis(); try { seConnection = new SeConnection( server, port, database, username, credentials); } catch (SeException e) { log.error(e,e); throw new ConnectionException(e); } } /** * TODO: DOCUMENT ME. * @return */ public boolean isActive() { long current = System.currentTimeMillis(); long last; synchronized (this) { last = lastTouch; } return Math.abs(current - last) < inactiveInterval; } /** * Sets the last-Usage-Time to the Current-time */ public void touch() { long time = System.currentTimeMillis(); synchronized (this) { lastTouch = time; } } /** * @see java.sql.Connection#clearWarnings() */ public void clearWarnings() throws SQLException { } /** * @see java.sql.Connection#close() */ public void close() throws SQLException { try { this.seConnection.close(); } catch (SeException e) { log.error(e,e); throw new SQLException(e.getMessage()); } } /** * @see java.sql.Connection#commit() */ public void commit() throws SQLException { try{ this.seConnection.commitTransaction(); } catch (SeException e) { log.error(e,e); throw new SQLException(e.getMessage()); } } /** * @see java.sql.Connection#createStatement() */ public Statement createStatement() throws SQLException { return new ArcSDEStatement(this); } /** * @see java.sql.Connection#createStatement(int, int) */ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { return new ArcSDEStatement(this); } /** * @see java.sql.Connection#createStatement(int, int, int) */ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return new ArcSDEStatement(this); } /** * @see java.sql.Connection#getAutoCommit() */ public boolean getAutoCommit() throws SQLException { return false; } /** * @see java.sql.Connection#getCatalog() */ public String getCatalog() throws SQLException { return null; } /** * @see java.sql.Connection#getHoldability() */ public int getHoldability() throws SQLException { return 0; } /** * @see java.sql.Connection#getMetaData() */ public DatabaseMetaData getMetaData() throws SQLException { return null; } /** * @see java.sql.Connection#getTransactionIsolation() */ public int getTransactionIsolation() throws SQLException { return 0; } /** * @see java.sql.Connection#getTypeMap() */ public Map<String, Class<?>> getTypeMap() throws SQLException { return null; } /** * @see java.sql.Connection#getWarnings() */ public SQLWarning getWarnings() throws SQLException { return null; } /** * @see java.sql.Connection#isClosed() */ public boolean isClosed() throws SQLException { try{ return this.seConnection.isClosed(); } catch (Exception e) { log.error(e,e); throw new SQLException(e.getMessage()); } } /** * @see java.sql.Connection#isReadOnly() */ public boolean isReadOnly() throws SQLException { return false; } /** * @see java.sql.Connection#nativeSQL(java.lang.String) */ public String nativeSQL(String sql) throws SQLException { return null; } /** * @see java.sql.Connection#prepareCall(java.lang.String) */ public CallableStatement prepareCall(String sql) throws SQLException { return null; } /** * @see java.sql.Connection#prepareCall(java.lang.String, int, int) */ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { return null; } /** * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int) */ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String) */ public PreparedStatement prepareStatement(String sql) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String, int) */ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String, int[]) */ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[]) */ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String, int, int) */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { return null; } /** * @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int) */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return null; } /** * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint) */ public void releaseSavepoint(Savepoint savepoint) throws SQLException { } /** * @see java.sql.Connection#rollback() */ public void rollback() throws SQLException { try { this.seConnection.rollbackTransaction(); } catch (SeException e) { log.error(e,e); throw new SQLException(e.getMessage()); } } /** * @see java.sql.Connection#rollback(java.sql.Savepoint) */ public void rollback(Savepoint savepoint) throws SQLException { this.rollback(); } /** * @see java.sql.Connection#setAutoCommit(boolean) */ public void setAutoCommit(boolean autoCommit) throws SQLException { } /** * @see java.sql.Connection#setCatalog(java.lang.String) */ public void setCatalog(String catalog) throws SQLException { } /** * @see java.sql.Connection#setHoldability(int) */ public void setHoldability(int holdability) throws SQLException { } /** * @see java.sql.Connection#setReadOnly(boolean) */ public void setReadOnly(boolean readOnly) throws SQLException { } /** * @see java.sql.Connection#setSavepoint() */ public Savepoint setSavepoint() throws SQLException { return null; } /** * @see java.sql.Connection#setSavepoint(java.lang.String) */ public Savepoint setSavepoint(String name) throws SQLException { return null; } /** * @see java.sql.Connection#setTransactionIsolation(int) */ public void setTransactionIsolation(int level) throws SQLException { } /** * @see java.sql.Connection#setTypeMap(java.util.Map) */ public void setTypeMap(Map<String, Class<?>> map) throws SQLException { } /** * @return the seConnection */ public SeConnection getSeConnection() { return seConnection; } public Array createArrayOf(String arg0, Object[] arg1) throws SQLException { return null; } public Blob createBlob() throws SQLException { return null; } public Clob createClob() throws SQLException { return null; } public NClob createNClob() throws SQLException { return null; } public SQLXML createSQLXML() throws SQLException { return null; } public Struct createStruct(String arg0, Object[] arg1) throws SQLException { return null; } public Properties getClientInfo() throws SQLException { return null; } public String getClientInfo(String arg0) throws SQLException { return null; } public boolean isValid(int arg0) throws SQLException { boolean valid = true; try { this.seConnection.testServer(serverRoundtripInterval); } catch (SeException e) { log.debug("The validation of the Connection has occured an Error. The connection is invalid."); valid = false; } return valid; } public void setClientInfo(Properties arg0) throws SQLClientInfoException { } public void setClientInfo(String arg0, String arg1) throws SQLClientInfoException { } public boolean isWrapperFor(Class<?> iface) throws SQLException { return false; } public <T> T unwrap(Class<T> iface) throws SQLException { return null; } }