tim@130: /** tim@130: * tim@130: */ tim@130: package de.intevation.gnv.geobackend.sde.datasources; tim@130: tim@130: import java.sql.Connection; tim@130: import java.sql.ResultSet; tim@130: import java.sql.SQLException; tim@130: import java.sql.SQLWarning; tim@130: import java.sql.Statement; tim@130: tim@130: import org.apache.log4j.Logger; tim@130: tim@130: import com.esri.sde.sdk.client.SeColumnDefinition; tim@130: import com.esri.sde.sdk.client.SeConnection; tim@130: import com.esri.sde.sdk.client.SeException; tim@130: import com.esri.sde.sdk.client.SeQuery; tim@130: import com.esri.sde.sdk.client.SeRow; tim@130: tim@130: /** tim@130: * @author Tim Englich tim@130: * tim@130: */ tim@130: public class ArcSDEStatement implements Statement { tim@130: tim@130: /** tim@130: * the logger, used to log exceptions and additonaly information tim@130: */ tim@130: private static Logger log = Logger.getLogger(ArcSDEStatement.class); tim@130: tim@130: private ArcSDEConnection connection = null; tim@130: tim@130: /** tim@130: * Constructor tim@130: */ tim@130: public ArcSDEStatement(ArcSDEConnection connection) { tim@130: this.connection = connection; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#addBatch(java.lang.String) tim@130: */ tim@130: public void addBatch(String arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#cancel() tim@130: */ tim@130: public void cancel() throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#clearBatch() tim@130: */ tim@130: public void clearBatch() throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#clearWarnings() tim@130: */ tim@130: public void clearWarnings() throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#close() tim@130: */ tim@130: public void close() throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#execute(java.lang.String) tim@130: */ tim@130: public boolean execute(String arg0) throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#execute(java.lang.String, int) tim@130: */ tim@130: public boolean execute(String arg0, int arg1) throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#execute(java.lang.String, int[]) tim@130: */ tim@130: public boolean execute(String arg0, int[] arg1) throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#execute(java.lang.String, java.lang.String[]) tim@130: */ tim@130: public boolean execute(String arg0, String[] arg1) throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeBatch() tim@130: */ tim@130: public int[] executeBatch() throws SQLException { tim@130: tim@130: return null; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeQuery(java.lang.String) tim@130: */ tim@130: public ResultSet executeQuery(String statement) throws SQLException { tim@130: try { tim@130: SeQuery query = new SeQuery(this.connection.getSeConnection()); tim@130: query.prepareSql(statement); tim@130: query.execute(); tim@130: return this.handleResultSet(query); tim@130: } catch (SeException e) { tim@130: log.error(e,e); tim@130: throw new SQLException(e.getMessage()); tim@130: } tim@130: tim@130: tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeUpdate(java.lang.String) tim@130: */ tim@130: public int executeUpdate(String arg0) throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeUpdate(java.lang.String, int) tim@130: */ tim@130: public int executeUpdate(String arg0, int arg1) throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeUpdate(java.lang.String, int[]) tim@130: */ tim@130: public int executeUpdate(String arg0, int[] arg1) throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[]) tim@130: */ tim@130: public int executeUpdate(String arg0, String[] arg1) throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getConnection() tim@130: */ tim@130: public Connection getConnection() throws SQLException { tim@130: return this.connection; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getFetchDirection() tim@130: */ tim@130: public int getFetchDirection() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getFetchSize() tim@130: */ tim@130: public int getFetchSize() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getGeneratedKeys() tim@130: */ tim@130: public ResultSet getGeneratedKeys() throws SQLException { tim@130: tim@130: return null; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getMaxFieldSize() tim@130: */ tim@130: public int getMaxFieldSize() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getMaxRows() tim@130: */ tim@130: public int getMaxRows() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getMoreResults() tim@130: */ tim@130: public boolean getMoreResults() throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getMoreResults(int) tim@130: */ tim@130: public boolean getMoreResults(int arg0) throws SQLException { tim@130: tim@130: return false; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getQueryTimeout() tim@130: */ tim@130: public int getQueryTimeout() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getResultSet() tim@130: */ tim@130: public ResultSet getResultSet() throws SQLException { tim@130: tim@130: return null; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getResultSetConcurrency() tim@130: */ tim@130: public int getResultSetConcurrency() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getResultSetHoldability() tim@130: */ tim@130: public int getResultSetHoldability() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getResultSetType() tim@130: */ tim@130: public int getResultSetType() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getUpdateCount() tim@130: */ tim@130: public int getUpdateCount() throws SQLException { tim@130: tim@130: return 0; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#getWarnings() tim@130: */ tim@130: public SQLWarning getWarnings() throws SQLException { tim@130: tim@130: return null; tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setCursorName(java.lang.String) tim@130: */ tim@130: public void setCursorName(String arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setEscapeProcessing(boolean) tim@130: */ tim@130: public void setEscapeProcessing(boolean arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setFetchDirection(int) tim@130: */ tim@130: public void setFetchDirection(int arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setFetchSize(int) tim@130: */ tim@130: public void setFetchSize(int arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setMaxFieldSize(int) tim@130: */ tim@130: public void setMaxFieldSize(int arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setMaxRows(int) tim@130: */ tim@130: public void setMaxRows(int arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * @see java.sql.Statement#setQueryTimeout(int) tim@130: */ tim@130: public void setQueryTimeout(int arg0) throws SQLException { tim@130: } tim@130: tim@130: /** tim@130: * Copied from de.intevation.gnv.geobackend.sde.datasources.SDEQuery tim@130: * @param pSeQuery tim@130: * @return tim@130: * @throws SeException tim@130: */ tim@130: private ResultSet handleResultSet(SeQuery pSeQuery) throws SeException { tim@130: log.debug("ArcSDEStatement,handleResultSet()"); tim@130: SDEResultSet lSet = new SDEResultSet(); tim@130: SeRow row; tim@130: int lCount; tim@130: for (lCount = 0; (row = pSeQuery.fetch()) != null; lCount++) { tim@130: // one time execution tim@130: if (lCount == 0) { tim@130: // analyze cols of result set tim@130: SeColumnDefinition[] lCols = row.getColumns(); tim@130: for (SeColumnDefinition lCol : lCols) { tim@130: lSet.addCol(new ColDefinition(lCol.getName(), lCol.getType()));// notice: esri-types have been copied into colDefinition class! tim@130: } tim@130: } tim@130: short lNumCols = row.getNumColumns(); tim@130: Row lBackingRow = new Row(lNumCols); tim@130: for (int i = 0; i < lNumCols; i++) { tim@130: lBackingRow.addObject(row.getObject(i), i); tim@130: } tim@130: lSet.addRow(lBackingRow); tim@130: } tim@130: pSeQuery.close(); tim@130: return lSet; tim@130: } tim@130: tim@130: }