diff options
Diffstat (limited to 'openjdk/sun/jdbc/odbc')
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcCallableStatement.java | 662 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcConnection.java | 490 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSet.java | 287 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSetMetaData.java | 180 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcDatabaseMetaData.java | 1211 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcDriver.java | 111 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcObject.java | 650 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcPreparedStatement.java | 387 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcResultSet.java | 799 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java | 269 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcStatement.java | 386 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcUpdateableResultSet.java | 165 | ||||
-rw-r--r-- | openjdk/sun/jdbc/odbc/JdbcOdbcUtils.java | 372 |
13 files changed, 0 insertions, 5969 deletions
diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcCallableStatement.java b/openjdk/sun/jdbc/odbc/JdbcOdbcCallableStatement.java deleted file mode 100644 index 12a15ff3..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcCallableStatement.java +++ /dev/null @@ -1,662 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.*; -import java.util.Calendar; -import java.util.Map; - -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.*; - - - -/** - * @author Volker Berlin - */ -public class JdbcOdbcCallableStatement extends JdbcOdbcPreparedStatement implements CallableStatement{ - - private final Parameters parameters = new Parameters(); - - public JdbcOdbcCallableStatement(JdbcOdbcConnection jdbcConn, OdbcCommand command, String sql, int resultSetType, int resultSetConcurrency){ - super(jdbcConn, command, sql, resultSetType, resultSetConcurrency); - } - - - public final Array getArray(int parameterIndex){ - return parameters.getArray(parameterIndex); - } - - - public final Array getArray(String parameterName) throws SQLException{ - return parameters.getArray(parameterName); - } - - - public final BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException{ - return parameters.getBigDecimal(parameterIndex, scale); - } - - - public final BigDecimal getBigDecimal(int parameterIndex) throws SQLException{ - return parameters.getBigDecimal(parameterIndex); - } - - - public final BigDecimal getBigDecimal(String parameterName) throws SQLException{ - return parameters.getBigDecimal(parameterName); - } - - - public final Blob getBlob(int parameterIndex){ - return parameters.getBlob(parameterIndex); - } - - - public final Blob getBlob(String parameterName) throws SQLException{ - return parameters.getBlob(parameterName); - } - - - public final boolean getBoolean(int parameterIndex) throws SQLException{ - return parameters.getBoolean(parameterIndex); - } - - - public final boolean getBoolean(String parameterName) throws SQLException{ - return parameters.getBoolean(parameterName); - } - - - public final byte getByte(int parameterIndex) throws SQLException{ - return parameters.getByte(parameterIndex); - } - - - public final byte getByte(String parameterName) throws SQLException{ - return parameters.getByte(parameterName); - } - - - public final byte[] getBytes(int parameterIndex) throws SQLException{ - return parameters.getBytes(parameterIndex); - } - - - public final byte[] getBytes(String parameterName) throws SQLException{ - return parameters.getBytes(parameterName); - } - - - public final Reader getCharacterStream(int parameterIndex) throws SQLException{ - return parameters.getCharacterStream(parameterIndex); - } - - - public final Reader getCharacterStream(String parameterName) throws SQLException{ - return parameters.getCharacterStream(parameterName); - } - - - public final Clob getClob(int parameterIndex){ - return parameters.getClob(parameterIndex); - } - - - public final Clob getClob(String parameterName) throws SQLException{ - return parameters.getClob(parameterName); - } - - - public final Date getDate(int parameterIndex, Calendar cal) throws SQLException{ - return parameters.getDate(parameterIndex, cal); - } - - - public final Date getDate(int parameterIndex) throws SQLException{ - return parameters.getDate(parameterIndex); - } - - - public final Date getDate(String parameterName, Calendar cal) throws SQLException{ - return parameters.getDate(parameterName, cal); - } - - - public final Date getDate(String parameterName) throws SQLException{ - return parameters.getDate(parameterName); - } - - - public final double getDouble(int parameterIndex) throws SQLException{ - return parameters.getDouble(parameterIndex); - } - - - public final double getDouble(String parameterName) throws SQLException{ - return parameters.getDouble(parameterName); - } - - - public final float getFloat(int parameterIndex) throws SQLException{ - return parameters.getFloat(parameterIndex); - } - - - public final float getFloat(String parameterName) throws SQLException{ - return parameters.getFloat(parameterName); - } - - - public final int getInt(int parameterIndex) throws SQLException{ - return parameters.getInt(parameterIndex); - } - - - public final int getInt(String parameterName) throws SQLException{ - return parameters.getInt(parameterName); - } - - - public final long getLong(int parameterIndex) throws SQLException{ - return parameters.getLong(parameterIndex); - } - - - public final long getLong(String parameterName) throws SQLException{ - return parameters.getLong(parameterName); - } - - - public final Reader getNCharacterStream(int parameterIndex) throws SQLException{ - return parameters.getNCharacterStream(parameterIndex); - } - - - public final Reader getNCharacterStream(String parameterName) throws SQLException{ - return parameters.getNCharacterStream(parameterName); - } - - - public final NClob getNClob(int parameterIndex){ - return parameters.getNClob(parameterIndex); - } - - - public final NClob getNClob(String parameterName) throws SQLException{ - return parameters.getNClob(parameterName); - } - - - public final String getNString(int parameterIndex) throws SQLException{ - return parameters.getNString(parameterIndex); - } - - - public final String getNString(String parameterName) throws SQLException{ - return parameters.getNString(parameterName); - } - - - public final Object getObject(int parameterIndex, Map<String, Class<?>> map){ - return parameters.getObject(parameterIndex, map); - } - - - public final Object getObject(int parameterIndex) throws SQLException{ - return parameters.getObject(parameterIndex); - } - - - public final Object getObject(String parameterName, Map<String, Class<?>> map) throws SQLException{ - return parameters.getObject(parameterName, map); - } - - - public final Object getObject(String parameterName) throws SQLException{ - return parameters.getObject(parameterName); - } - - - public final Ref getRef(int parameterIndex){ - return parameters.getRef(parameterIndex); - } - - - public final Ref getRef(String parameterName) throws SQLException{ - return parameters.getRef(parameterName); - } - - - public final RowId getRowId(int parameterIndex){ - return parameters.getRowId(parameterIndex); - } - - - public final RowId getRowId(String parameterName) throws SQLException{ - return parameters.getRowId(parameterName); - } - - - public final short getShort(int parameterIndex) throws SQLException{ - return parameters.getShort(parameterIndex); - } - - - public final short getShort(String parameterName) throws SQLException{ - return parameters.getShort(parameterName); - } - - - public final SQLXML getSQLXML(int parameterIndex){ - return parameters.getSQLXML(parameterIndex); - } - - - public final SQLXML getSQLXML(String parameterName) throws SQLException{ - return parameters.getSQLXML(parameterName); - } - - - public final String getString(int parameterIndex) throws SQLException{ - return parameters.getString(parameterIndex); - } - - - public final String getString(String parameterName) throws SQLException{ - return parameters.getString(parameterName); - } - - - public final Time getTime(int parameterIndex, Calendar cal) throws SQLException{ - return parameters.getTime(parameterIndex, cal); - } - - - public final Time getTime(int parameterIndex) throws SQLException{ - return parameters.getTime(parameterIndex); - } - - - public final Time getTime(String parameterName, Calendar cal) throws SQLException{ - return parameters.getTime(parameterName, cal); - } - - - public final Time getTime(String parameterName) throws SQLException{ - return parameters.getTime(parameterName); - } - - - public final Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException{ - return parameters.getTimestamp(parameterIndex, cal); - } - - - public final Timestamp getTimestamp(int parameterIndex) throws SQLException{ - return parameters.getTimestamp(parameterIndex); - } - - - public final Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException{ - return parameters.getTimestamp(parameterName, cal); - } - - - public final Timestamp getTimestamp(String parameterName) throws SQLException{ - return parameters.getTimestamp(parameterName); - } - - - public final URL getURL(int parameterIndex) throws SQLException{ - return parameters.getURL(parameterIndex); - } - - - public final URL getURL(String parameterName) throws SQLException{ - return parameters.getURL(parameterName); - } - - - public final boolean wasNull(){ - return parameters.wasNull(); - } - - - public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException{ - registerOutParameter(parameterIndex, sqlType, -1); - } - - - public void registerOutParameter(String parameterName, int sqlType) throws SQLException{ - registerOutParameter(parameters.findColumn(parameterName), sqlType); - } - - - public void registerOutParameter(int parameterIndex, int sqlType, int scaleOrLength) throws SQLException{ - DbParameter para = getPara(parameterIndex); - int direction = para.get_Value() == null ? ParameterDirection.Output : ParameterDirection.InputOutput; - para.set_Direction(ParameterDirection.wrap(direction)); - - if(sqlType != Types.OTHER){ - para.set_DbType(DbType.wrap(JdbcOdbcUtils.convertJdbc2AdoNetType(sqlType))); - } - - if(scaleOrLength >= 0){ - switch(sqlType){ - case Types.DECIMAL: - case Types.NUMERIC: - para.set_Scale((byte)scaleOrLength); - } - } - } - - - public void registerOutParameter(int parameterIndex, int sqlType, String typeName){ - throw new UnsupportedOperationException(); - } - - - public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException{ - registerOutParameter(parameters.findColumn(parameterName), sqlType, scale); - } - - - public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException{ - registerOutParameter(parameters.findColumn(parameterName), sqlType, typeName); - } - - - public void setAsciiStream(String parameterName, InputStream x) throws SQLException{ - setAsciiStream(parameters.findColumn(parameterName), x); - } - - - public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException{ - setAsciiStream(parameters.findColumn(parameterName), x, length); - } - - - public void setAsciiStream(String parameterName, InputStream x, long length) throws SQLException{ - setAsciiStream(parameters.findColumn(parameterName), x, length); - } - - - public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException{ - setBigDecimal(parameters.findColumn(parameterName), x); - } - - - public void setBinaryStream(String parameterName, InputStream x) throws SQLException{ - setBinaryStream(parameters.findColumn(parameterName), x); - } - - - public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException{ - setBinaryStream(parameters.findColumn(parameterName), x, length); - } - - - public void setBinaryStream(String parameterName, InputStream x, long length) throws SQLException{ - setBinaryStream(parameters.findColumn(parameterName), x, length); - } - - - public void setBlob(String parameterName, Blob x) throws SQLException{ - setBlob(parameters.findColumn(parameterName), x); - } - - - public void setBlob(String parameterName, InputStream x) throws SQLException{ - setBlob(parameters.findColumn(parameterName), x); - } - - - public void setBlob(String parameterName, InputStream x, long length) throws SQLException{ - setBlob(parameters.findColumn(parameterName), x, length); - } - - - public void setBoolean(String parameterName, boolean x) throws SQLException{ - setBoolean(parameters.findColumn(parameterName), x); - } - - - public void setByte(String parameterName, byte x) throws SQLException{ - setByte(parameters.findColumn(parameterName), x); - } - - - public void setBytes(String parameterName, byte[] x) throws SQLException{ - setBytes(parameters.findColumn(parameterName), x); - } - - - public void setCharacterStream(String parameterName, Reader x) throws SQLException{ - setCharacterStream(parameters.findColumn(parameterName), x); - } - - - public void setCharacterStream(String parameterName, Reader x, int length) throws SQLException{ - setCharacterStream(parameters.findColumn(parameterName), x, length); - } - - - public void setCharacterStream(String parameterName, Reader x, long length) throws SQLException{ - setCharacterStream(parameters.findColumn(parameterName), x, length); - } - - - public void setClob(String parameterName, Clob x) throws SQLException{ - setClob(parameters.findColumn(parameterName), x); - } - - - public void setClob(String parameterName, Reader x) throws SQLException{ - setClob(parameters.findColumn(parameterName), x); - } - - - public void setClob(String parameterName, Reader x, long length) throws SQLException{ - setClob(parameters.findColumn(parameterName), x, length); - } - - - public void setDate(String parameterName, Date x) throws SQLException{ - setDate(parameters.findColumn(parameterName), x); - } - - - public void setDate(String parameterName, Date x, Calendar cal) throws SQLException{ - setDate(parameters.findColumn(parameterName), x, cal); - } - - - public void setDouble(String parameterName, double x) throws SQLException{ - setDouble(parameters.findColumn(parameterName), x); - } - - - public void setFloat(String parameterName, float x) throws SQLException{ - setFloat(parameters.findColumn(parameterName), x); - } - - - public void setInt(String parameterName, int x) throws SQLException{ - setInt(parameters.findColumn(parameterName), x); - } - - - public void setLong(String parameterName, long x) throws SQLException{ - setLong(parameters.findColumn(parameterName), x); - } - - - public void setNCharacterStream(String parameterName, Reader x) throws SQLException{ - setNCharacterStream(parameters.findColumn(parameterName), x); - } - - - public void setNCharacterStream(String parameterName, Reader x, long length) throws SQLException{ - setNCharacterStream(parameters.findColumn(parameterName), x, length); - } - - - public void setNClob(String parameterName, NClob x) throws SQLException{ - setNClob(parameters.findColumn(parameterName), x); - } - - - public void setNClob(String parameterName, Reader x) throws SQLException{ - setNClob(parameters.findColumn(parameterName), x); - } - - - public void setNClob(String parameterName, Reader x, long length) throws SQLException{ - setNClob(parameters.findColumn(parameterName), x, length); - } - - - public void setNString(String parameterName, String x) throws SQLException{ - setNString(parameters.findColumn(parameterName), x); - } - - - public void setNull(String parameterName, int sqlType) throws SQLException{ - setNull(parameters.findColumn(parameterName), sqlType); - } - - - public void setNull(String parameterName, int sqlType, String typeName) throws SQLException{ - setNull(parameters.findColumn(parameterName), sqlType, typeName); - } - - - public void setObject(String parameterName, Object x) throws SQLException{ - setObject(parameters.findColumn(parameterName), x); - } - - - public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException{ - setObject(parameters.findColumn(parameterName), x, targetSqlType); - } - - - public void setObject(String parameterName, Object x, int targetSqlType, int scaleOrLength) throws SQLException{ - setObject(parameters.findColumn(parameterName), x, targetSqlType, scaleOrLength); - } - - - public void setRowId(String parameterName, RowId x) throws SQLException{ - setRowId(parameters.findColumn(parameterName), x); - } - - - public void setSQLXML(String parameterName, SQLXML x) throws SQLException{ - setSQLXML(parameters.findColumn(parameterName), x); - } - - - public void setShort(String parameterName, short x) throws SQLException{ - setShort(parameters.findColumn(parameterName), x); - } - - - public void setString(String parameterName, String x) throws SQLException{ - setString(parameters.findColumn(parameterName), x); - } - - - public void setTime(String parameterName, Time x) throws SQLException{ - setTime(parameters.findColumn(parameterName), x); - } - - - public void setTime(String parameterName, Time x, Calendar cal) throws SQLException{ - setTime(parameters.findColumn(parameterName), x, cal); - } - - - public void setTimestamp(String parameterName, Timestamp x) throws SQLException{ - setTimestamp(parameters.findColumn(parameterName), x); - } - - - public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException{ - setTimestamp(parameters.findColumn(parameterName), x, cal); - } - - - public void setURL(String parameterName, URL x) throws SQLException{ - setURL(parameters.findColumn(parameterName), x); - } - - private class Parameters extends JdbcOdbcObject{ - - @Override - public int findColumn(String parameterName) throws SQLException{ - try{ - DbParameterCollection params = command.get_Parameters(); - for(int i=0; i<params.get_Count();i++){ - DbParameter param = params.get_Item(i); - if(parameterName.equalsIgnoreCase(param.get_ParameterName())){ - return i+1; - } - } - throw new SQLException( "Parameter '"+parameterName+"' not found.", "S0022"); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - @Override - protected Object getObjectImpl(int parameterIndex) throws SQLException{ - return getPara(parameterIndex).get_Value(); - } - - } - - - /** - * {@inheritDoc} - */ - public <T> T getObject(int parameterIndex, Class<T> type) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - - /** - * {@inheritDoc} - */ - public <T> T getObject(String parameterName, Class<T> type) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcConnection.java b/openjdk/sun/jdbc/odbc/JdbcOdbcConnection.java deleted file mode 100644 index 5e075b2a..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcConnection.java +++ /dev/null @@ -1,490 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.*; - -import java.sql.*; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider - */ -public class JdbcOdbcConnection implements Connection{ - - private final OdbcConnection netConn; - - private DbTransaction transaction; - - private int isolation = TRANSACTION_READ_COMMITTED; - - - JdbcOdbcConnection(String connectString, Properties info) throws SQLException{ - try{ - boolean isDSN = connectString.indexOf('=') < 0; - StringBuilder connStr = new StringBuilder(); - if(isDSN){ - connStr.append("DSN="); - } - connStr.append(connectString); - - String uid = info.getProperty("user"); - String pwd = info.getProperty("password"); - - if(uid != null){ - connStr.append(";UID=").append(uid); - } - if(pwd != null){ - connStr.append(";PWD=").append(pwd); - } - - netConn = new OdbcConnection(connStr.toString()); - - netConn.Open(); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public void clearWarnings() throws SQLException{ - // TODO Auto-generated method stub - - } - - - @Override - public void close() throws SQLException{ - try{ - netConn.Close(); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - @Override - public Array createArrayOf(String typeName, Object[] elements){ - throw new UnsupportedOperationException(); - } - - - @Override - public Blob createBlob(){ - throw new UnsupportedOperationException(); - } - - - @Override - public Clob createClob(){ - throw new UnsupportedOperationException(); - } - - - @Override - public NClob createNClob(){ - throw new UnsupportedOperationException(); - } - - - @Override - public SQLXML createSQLXML(){ - throw new UnsupportedOperationException(); - } - - - @Override - public Statement createStatement() throws SQLException{ - return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - } - - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException{ - try{ - return new JdbcOdbcStatement(this, netConn.CreateCommand(), resultSetType, resultSetConcurrency); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability){ - throw new UnsupportedOperationException(); - } - - - @Override - public Struct createStruct(String typeName, Object[] attributes){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setAutoCommit(boolean autoCommit) throws SQLException{ - try{ - if(autoCommit && transaction != null){ - return; // no change - } - if(!autoCommit && transaction == null){ - return; // no change - } - int level; - switch(isolation){ - case TRANSACTION_READ_COMMITTED: - level = IsolationLevel.ReadUncommitted; - break; - case TRANSACTION_READ_UNCOMMITTED: - level = IsolationLevel.ReadCommitted; - break; - case TRANSACTION_REPEATABLE_READ: - level = IsolationLevel.RepeatableRead; - break; - case TRANSACTION_SERIALIZABLE: - level = IsolationLevel.Serializable; - break; - default: - level = IsolationLevel.ReadCommitted; - } - if(autoCommit){ - transaction = netConn.BeginTransaction(IsolationLevel.wrap(level)); - }else{ - transaction.Commit(); - transaction = null; - } - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - @Override - public boolean getAutoCommit(){ - return transaction != null; - } - - - @Override - public void commit() throws SQLException{ - try{ - if(transaction == null){ - // auto commit == true - return; - } - transaction.Commit(); - transaction = netConn.BeginTransaction(transaction.get_IsolationLevel()); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - @Override - public void rollback() throws SQLException{ - try{ - if(transaction == null){ - // auto commit == true - return; - } - transaction.Rollback(); - transaction = netConn.BeginTransaction(transaction.get_IsolationLevel()); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - @Override - public void setTransactionIsolation(int level){ - isolation = level; - } - - - @Override - public int getTransactionIsolation(){ - return isolation; - } - - - @Override - public String getClientInfo(String name){ - throw new UnsupportedOperationException(); - } - - - @Override - public Properties getClientInfo(){ - throw new UnsupportedOperationException(); - } - - - @Override - public int getHoldability(){ - throw new UnsupportedOperationException(); - } - - - @Override - public DatabaseMetaData getMetaData(){ - return new JdbcOdbcDatabaseMetaData(this, netConn); - } - - - @Override - public Map<String, Class<?>> getTypeMap(){ - throw new UnsupportedOperationException(); - } - - - @Override - public SQLWarning getWarnings() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - @Override - public boolean isClosed() throws SQLException{ - return netConn.get_State().Value == ConnectionState.Closed; - } - - - @Override - public boolean isReadOnly() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - @Override - public boolean isValid(int timeout) throws SQLException{ - throw new UnsupportedOperationException(); - } - - - @Override - public String nativeSQL(String sql) throws SQLException{ - // TODO Auto-generated method stub - return sql; - } - - - @Override - public CallableStatement prepareCall(String sql) throws SQLException{ - return prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - } - - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException{ - try{ - return new JdbcOdbcCallableStatement(this, netConn.CreateCommand(), sql, resultSetType, - resultSetConcurrency); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability){ - throw new UnsupportedOperationException(); - } - - - @Override - public PreparedStatement prepareStatement(String sql) throws SQLException{ - return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - } - - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException{ - try{ - return new JdbcOdbcPreparedStatement(this, netConn.CreateCommand(), sql, resultSetType, - resultSetConcurrency); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability){ - throw new UnsupportedOperationException(); - } - - - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys){ - throw new UnsupportedOperationException(); - } - - - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes){ - throw new UnsupportedOperationException(); - } - - - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames){ - throw new UnsupportedOperationException(); - } - - - @Override - public void releaseSavepoint(Savepoint savepoint){ - throw new UnsupportedOperationException(); - } - - - @Override - public void rollback(Savepoint savepoint){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setCatalog(String catalog) throws SQLException{ - try{ - netConn.ChangeDatabase(catalog); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public String getCatalog(){ - return netConn.get_Database(); - } - - - @Override - public void setClientInfo(String name, String value){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setClientInfo(Properties properties){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setHoldability(int holdability){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setReadOnly(boolean readOnly) throws SQLException{ - // TODO Auto-generated method stub - - } - - - @Override - public Savepoint setSavepoint(){ - throw new UnsupportedOperationException(); - } - - - @Override - public Savepoint setSavepoint(String name){ - throw new UnsupportedOperationException(); - } - - - @Override - public void setTypeMap(Map<String, Class<?>> map){ - throw new UnsupportedOperationException(); - } - - - @Override - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - @Override - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - - /** - * {@inheritDoc} - */ - public void setSchema(String schema) throws SQLException { - } - - - /** - * {@inheritDoc} - */ - public String getSchema() throws SQLException { - return null; - } - - - /** - * {@inheritDoc} - */ - public void abort(Executor executor) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - - /** - * {@inheritDoc} - */ - public void setNetworkTimeout(Executor executor, int milliseconds) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - - /** - * {@inheritDoc} - */ - public int getNetworkTimeout() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSet.java b/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSet.java deleted file mode 100644 index 9de750a4..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSet.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.sql.*; - -import cli.System.Data.*; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider. This ResultSet based on DataTable. It is read only and - * scrollable. - */ -public class JdbcOdbcDTResultSet extends JdbcOdbcResultSet{ - - private final DataTable data; - - private DataRowCollection rows; - - private int rowIndex; // row index starting with 0; -1 means beforeFirst - - private cli.System.Data.DataRow row; - - - public JdbcOdbcDTResultSet(DataTable data){ - this(data, CONCUR_READ_ONLY); - } - public JdbcOdbcDTResultSet(DataTable data, int concurrency){ - super(null, TYPE_SCROLL_INSENSITIVE, concurrency); - this.data = data; - this.rows = data.get_Rows(); - this.rowIndex = -1; - } - - - @Override - public boolean absolute(int rowPosition) throws SQLException{ - if(rowPosition == 0){ - return !isBeforeFirst() && !isAfterLast(); - } - DataRowCollection dataRows = getRows(); - int count = dataRows.get_Count(); - if(rowPosition > 0){ - if(rowPosition > count){ - rowIndex = count; - setDataRow(); - return false; - } - rowIndex = rowPosition - 1; - setDataRow(); - return true; - }else{ - if(-rowPosition > count){ - rowIndex = -1; - setDataRow(); - return false; - } - rowIndex = count + rowPosition; - setDataRow(); - return true; - } - } - - - @Override - public void afterLast() throws SQLException{ - rowIndex = getRows().get_Count(); - setDataRow(); - } - - - @Override - public void beforeFirst() throws SQLException{ - rowIndex = -1; - setDataRow(); - } - - - @Override - public void close(){ - rows = null; - } - - - @Override - public int findColumn(String columnLabel) throws SQLException{ - getRows(); // Check if ResultSet is closed - int idx = data.get_Columns().IndexOf(columnLabel); - if(idx < 0){ - throw new SQLException("Column '" + columnLabel + "' not found.", "S0022"); - } - return idx + 1; - } - - - @Override - public boolean first() throws SQLException{ - beforeFirst(); - return next(); - } - - - @Override - public ResultSetMetaData getMetaData(){ - return new JdbcOdbcDTResultSetMetaData(data); - } - - - @Override - public int getRow() throws SQLException{ - return rowIndex < getRows().get_Count() ? rowIndex + 1 : 0; - } - - - @Override - public boolean isAfterLast() throws SQLException{ - int count = getRows().get_Count(); - return rowIndex >= count || count == 0; - } - - - @Override - public boolean isBeforeFirst() throws SQLException{ - return rowIndex <= -1 || getRows().get_Count() == 0; - } - - - @Override - public boolean isClosed(){ - return rows == null; - } - - - @Override - public boolean isFirst() throws SQLException{ - return rowIndex == 0 && getRows().get_Count() > 0; - } - - - @Override - public boolean isLast() throws SQLException{ - return rowIndex >= 0 && rowIndex == getRows().get_Count() - 1; - } - - - @Override - public boolean last() throws SQLException{ - afterLast(); - return previous(); - } - - - @Override - public boolean next() throws SQLException{ - DataRowCollection dataRows = getRows(); - if(rowIndex + 1 < dataRows.get_Count()){ - ++rowIndex; - setDataRow(); - return true; - }else{ - rowIndex = dataRows.get_Count(); - setDataRow(); - return false; - } - } - - - @Override - public boolean previous() throws SQLException{ - if(rowIndex > 0){ - --rowIndex; - setDataRow(); - return true; - }else{ - rowIndex = -1; - setDataRow(); - return false; - } - } - - - @Override - public void refreshRow(){ - // ignore it - } - - - @Override - public boolean relative(int rowPositions) throws SQLException{ - DataRowCollection dataRows = getRows(); - int newRowIndex = rowIndex + rowPositions; - if(newRowIndex < 0){ - rowIndex = -1; - setDataRow(); - return false; - } - int count = dataRows.get_Count(); - if(newRowIndex >= dataRows.get_Count()){ - rowIndex = count; - setDataRow(); - return false; - } - rowIndex = newRowIndex; - setDataRow(); - return true; - } - - - /** - * {@inheritDoc} - */ - @Override - protected Object getObjectImpl(int columnIndex) throws SQLException{ - try{ - return getDataRow().get_Item(columnIndex - 1); - }catch(ArrayIndexOutOfBoundsException ex){ - throw new SQLException("Invalid column number (" + columnIndex + "). A number between 1 and " - + data.get_Columns().get_Count() + " is valid.", "S1002"); - } - } - - - /** - * Check if this ResultSet is closed before access to the DataRowCollection - * - * @return the local rows object - * @throws SQLException - * If the ResultSet is closed. - */ - protected DataRowCollection getRows() throws SQLException{ - if(rows == null){ - throw new SQLException("ResultSet is closed.", "24000"); - } - return rows; - } - - - /** - * Get the current DataRow - * - * @return the DataRow - * @throws SQLException - * if closed or no current Row - */ - protected DataRow getDataRow() throws SQLException{ - getRows(); // checks if ResultSet is closed - if(row == null){ - throw new SQLException("No current row", "S1109"); - } - return row; - } - - /** - * Set the current row from the current rowIndex. If the rowIndex was not change - * then the row variable will be new set. - * @throws SQLException If the ResultSet is closed. - */ - protected void setDataRow() throws SQLException{ - DataRowCollection dataRows = getRows(); - if(rowIndex < 0 || rowIndex >= dataRows.get_Count()){ - row = null; - }else{ - row = dataRows.get_Item(rowIndex); - } - } - -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSetMetaData.java b/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSetMetaData.java deleted file mode 100644 index 25c15fb9..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcDTResultSetMetaData.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.sql.*; - -import cli.System.Data.*; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider - */ -public class JdbcOdbcDTResultSetMetaData implements ResultSetMetaData{ - - private final DataTable table; - - - public JdbcOdbcDTResultSetMetaData(DataTable table){ - this.table = table; - } - - - public String getCatalogName(int column){ - return ""; - } - - - public String getColumnClassName(int column){ - String type = getDataColumn(column).get_DataType().toString(); - return JdbcOdbcUtils.getJavaClassName(type); - } - - - public int getColumnCount(){ - return table.get_Columns().get_Count(); - } - - - public int getColumnDisplaySize(int column) throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public String getColumnLabel(int column) throws SQLException{ - return getDataColumn(column).get_Caption(); - } - - - public String getColumnName(int column) throws SQLException{ - return getDataColumn(column).get_ColumnName(); - } - - - public int getColumnType(int column) throws SQLException{ - cli.System.Type type = getDataColumn(column).get_DataType(); - // TODO Auto-generated method stub - return Types.OTHER; - } - - - public String getColumnTypeName(int column) throws SQLException{ - return ""; - } - - - public int getPrecision(int column) throws SQLException{ - return getDataColumn(column).get_MaxLength(); - } - - - public int getScale(int column) throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public String getSchemaName(int column) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getTableName(int column) throws SQLException{ - return table.get_TableName(); - } - - - public boolean isAutoIncrement(int column) throws SQLException{ - return getDataColumn(column).get_AutoIncrement(); - } - - - public boolean isCaseSensitive(int column) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isCurrency(int column) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isDefinitelyWritable(int column) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public int isNullable(int column) throws SQLException{ - return getDataColumn(column).get_AllowDBNull() ? columnNullable : columnNoNulls; - } - - - public boolean isReadOnly(int column) throws SQLException{ - return getDataColumn(column).get_ReadOnly(); - } - - - public boolean isSearchable(int column) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isSigned(int column) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isWritable(int column) throws SQLException{ - return !getDataColumn(column).get_ReadOnly(); - } - - - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - - /** - * Get a DataColumn from the DataTable - * @param column the JDBC column index starting with 1 - * @return the DataColumn - */ - private DataColumn getDataColumn(int column){ - return table.get_Columns().get_Item(column - 1); - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcDatabaseMetaData.java b/openjdk/sun/jdbc/odbc/JdbcOdbcDatabaseMetaData.java deleted file mode 100644 index df631c5b..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcDatabaseMetaData.java +++ /dev/null @@ -1,1211 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import ikvm.lang.CIL; - -import java.sql.*; -import java.util.HashSet; - -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.*; - -/** - * @author Volker Berlin - */ -public class JdbcOdbcDatabaseMetaData implements DatabaseMetaData{ - - private JdbcOdbcConnection jdbcConn; - - private final OdbcConnection netConn; - - private DataRow dataSourceInfo; - - public JdbcOdbcDatabaseMetaData(JdbcOdbcConnection jdbcConn, OdbcConnection netConn){ - this.jdbcConn = jdbcConn; - this.netConn = netConn; - } - - - public boolean allProceduresAreCallable() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean allTablesAreSelectable() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean autoCommitFailureClosesAllResultSets(){ - throw new UnsupportedOperationException(); - } - - - public boolean dataDefinitionCausesTransactionCommit() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean dataDefinitionIgnoredInTransactions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean deletesAreDetected(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean doesMaxRowSizeIncludeBlobs() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, - String attributeNamePattern){ - throw new UnsupportedOperationException(); - } - - - public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) - throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getCatalogSeparator() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getCatalogTerm() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getCatalogs() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getClientInfoProperties(){ - throw new UnsupportedOperationException(); - } - - - public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) - throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) - throws SQLException{ - try{ - // the description of the restrictions can you request with GetSchema("Restrictions") - String[] restrictions = new String[]{catalog, schemaPattern, tableNamePattern, columnNamePattern}; - DataTable data = netConn.GetSchema(OdbcMetaDataCollectionNames.Columns, restrictions); - return new JdbcOdbcDTResultSet(data); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public Connection getConnection(){ - return jdbcConn; - } - - - public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, - String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public int getDatabaseMajorVersion(){ - String version = netConn.get_ServerVersion().trim(); - for(int i = 0; i < version.length(); i++){ - char ch = version.charAt(i); - if(ch < '0' || ch > '9'){ - return Integer.parseInt(version.substring(0, i)); - } - } - return Integer.parseInt(version); - } - - - public int getDatabaseMinorVersion(){ - String version = netConn.get_ServerVersion().trim(); - int idx = version.indexOf('.'); - if(idx < 0){ - return 0; - } - version = version.substring(idx + 1); - for(int i = 0; i < version.length(); i++){ - char ch = version.charAt(i); - if(ch < '0' || ch > '9'){ - return Integer.parseInt(version.substring(0, i)); - } - } - return Integer.parseInt(version); - } - - - public String getDatabaseProductName() throws SQLException{ - return String.valueOf(getInfo(DbMetaDataColumnNames.DataSourceProductName)); - } - - - public String getDatabaseProductVersion(){ - return netConn.get_ServerVersion(); - } - - - public int getDefaultTransactionIsolation(){ - return Connection.TRANSACTION_READ_COMMITTED; - } - - - public int getDriverMajorVersion(){ - return 2; - } - - - public int getDriverMinorVersion(){ - return 1; - } - - - public String getDriverName(){ - return "JDBC-ODBC Bridge (" + netConn.get_Driver() + ")"; - } - - - public String getDriverVersion(){ - return "2.0001"; - } - - - public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getExtraNameCharacters(){ - return ""; - } - - - public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, - String columnNamePattern){ - throw new UnsupportedOperationException(); - } - - - public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern){ - throw new UnsupportedOperationException(); - } - - - public String getIdentifierQuoteString() throws SQLException{ - String quote = (String)getInfo(DbMetaDataColumnNames.QuotedIdentifierPattern); - if(quote.length()>=2){ - char ch1 = quote.charAt(0); - char ch2 = quote.charAt(quote.length()-1); - if(ch1 == ch2){ - return quote.substring(0,1); - } - } - return "\""; // ANSI SQL and should work with the most DBMS - } - - - public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) - throws SQLException{ - try{ - // the description of the restrictions can you request with GetSchema("Restrictions") - String[] restrictions = new String[]{catalog, schema, table}; - DataTable data = netConn.GetSchema(OdbcMetaDataCollectionNames.Indexes, restrictions); - return new JdbcOdbcDTResultSet(data); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public int getJDBCMajorVersion(){ - return 2; - } - - - public int getJDBCMinorVersion(){ - return 0; - } - - - public int getMaxBinaryLiteralLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxCatalogNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxCharLiteralLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnsInGroupBy() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnsInIndex() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnsInOrderBy() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnsInSelect() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxColumnsInTable() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxConnections() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxCursorNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxIndexLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxProcedureNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxRowSize() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxSchemaNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxStatementLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxStatements() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxTableNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxTablesInSelect() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxUserNameLength() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public String getNumericFunctions() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, - String columnNamePattern) throws SQLException{ - try{ - // the description of the restrictions can you request with GetSchema("Restrictions") - String[] restrictions = new String[]{catalog, schemaPattern, procedureNamePattern, columnNamePattern}; - DataTable dt1 = netConn.GetSchema(OdbcMetaDataCollectionNames.ProcedureColumns, restrictions); - DataTable dt2 = netConn.GetSchema(OdbcMetaDataCollectionNames.ProcedureParameters, restrictions); - // concatenate the both DataTable - DataRowCollection rows1 = dt1.get_Rows(); - DataRowCollection rows2 = dt2.get_Rows(); - for(int i = 0; i < rows2.get_Count(); i++){ - DataRow row = rows2.get_Item(i); - rows1.Add(row.get_ItemArray()); - } - return new JdbcOdbcDTResultSet(dt1); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public String getProcedureTerm() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) - throws SQLException{ - try{ - // the description of the restrictions can you request with GetSchema("Restrictions") - String[] restrictions = new String[]{catalog, schemaPattern, procedureNamePattern}; - DataTable data = netConn.GetSchema(OdbcMetaDataCollectionNames.Procedures, restrictions); - return new JdbcOdbcDTResultSet(data); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public int getResultSetHoldability(){ - throw new UnsupportedOperationException(); - } - - - public RowIdLifetime getRowIdLifetime(){ - throw new UnsupportedOperationException(); - } - - - public String getSQLKeywords() throws SQLException{ - try{ - DataTable dt = netConn.GetSchema(DbMetaDataCollectionNames.ReservedWords); - final DataRowCollection rows = dt.get_Rows(); - final int count = rows.get_Count(); - final StringBuilder builder = new StringBuilder(); - for(int i=0; i<count; i++){ - String word = (String)rows.get_Item(i).get_Item(0); - if(builder.length() > 0){ - builder.append(','); - } - builder.append(word); - } - return builder.toString(); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public int getSQLStateType() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public String getSchemaTerm() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getSchemas() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getSchemas(String catalog, String schemaPattern){ - throw new UnsupportedOperationException(); - } - - - public String getSearchStringEscape() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getStringFunctions() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern){ - throw new UnsupportedOperationException(); - } - - - public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern){ - throw new UnsupportedOperationException(); - } - - - public String getSystemFunctions() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getTableTypes() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) - throws SQLException{ - try{ - // the description of the restrictions can you request with GetSchema("Restrictions") - String[] restrictions = new String[]{catalog, schemaPattern, tableNamePattern}; - DataTable dt1 = netConn.GetSchema(OdbcMetaDataCollectionNames.Tables, restrictions); - DataTable dt2 = netConn.GetSchema(OdbcMetaDataCollectionNames.Views, restrictions); - // concatenate the both DataTable - DataRowCollection rows1 = dt1.get_Rows(); - DataRowCollection rows2 = dt2.get_Rows(); - for(int i = 0; i < rows2.get_Count(); i++){ - DataRow row = rows2.get_Item(i); - rows1.Add(row.get_ItemArray()); - } - if(types != null){ - RowLoop: - // Filter the types - for(int i = rows1.get_Count() - 1; i >= 0; i--){ - DataRow row = rows1.get_Item(i); - Object tableType = row.get_Item("TABLE_TYPE"); - for(String type : types){ - if(type.equals(tableType)){ - continue RowLoop; - } - } - rows1.RemoveAt(i); - } - } - return new JdbcOdbcDTResultSet(dt1); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public String getTimeDateFunctions() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getTypeInfo() throws SQLException{ - try{ - //TODO Column Names and order are wrong - DataTable data = netConn.GetSchema(DbMetaDataCollectionNames.DataTypes); - return new JdbcOdbcDTResultSet(data); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types){ - throw new UnsupportedOperationException(); - } - - - public String getURL() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public String getUserName() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public boolean insertsAreDetected(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isCatalogAtStart() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isReadOnly() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean locatorsUpdateCopy(){ - throw new UnsupportedOperationException(); - } - - - public boolean nullPlusNonNullIsNull() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean nullsAreSortedAtEnd() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean nullsAreSortedAtStart() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean nullsAreSortedHigh() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean nullsAreSortedLow() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean othersDeletesAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean othersInsertsAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean othersUpdatesAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean ownDeletesAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean ownInsertsAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean ownUpdatesAreVisible(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesLowerCaseIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesLowerCaseQuotedIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesMixedCaseIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesMixedCaseQuotedIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesUpperCaseIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean storesUpperCaseQuotedIdentifiers() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsANSI92EntryLevelSQL() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsANSI92FullSQL() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsANSI92IntermediateSQL() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsAlterTableWithAddColumn() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsAlterTableWithDropColumn() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsBatchUpdates() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCatalogsInDataManipulation() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCatalogsInIndexDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCatalogsInProcedureCalls() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCatalogsInTableDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsColumnAliasing() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsConvert() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsConvert(int fromType, int toType) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCoreSQLGrammar() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsCorrelatedSubqueries() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsDataManipulationTransactionsOnly() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsDifferentTableCorrelationNames() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsExpressionsInOrderBy() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsExtendedSQLGrammar() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsFullOuterJoins() throws SQLException{ - int join = CIL.unbox_int(getInfo(DbMetaDataColumnNames.SupportedJoinOperators)); - return (join & SupportedJoinOperators.FullOuter) > 0; - } - - - public boolean supportsGetGeneratedKeys() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsGroupBy() throws SQLException{ - int behavior = CIL.unbox_int(getInfo(DbMetaDataColumnNames.GroupByBehavior)); - return behavior != GroupByBehavior.NotSupported; - } - - - public boolean supportsGroupByBeyondSelect() throws SQLException{ - int behavior = CIL.unbox_int(getInfo(DbMetaDataColumnNames.GroupByBehavior)); - return behavior == GroupByBehavior.MustContainAll; - } - - - public boolean supportsGroupByUnrelated() throws SQLException{ - int behavior = CIL.unbox_int(getInfo(DbMetaDataColumnNames.GroupByBehavior)); - return behavior == GroupByBehavior.Unrelated; - } - - - public boolean supportsIntegrityEnhancementFacility() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsLikeEscapeClause() throws SQLException{ - return getSQLKeywords().toUpperCase().indexOf(",LIKE,") > 0; - } - - - public boolean supportsLimitedOuterJoins() throws SQLException{ - int join = CIL.unbox_int(getInfo(DbMetaDataColumnNames.SupportedJoinOperators)); - return join > 0; - } - - - public boolean supportsMinimumSQLGrammar() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsMixedCaseIdentifiers() throws SQLException{ - int identifierCase = CIL.unbox_int(getInfo(DbMetaDataColumnNames.IdentifierCase)); - return identifierCase == IdentifierCase.Sensitive; - } - - - public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException{ - int identifierCase = CIL.unbox_int(getInfo(DbMetaDataColumnNames.QuotedIdentifierCase)); - return identifierCase == IdentifierCase.Sensitive; - } - - - public boolean supportsMultipleOpenResults() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsMultipleResultSets() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsMultipleTransactions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsNamedParameters() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsNonNullableColumns() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsOpenCursorsAcrossCommit() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsOpenCursorsAcrossRollback() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsOpenStatementsAcrossCommit() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsOpenStatementsAcrossRollback() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsOrderByUnrelated() throws SQLException{ - return CIL.unbox_boolean( getInfo(DbMetaDataColumnNames.OrderByColumnsInSelect)); - } - - - public boolean supportsOuterJoins() throws SQLException{ - int join = CIL.unbox_int(getInfo(DbMetaDataColumnNames.SupportedJoinOperators)); - return (join & SupportedJoinOperators.LeftOuter) > 0 || (join & SupportedJoinOperators.RightOuter) > 0; - } - - - public boolean supportsPositionedDelete() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsPositionedUpdate() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsResultSetHoldability(int holdability){ - throw new UnsupportedOperationException(); - } - - - public boolean supportsResultSetType(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSavepoints() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSchemasInDataManipulation() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSchemasInIndexDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSchemasInProcedureCalls() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSchemasInTableDefinitions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSelectForUpdate() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsStatementPooling(){ - throw new UnsupportedOperationException(); - } - - - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException{ - throw new UnsupportedOperationException(); - } - - - public boolean supportsStoredProcedures() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSubqueriesInComparisons() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSubqueriesInExists() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSubqueriesInIns() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsSubqueriesInQuantifieds() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsTableCorrelationNames() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsTransactionIsolationLevel(int level) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsTransactions() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsUnion() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean supportsUnionAll() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean updatesAreDetected(int type) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean usesLocalFilePerTable() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean usesLocalFiles() throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - private Object getInfo(String key) throws SQLException{ - try{ - if(dataSourceInfo == null){ - DataTable td = netConn.GetSchema(DbMetaDataCollectionNames.DataSourceInformation); - dataSourceInfo = td.get_Rows().get_Item(0); - } - return dataSourceInfo.get_Item(key); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - /** - * {@inheritDoc} - */ - public ResultSet getPseudoColumns(String catalog, String schemaPattern, - String tableNamePattern, String columnNamePattern) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - - /** - * {@inheritDoc} - */ - public boolean generatedKeyAlwaysReturned() throws SQLException { - return false; - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcDriver.java b/openjdk/sun/jdbc/odbc/JdbcOdbcDriver.java deleted file mode 100644 index 9eb1d9d4..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcDriver.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.sql.*; -import java.util.Properties; -import java.util.logging.Logger; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider - */ -public class JdbcOdbcDriver implements Driver{ - - private static final String URL_PREFIX = "jdbc:odbc:"; - - static{ - try{ - DriverManager.registerDriver(new JdbcOdbcDriver()); - }catch(SQLException ex){ - throw new ExceptionInInitializerError(ex); - } - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean acceptsURL(String url){ - return url.startsWith(URL_PREFIX); - } - - - /** - * {@inheritDoc} - */ - @Override - public Connection connect(String url, Properties info) throws SQLException{ - if(!acceptsURL(url)){ - return null; - } - String connectString = url.substring(URL_PREFIX.length()); - return new JdbcOdbcConnection(connectString, info); - } - - - /** - * {@inheritDoc} - */ - @Override - public int getMajorVersion(){ - return 2; - } - - - /** - * {@inheritDoc} - */ - @Override - public int getMinorVersion(){ - return 1; - } - - - /** - * {@inheritDoc} - */ - @Override - public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException{ - return new DriverPropertyInfo[0]; - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean jdbcCompliant(){ - return true; - } - - - /** - * {@inheritDoc} - */ - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(); - } - -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcObject.java b/openjdk/sun/jdbc/odbc/JdbcOdbcObject.java deleted file mode 100644 index 32e9a40f..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcObject.java +++ /dev/null @@ -1,650 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - Copyright (C) 2011 Karsten Heinrich (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.Ref; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Map; - -import cli.System.Convert; -import cli.System.DBNull; -import cli.System.IConvertible; -import cli.System.Int16; -import cli.System.Int32; -import cli.System.Int64; -import cli.System.Single; - -/** - * @author Volker Berlin - */ -public abstract class JdbcOdbcObject{ - - private boolean wasNull; - - - /** - * Maps the given ResultSet column label to its ResultSet column index or the given CallableStatment parameter name - * to the parameter index. - * - * @param columnLabel - * the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, - * then the label is the name of the column - * @return the column index of the given column name - * @throws SQLException - * if the ResultSet object does not contain a column labeled columnLabel, a database access error occurs - * or this method is called on a closed result set - */ - public abstract int findColumn(String columnLabel) throws SQLException; - - - /** - * Read an Object from the current row store at the current row on the given column. - * - * @param columnIndex - * a JDBC column index starting with 1 - * @return a .NET Object, DBNull or null - * @throws SQLException - * if the result is closed or any other error occur. - */ - protected abstract Object getObjectImpl(int columnIndex) throws SQLException; - - - /** - * Read an Object from the current row store at the current row on the given column. Set the flag wasNull. - * - * @param columnIndex - * a JDBC column index starting with 1 - * @return a .NET Object or null - * @throws SQLException - * if the result is closed or any other error occur. - */ - private final Object getObjectSetWasNull(int columnIndex) throws SQLException{ - Object obj = getObjectImpl(columnIndex); - if(obj == null || obj == DBNull.Value){ - wasNull = true; - return null; - } - wasNull = false; - return obj; - } - - - public final Array getArray(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final Array getArray(String columnLabel) throws SQLException{ - return getArray(findColumn(columnLabel)); - } - - - public final InputStream getAsciiStream(int columnIndex) throws SQLException{ - try{ - String str = getString(columnIndex); - if(str == null){ - return null; - } - return new ByteArrayInputStream(str.getBytes("Ascii")); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final InputStream getAsciiStream(String columnLabel) throws SQLException{ - return getAsciiStream(findColumn(columnLabel)); - } - - - public final BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException{ - BigDecimal dec = getBigDecimal(columnIndex); - if(dec == null){ - return null; - } - if(dec.scale() != scale){ - return dec.setScale(scale, BigDecimal.ROUND_HALF_EVEN); - } - return dec; - } - - - public final BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException{ - return getBigDecimal(findColumn(columnLabel), scale); - } - - - public final BigDecimal getBigDecimal(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - String str = obj.toString(); - return new BigDecimal(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final BigDecimal getBigDecimal(String columnLabel) throws SQLException{ - return getBigDecimal(findColumn(columnLabel)); - } - - - public final InputStream getBinaryStream(int columnIndex) throws SQLException{ - byte[] data = getBytes(columnIndex); - if(data == null){ - return null; - } - return new ByteArrayInputStream(data); - } - - - public final InputStream getBinaryStream(String columnLabel) throws SQLException{ - return getBinaryStream(findColumn(columnLabel)); - } - - - public final Blob getBlob(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final Blob getBlob(String columnLabel) throws SQLException{ - return getBlob(findColumn(columnLabel)); - } - - - public final boolean getBoolean(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return false; - } - if(obj instanceof IConvertible){ - return Convert.ToBoolean(obj); - } - String str = obj.toString(); - if(str.length() > 0){ - // special handling for boolean representation in old databases - char ch = str.charAt(0); - if(ch == 'T' || ch == 't'){ - return true; - } - if(ch == 'F' || ch == 'f'){ - return true; - } - } - return cli.System.Boolean.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final boolean getBoolean(String columnLabel) throws SQLException{ - return getBoolean(findColumn(columnLabel)); - } - - - public final byte getByte(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToByte(obj); - } - String str = obj.toString(); - return cli.System.Byte.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final byte getByte(String columnLabel) throws SQLException{ - return getByte(findColumn(columnLabel)); - } - - - public final byte[] getBytes(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - if(obj instanceof byte[]){ - return (byte[])obj; - } - String str = obj.toString(); - return str.getBytes(); // which encoding? - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final byte[] getBytes(String columnLabel) throws SQLException{ - return getBytes(findColumn(columnLabel)); - } - - - public final Reader getCharacterStream(int columnIndex) throws SQLException{ - String str = getString(columnIndex); - if(str == null){ - return null; - } - return new StringReader(str); - } - - - public final Reader getCharacterStream(String columnLabel) throws SQLException{ - return getCharacterStream(findColumn(columnLabel)); - } - - - public final Clob getClob(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final Clob getClob(String columnLabel) throws SQLException{ - return getClob(findColumn(columnLabel)); - } - - - public final Date getDate(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - if(obj instanceof cli.System.DateTime){ - cli.System.DateTime dt = (cli.System.DateTime)obj; - return new Date(dt.get_Year() - 1900, dt.get_Month() - 1, dt.get_Day()); - } - String str = obj.toString(); - return Date.valueOf(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final Date getDate(String columnLabel) throws SQLException{ - return getDate(findColumn(columnLabel)); - } - - - public final Date getDate(int columnIndex, Calendar cal) throws SQLException{ - Date date = getDate(columnIndex); - JdbcOdbcUtils.convertLocalToCalendarDate(date, cal); - return date; - } - - - public final Date getDate(String columnLabel, Calendar cal) throws SQLException{ - return getDate(findColumn(columnLabel), cal); - } - - - public final double getDouble(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToDouble(obj); - } - String str = obj.toString(); - return cli.System.Double.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final double getDouble(String columnLabel) throws SQLException{ - return getDouble(findColumn(columnLabel)); - } - - - public final float getFloat(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToSingle(obj); - } - String str = obj.toString(); - return Single.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final float getFloat(String columnLabel) throws SQLException{ - return getFloat(findColumn(columnLabel)); - } - - - public final int getInt(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToInt32(obj); - } - String str = obj.toString(); - return Int32.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final int getInt(String columnLabel) throws SQLException{ - return getInt(findColumn(columnLabel)); - } - - - public final long getLong(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToInt64(obj); - } - String str = obj.toString(); - return Int64.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final long getLong(String columnLabel) throws SQLException{ - return getLong(findColumn(columnLabel)); - } - - - public final Reader getNCharacterStream(int columnIndex) throws SQLException{ - return getCharacterStream(columnIndex); - } - - - public final Reader getNCharacterStream(String columnLabel) throws SQLException{ - return getCharacterStream(columnLabel); - } - - - public final NClob getNClob(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final NClob getNClob(String columnLabel) throws SQLException{ - return getNClob(findColumn(columnLabel)); - } - - - public final String getNString(int columnIndex) throws SQLException{ - return getString(columnIndex); - } - - - public final String getNString(String columnLabel) throws SQLException{ - return getString(columnLabel); - } - - - public final Object getObject(int columnIndex) throws SQLException{ - return JdbcOdbcUtils.convertNet2Java(getObjectSetWasNull(columnIndex)); - } - - - public final Object getObject(String columnLabel) throws SQLException{ - return getObject(findColumn(columnLabel)); - } - - - public final Object getObject(int columnIndex, Map<String, Class<?>> map){ - throw new UnsupportedOperationException(); - } - - - public final Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException{ - return getObject(findColumn(columnLabel), map); - } - - - public final Ref getRef(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final Ref getRef(String columnLabel) throws SQLException{ - return getRef(findColumn(columnLabel)); - } - - - public final RowId getRowId(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final RowId getRowId(String columnLabel) throws SQLException{ - return getRowId(findColumn(columnLabel)); - } - - - public final SQLXML getSQLXML(int columnIndex){ - throw new UnsupportedOperationException(); - } - - - public final SQLXML getSQLXML(String columnLabel) throws SQLException{ - return getSQLXML(findColumn(columnLabel)); - } - - - public final short getShort(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return 0; - } - if(obj instanceof IConvertible){ - return Convert.ToInt16(obj); - } - String str = obj.toString(); - return Int16.Parse(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final short getShort(String columnLabel) throws SQLException{ - return getShort(findColumn(columnLabel)); - } - - - public final String getString(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - return obj.toString(); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final String getString(String columnLabel) throws SQLException{ - return getString(findColumn(columnLabel)); - } - - - public final Time getTime(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - if(obj instanceof cli.System.DateTime){ - cli.System.DateTime dt = (cli.System.DateTime)obj; - return new Time(dt.get_Hour(), dt.get_Minute() - 1, dt.get_Second()); - } - if(obj instanceof cli.System.TimeSpan){ - cli.System.TimeSpan ts = (cli.System.TimeSpan)obj; - return new Time(ts.get_Hours(), ts.get_Minutes() - 1, ts.get_Seconds()); - } - String str = obj.toString(); - return Time.valueOf(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final Time getTime(String columnLabel) throws SQLException{ - return getTime(findColumn(columnLabel)); - } - - - public final Time getTime(int columnIndex, Calendar cal) throws SQLException{ - Time time = getTime(columnIndex); - JdbcOdbcUtils.convertLocalToCalendarDate(time, cal); - return time; - } - - - public final Time getTime(String columnLabel, Calendar cal) throws SQLException{ - return getTime(findColumn(columnLabel), cal); - } - - - public final Timestamp getTimestamp(int columnIndex) throws SQLException{ - try{ - Object obj = getObjectSetWasNull(columnIndex); - if(wasNull){ - return null; - } - if(obj instanceof cli.System.DateTime){ - return JdbcOdbcUtils.convertDateTimeToTimestamp((cli.System.DateTime)obj); - } - String str = obj.toString(); - return Timestamp.valueOf(str); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final Timestamp getTimestamp(String columnLabel) throws SQLException{ - return getTimestamp(findColumn(columnLabel)); - } - - - public final Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException{ - Timestamp ts = getTimestamp(columnIndex); - JdbcOdbcUtils.convertLocalToCalendarDate(ts, cal); - return ts; - } - - - public final Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException{ - return getTimestamp(findColumn(columnLabel), cal); - } - - - public final URL getURL(int columnIndex) throws SQLException{ - try{ - String url = getString(columnIndex); - if(wasNull){ - return null; - } - return new URL(url); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final URL getURL(String columnLabel) throws SQLException{ - return getURL(findColumn(columnLabel)); - } - - - public final InputStream getUnicodeStream(int columnIndex) throws SQLException{ - try{ - return new ByteArrayInputStream(getString(columnIndex).getBytes("UTF16")); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public final InputStream getUnicodeStream(String columnLabel) throws SQLException{ - return getUnicodeStream(findColumn(columnLabel)); - } - - - public final boolean wasNull(){ - return wasNull; - } - -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcPreparedStatement.java b/openjdk/sun/jdbc/odbc/JdbcOdbcPreparedStatement.java deleted file mode 100644 index 93805fd6..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcPreparedStatement.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.ParameterMetaData; -import java.sql.PreparedStatement; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.Calendar; - -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.*; - -/** - * @author Volker Berlin - */ -public class JdbcOdbcPreparedStatement extends JdbcOdbcStatement implements PreparedStatement{ - - public JdbcOdbcPreparedStatement(JdbcOdbcConnection jdbcConn, OdbcCommand command, String sql, int resultSetType, int resultSetConcurrency){ - super(jdbcConn, command, resultSetType, resultSetConcurrency); - command.set_CommandText(sql); - command.Prepare(); - } - - - public void addBatch() throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void clearParameters(){ - DbParameterCollection params = command.get_Parameters(); - params.Clear(); - } - - - public boolean execute() throws SQLException{ - return super.execute(null); - } - - - public ResultSet executeQuery() throws SQLException{ - return super.executeQuery(null); - } - - - public int executeUpdate() throws SQLException{ - return super.executeUpdate(null); - } - - - public ResultSetMetaData getMetaData() throws SQLException{ - ResultSet rs = getResultSet(); - if(rs != null){ - rs.getMetaData(); - } - DbDataReader reader = command.ExecuteReader(CommandBehavior.wrap(CommandBehavior.SchemaOnly)); - JdbcOdbcResultSetMetaData metadata = new JdbcOdbcResultSetMetaData(reader); - reader.Close(); - return metadata; - } - - - public ParameterMetaData getParameterMetaData(){ - throw new UnsupportedOperationException(); - } - - - public void setArray(int parameterIndex, Array x) throws SQLException{ - setObject(parameterIndex, x, Types.ARRAY); - } - - - public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARCHAR); - } - - - public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARCHAR, length); - } - - - public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARCHAR, (int)length); - } - - - public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException{ - setObject(parameterIndex, x, Types.DECIMAL); - } - - - public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARBINARY); - } - - - public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARBINARY, length); - } - - - public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARBINARY, (int)length); - } - - - public void setBlob(int parameterIndex, Blob x) throws SQLException{ - setObject(parameterIndex, x, Types.BLOB); - } - - - public void setBlob(int parameterIndex, InputStream x) throws SQLException{ - setObject(parameterIndex, x, Types.BLOB); - } - - - public void setBlob(int parameterIndex, InputStream x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.BLOB, (int)length); - } - - - public void setBoolean(int parameterIndex, boolean x) throws SQLException{ - setObject(parameterIndex, Boolean.valueOf(x), Types.BOOLEAN); - } - - - public void setByte(int parameterIndex, byte x) throws SQLException{ - setObject(parameterIndex, Byte.valueOf(x), Types.TINYINT); - } - - - public void setBytes(int parameterIndex, byte[] x) throws SQLException{ - setObject(parameterIndex, x, Types.BINARY); - } - - - public void setCharacterStream(int parameterIndex, Reader x) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARCHAR); - } - - - public void setCharacterStream(int parameterIndex, Reader x, int length) throws SQLException{ - setObject(parameterIndex, x, Types.NCLOB, length); - } - - - public void setCharacterStream(int parameterIndex, Reader x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGVARCHAR, (int)length); - } - - - public void setClob(int parameterIndex, Clob x) throws SQLException{ - setObject(parameterIndex, x, Types.CLOB); - } - - - public void setClob(int parameterIndex, Reader x) throws SQLException{ - setObject(parameterIndex, x, Types.CLOB); - } - - - public void setClob(int parameterIndex, Reader x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.CLOB, (int)length); - } - - - public void setDate(int parameterIndex, Date x) throws SQLException{ - setObject(parameterIndex, x, Types.DATE); - } - - - public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException{ - JdbcOdbcUtils.convertCalendarToLocalDate(x, cal); - setObject(parameterIndex, x, Types.DATE); - } - - - public void setDouble(int parameterIndex, double x) throws SQLException{ - setObject(parameterIndex, Double.valueOf(x), Types.DOUBLE); - } - - - public void setFloat(int parameterIndex, float x) throws SQLException{ - setObject(parameterIndex, Float.valueOf(x), Types.FLOAT); - } - - - public void setInt(int parameterIndex, int x) throws SQLException{ - setObject(parameterIndex, Integer.valueOf(x), Types.INTEGER); - } - - - public void setLong(int parameterIndex, long x) throws SQLException{ - setObject(parameterIndex, Long.valueOf(x), Types.BIGINT); - } - - - public void setNCharacterStream(int parameterIndex, Reader x) throws SQLException{ - setObject(parameterIndex, x, Types.LONGNVARCHAR); - } - - - public void setNCharacterStream(int parameterIndex, Reader x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGNVARCHAR, (int)length); - } - - - public void setNClob(int parameterIndex, NClob x) throws SQLException{ - setObject(parameterIndex, x, Types.NCLOB); - } - - - public void setNClob(int parameterIndex, Reader x) throws SQLException{ - setObject(parameterIndex, x, Types.NCLOB); - } - - - public void setNClob(int parameterIndex, Reader x, long length) throws SQLException{ - setObject(parameterIndex, x, Types.NCLOB, (int)length); - } - - - public void setNString(int parameterIndex, String x) throws SQLException{ - setObject(parameterIndex, x, Types.NVARCHAR); - } - - - public void setNull(int parameterIndex, int sqlType) throws SQLException{ - setObject(parameterIndex, null, sqlType); - } - - - public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException{ - setObject(parameterIndex, null, sqlType); - } - - - public void setObject(int parameterIndex, Object x) throws SQLException{ - setObject(parameterIndex, x, Types.OTHER, -1); - } - - - public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException{ - setObject(parameterIndex, x, targetSqlType, -1); - } - - - public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException{ - DbParameter para = getPara(parameterIndex); - para.set_Value(JdbcOdbcUtils.convertJava2Net(x, scaleOrLength)); - if(para.get_Direction().Value == ParameterDirection.Output){ - para.set_Direction(ParameterDirection.wrap(ParameterDirection.InputOutput)); - } - - if(targetSqlType != Types.OTHER){ - para.set_DbType(DbType.wrap(JdbcOdbcUtils.convertJdbc2AdoNetType(targetSqlType))); - } - - if(scaleOrLength >= 0){ - switch(targetSqlType){ - case Types.DECIMAL: - case Types.NUMERIC: - para.set_Scale((byte)scaleOrLength); - } - } - } - - - public void setRef(int parameterIndex, Ref x) throws SQLException{ - setObject(parameterIndex, x, Types.REF); - } - - - public void setRowId(int parameterIndex, RowId x) throws SQLException{ - setObject(parameterIndex, x, Types.ROWID); - } - - - public void setSQLXML(int parameterIndex, SQLXML x) throws SQLException{ - setObject(parameterIndex, x, Types.SQLXML); - } - - - public void setShort(int parameterIndex, short x) throws SQLException{ - setObject(parameterIndex, Short.valueOf(x), Types.SMALLINT); - } - - - public void setString(int parameterIndex, String x) throws SQLException{ - setObject(parameterIndex, x, Types.VARCHAR); - } - - - public void setTime(int parameterIndex, Time x) throws SQLException{ - setObject(parameterIndex, x, Types.TIME); - } - - - public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException{ - JdbcOdbcUtils.convertCalendarToLocalDate(x, cal); - setObject(parameterIndex, x, Types.TIME); - } - - - public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException{ - setObject(parameterIndex, x, Types.TIMESTAMP); - } - - - public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException{ - JdbcOdbcUtils.convertCalendarToLocalDate(x, cal); - setObject(parameterIndex, x, Types.TIMESTAMP); - } - - - public void setURL(int parameterIndex, URL x) throws SQLException{ - setObject(parameterIndex, x, Types.DATALINK); - } - - - public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException{ - setObject(parameterIndex, x, Types.LONGNVARCHAR, length); - } - - - /** - * Get the DbParameter from the current command. If the parameter does not exits in the collection then add it. - * - * @param parameterIndex - * The JDBC parameter index starting with 1 - * @return the DbParameter for the index. - * @throws SQLException - * If any error occur. - */ - protected DbParameter getPara(int parameterIndex) throws SQLException{ - try{ - DbParameterCollection params = command.get_Parameters(); - while(params.get_Count() < parameterIndex){ - params.Add(command.CreateParameter()); - } - return params.get_Item(parameterIndex - 1); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcResultSet.java b/openjdk/sun/jdbc/odbc/JdbcOdbcResultSet.java deleted file mode 100644 index 398f368b..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcResultSet.java +++ /dev/null @@ -1,799 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.sql.*; - -import cli.System.Data.Common.*; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider. This ResultSet based on a DataReader. - */ -public class JdbcOdbcResultSet extends JdbcOdbcObject implements ResultSet{ - - private DbDataReader reader; - - private final JdbcOdbcStatement statement; - - private final int holdability; - - private final int concurrency; - - private int fetchSize; - - private int row; - - private final int resultSetType; - - private ResultSetMetaData metaData; - - - /** - * Create a ResultSet that based on a DbDataReader - * - * @param statement - * the statement for getStatement(), can be null - * @param reader - * the reader for the data access, if it null then the resultset is closed. - */ - public JdbcOdbcResultSet(JdbcOdbcStatement statement, DbDataReader reader){ - this.statement = statement; - this.reader = reader; - this.resultSetType = TYPE_FORWARD_ONLY; - this.concurrency = CONCUR_READ_ONLY; - this.holdability = HOLD_CURSORS_OVER_COMMIT; - } - - - /** - * A constructor for extended classes. All methods that use the reader must be overridden if you use this - * constructor. - * - * @param statement - * the statement for getStatement(), can be null - * @param resultSetType - * a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or - * ResultSet.TYPE_SCROLL_SENSITIVE - * @param concurrency - * a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE - */ - protected JdbcOdbcResultSet(JdbcOdbcStatement statement, int resultSetType, int concurrency){ - this.statement = statement; - this.reader = null; - this.resultSetType = resultSetType; - this.concurrency = concurrency; - this.holdability = HOLD_CURSORS_OVER_COMMIT; - } - - - public boolean absolute(int rowPosition) throws SQLException{ - throwForwardOnly(); - return false; // for Compiler - } - - - public void afterLast() throws SQLException{ - throwForwardOnly(); - } - - - public void beforeFirst() throws SQLException{ - throwForwardOnly(); - } - - - public void cancelRowUpdates() throws SQLException{ - throwReadOnly(); - } - - - public void clearWarnings() throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void close(){ - reader = null; - statement.closeReaderIfPossible(); - } - - - public void deleteRow() throws SQLException{ - throwReadOnly(); - } - - - @Override - public int findColumn(String columnLabel) throws SQLException{ - try{ - return getReader().GetOrdinal(columnLabel) + 1; - }catch(ArrayIndexOutOfBoundsException ex){ - throw new SQLException("Column '" + columnLabel + "' not found.", "S0022", ex); - } - } - - - public boolean first() throws SQLException{ - throwForwardOnly(); - return false; // for compiler - } - - - public int getConcurrency(){ - return concurrency; - } - - - public String getCursorName() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public int getFetchDirection(){ - return FETCH_UNKNOWN; - } - - - public int getFetchSize(){ - return fetchSize; - } - - - public int getHoldability(){ - return holdability; - } - - - public ResultSetMetaData getMetaData() throws SQLException{ - if(metaData == null){ - metaData = new JdbcOdbcResultSetMetaData(getReader()); - } - return metaData; - } - - - public int getRow() throws SQLException{ - getReader(); // checking for is closed - return row; - } - - - public Statement getStatement(){ - return statement; - } - - - public int getType(){ - return resultSetType; - } - - - public SQLWarning getWarnings() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public void insertRow() throws SQLException{ - throwReadOnly(); - } - - - public boolean isAfterLast() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public boolean isBeforeFirst() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public boolean isClosed(){ - return reader == null; - } - - - public boolean isFirst() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public boolean isLast() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public boolean last() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public void moveToCurrentRow() throws SQLException{ - throwReadOnly(); - } - - - public void moveToInsertRow() throws SQLException{ - throwReadOnly(); - } - - - public boolean next() throws SQLException{ - DbDataReader dataReader = getReader(); - //if we after the last row then we close the reader - //to prevent an error on repeating call of next() after the end - //that we check also get_IsClosed() - if(!dataReader.get_IsClosed() && dataReader.Read()){ - row++; - return true; - } - row = 0; - statement.closeReaderIfPossible(); - return false; - } - - - public boolean previous() throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public void refreshRow() throws SQLException{ - throwForwardOnly(); - } - - - public boolean relative(int rowPositions) throws SQLException{ - throwForwardOnly(); - return false; // only for compiler - } - - - public boolean rowDeleted() throws SQLException{ - throwReadOnly(); - return false; // only for compiler - } - - - public boolean rowInserted() throws SQLException{ - throwReadOnly(); - return false; // only for compiler - } - - - public boolean rowUpdated() throws SQLException{ - throwReadOnly(); - return false; // only for compiler - } - - - public void setFetchDirection(int direction){ - // ignore it - } - - - public void setFetchSize(int rows){ - // ignore it - } - - - public void updateArray(int columnIndex, Array x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateArray(String columnLabel, Array x) throws SQLException{ - updateArray(findColumn(columnLabel), x); - } - - - public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException{ - updateObject(columnIndex, x, length); - } - - - public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException{ - updateObject(findColumn(columnLabel), x, length); - } - - - public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException{ - updateObject(columnIndex, x, length); - } - - - public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException{ - updateObject(findColumn(columnLabel), x, length); - } - - - public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateBlob(int columnIndex, Blob x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateBlob(String columnLabel, Blob x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateBlob(int columnIndex, InputStream x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateBlob(String columnLabel, InputStream x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateBlob(int columnIndex, InputStream x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateBlob(String columnLabel, InputStream x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateBoolean(int columnIndex, boolean x) throws SQLException{ - updateObject(columnIndex, Boolean.valueOf(x)); - } - - - public void updateBoolean(String columnLabel, boolean x) throws SQLException{ - updateObject(findColumn(columnLabel), Boolean.valueOf(x)); - } - - - public void updateByte(int columnIndex, byte x) throws SQLException{ - updateObject(columnIndex, Byte.valueOf(x)); - } - - - public void updateByte(String columnLabel, byte x) throws SQLException{ - updateObject(findColumn(columnLabel), Byte.valueOf(x)); - } - - - public void updateBytes(int columnIndex, byte[] x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateBytes(String columnLabel, byte[] x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException{ - updateObject(columnIndex, x, length); - } - - - public void updateCharacterStream(String columnLabel, Reader x, int length) throws SQLException{ - updateObject(findColumn(columnLabel), x, length); - } - - - public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateCharacterStream(String columnLabel, Reader x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateCharacterStream(int columnIndex, Reader x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateCharacterStream(String columnLabel, Reader x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateClob(int columnIndex, Clob x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateClob(String columnLabel, Clob x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateClob(int columnIndex, Reader x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateClob(String columnLabel, Reader x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateClob(int columnIndex, Reader x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateClob(String columnLabel, Reader x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateDate(int columnIndex, Date x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateDate(String columnLabel, Date x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateDouble(int columnIndex, double x) throws SQLException{ - updateObject(columnIndex, Double.valueOf(x)); - } - - - public void updateDouble(String columnLabel, double x) throws SQLException{ - updateObject(findColumn(columnLabel), Double.valueOf(x)); - } - - - public void updateFloat(int columnIndex, float x) throws SQLException{ - updateObject(columnIndex, Float.valueOf(x)); - } - - - public void updateFloat(String columnLabel, float x) throws SQLException{ - updateObject(findColumn(columnLabel), Float.valueOf(x)); - } - - - public void updateInt(int columnIndex, int x) throws SQLException{ - updateObject(columnIndex, Integer.valueOf(x)); - } - - - public void updateInt(String columnLabel, int x) throws SQLException{ - updateObject(findColumn(columnLabel), Integer.valueOf(x)); - } - - - public void updateLong(int columnIndex, long x) throws SQLException{ - updateObject(columnIndex, Long.valueOf(x)); - } - - - public void updateLong(String columnLabel, long x) throws SQLException{ - updateObject(findColumn(columnLabel), Long.valueOf(x)); - } - - - public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateNCharacterStream(String columnLabel, Reader x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateNCharacterStream(String columnLabel, Reader x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateNClob(int columnIndex, NClob x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateNClob(String columnLabel, NClob x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateNClob(int columnIndex, Reader x, long length) throws SQLException{ - updateObject(columnIndex, x, (int)length); - } - - - public void updateNClob(String columnLabel, Reader x, long length) throws SQLException{ - updateObject(findColumn(columnLabel), x, (int)length); - } - - - public void updateNClob(int columnIndex, Reader x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateNClob(String columnLabel, Reader x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateNString(int columnIndex, String x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateNString(String columnLabel, String x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateNull(int columnIndex) throws SQLException{ - updateObject(columnIndex, null); - } - - - public void updateNull(String columnLabel) throws SQLException{ - updateObject(findColumn(columnLabel), null); - } - - - public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException{ - throwReadOnly(); - } - - - public void updateObject(int columnIndex, Object x) throws SQLException{ - updateObject(columnIndex, x, -1); - } - - - public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException{ - updateObject(findColumn(columnLabel), x, scaleOrLength); - } - - - public void updateObject(String columnLabel, Object x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateRef(int columnIndex, Ref x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateRef(String columnLabel, Ref x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateRow() throws SQLException{ - throwReadOnly(); - } - - - public void updateRowId(int columnIndex, RowId x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateRowId(String columnLabel, RowId x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateShort(int columnIndex, short x) throws SQLException{ - updateObject(columnIndex, Short.valueOf(x)); - } - - - public void updateShort(String columnLabel, short x) throws SQLException{ - updateObject(findColumn(columnLabel), Short.valueOf(x)); - } - - - public void updateString(int columnIndex, String x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateString(String columnLabel, String x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateTime(int columnIndex, Time x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateTime(String columnLabel, Time x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException{ - updateObject(columnIndex, x); - } - - - public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException{ - updateObject(findColumn(columnLabel), x); - } - - - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - - private void throwForwardOnly() throws SQLException{ - throw new SQLException("ResultSet is forward only.", "24000"); - } - - - private void throwReadOnly() throws SQLException{ - throw new SQLException("ResultSet is read only.", "24000"); - } - - - /** - * Check if this ResultSet is closed before access to the DbDataReader - * - * @return - * @throws SQLException - */ - private DbDataReader getReader() throws SQLException{ - if(reader == null){ - throw new SQLException("ResultSet is closed.", "24000"); - } - return reader; - } - - - /** - * {@inheritDoc} - */ - @Override - protected Object getObjectImpl(int columnIndex) throws SQLException{ - try{ - DbDataReader datareader = getReader(); - try{ - return datareader.get_Item(columnIndex-1); - }catch(ArrayIndexOutOfBoundsException aioobe){ - throw new SQLException( "Invalid column number ("+columnIndex+"). A number between 1 and "+datareader.get_FieldCount()+" is valid.", "S1002", aioobe); - } - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - /** - * {@inheritDoc} - */ - public <T> T getObject(int columnIndex, Class<T> type) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - - /** - * {@inheritDoc} - */ - public <T> T getObject(String columnLabel, Class<T> type) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java b/openjdk/sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java deleted file mode 100644 index a92fdaf1..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcResultSetMetaData.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import ikvm.lang.CIL; - -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Types; - -import cli.System.Convert; -import cli.System.DBNull; -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.OdbcType; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider. - */ -public class JdbcOdbcResultSetMetaData implements ResultSetMetaData{ - - private final DbDataReader reader; - - private final DataTable schema; - - JdbcOdbcResultSetMetaData(DbDataReader reader){ - this.reader = reader; - schema = reader.GetSchemaTable(); - } - - public String getCatalogName(int column) throws SQLException{ - Object obj = getColumnMeta(column, "BaseCatalogName"); - if(obj == null || obj == DBNull.Value){ - return ""; - } - return obj.toString(); - } - - - public String getColumnClassName(int column) throws SQLException{ - String type = getColumnMeta(column, "DataType").toString(); - return JdbcOdbcUtils.getJavaClassName(type); - } - - - public int getColumnCount(){ - return schema.get_Rows().get_Count(); - } - - - public int getColumnDisplaySize(int column) throws SQLException{ - int precision = getPrecision(column); - int type = CIL.unbox_int( getColumnMeta(column, "ProviderType") ); - switch(type){ - case OdbcType.Decimal: - case OdbcType.Numeric: - return precision + (getScale(column) > 0 ? 2 : 1); // + sign and comma - } - return precision; - } - - - public String getColumnLabel(int column) throws SQLException{ - return getColumnMeta(column, "ColumnName").toString(); - } - - - public String getColumnName(int column) throws SQLException{ - return getColumnMeta(column, "ColumnName").toString(); - } - - - public int getColumnType(int column) throws SQLException{ - int type = CIL.unbox_int( getColumnMeta(column, "ProviderType") ); - switch(type){ - case OdbcType.VarChar: - return Types.VARCHAR; - case OdbcType.Char: - return Types.CHAR; - case OdbcType.Binary: - case OdbcType.Timestamp: - return Types.BINARY; - case OdbcType.Bit: - return Types.BOOLEAN; - case OdbcType.TinyInt: - return Types.TINYINT; - case OdbcType.Date: - return Types.DATE; - case OdbcType.DateTime: - case OdbcType.SmallDateTime: - return Types.TIMESTAMP; - case OdbcType.Decimal: - return Types.DECIMAL; - case OdbcType.Double: - return Types.DOUBLE; - case OdbcType.UniqueIdentifier: - return Types.ROWID; - case OdbcType.SmallInt: - return Types.SMALLINT; - case OdbcType.Int: - return Types.INTEGER; - case OdbcType.BigInt: - return Types.BIGINT; - case OdbcType.Real: - return Types.FLOAT; - case OdbcType.NVarChar: - return Types.NVARCHAR; - case OdbcType.NChar: - return Types.NCHAR; - case OdbcType.NText: - return Types.LONGNVARCHAR; - case OdbcType.Text: - return Types.LONGVARCHAR; - case OdbcType.Image: - return Types.LONGVARBINARY; - case OdbcType.Time: - return Types.TIME; - case OdbcType.Numeric: - return Types.NUMERIC; - case OdbcType.VarBinary: - return Types.VARBINARY; - } - return Types.OTHER; - } - - - public String getColumnTypeName(int column) throws SQLException{ - try{ - return reader.GetDataTypeName(column - 1); - }catch(ArrayIndexOutOfBoundsException ex){ - throw new SQLException("Invalid column number ("+column+"). A number between 1 and "+schema.get_Rows().get_Count()+" is valid.", "S1002"); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - public int getPrecision(int column) throws SQLException{ - Object obj = getColumnMeta(column, "NumericPrecision"); - return Convert.ToInt32(obj); - } - - - public int getScale(int column) throws SQLException{ - Object obj = getColumnMeta(column, "NumericScale"); - return Convert.ToInt32(obj); - } - - - public String getSchemaName(int column) throws SQLException{ - Object obj = getColumnMeta(column, "BaseSchemaName"); - if(obj == null || obj == DBNull.Value){ - return ""; - } - return obj.toString(); - } - - - public String getTableName(int column) throws SQLException{ - Object obj = getColumnMeta(column, "BaseTableName"); - if(obj == null || obj == DBNull.Value){ - return ""; - } - return obj.toString(); - } - - - public boolean isAutoIncrement(int column) throws SQLException{ - Object obj = getColumnMeta(column, "IsAutoIncrement"); - return Convert.ToBoolean(obj); - } - - - public boolean isCaseSensitive(int column){ - return false; - } - - - public boolean isCurrency(int column) throws SQLException{ - return CIL.unbox_int( getColumnMeta(column, "ProviderType") ) == OdbcType.Decimal && getScale(column) == 4; - } - - - public boolean isDefinitelyWritable(int column){ - return false; - } - - - public int isNullable(int column) throws SQLException{ - Object obj = getColumnMeta(column, "AllowDBNull"); - return Convert.ToBoolean(obj) ? columnNullable : columnNoNulls; - } - - - public boolean isReadOnly(int column) throws SQLException{ - Object obj = getColumnMeta(column, "IsReadOnly"); - return Convert.ToBoolean(obj); - } - - - public boolean isSearchable(int column) throws SQLException{ - return !CIL.unbox_boolean( getColumnMeta(column, "IsLong") ); - } - - - public boolean isSigned(int column) throws SQLException{ - int type = CIL.unbox_int( getColumnMeta(column, "ProviderType") ); - switch(type){ - case OdbcType.Numeric: - case OdbcType.Decimal: - case OdbcType.Double: - case OdbcType.SmallInt: - case OdbcType.Int: - case OdbcType.BigInt: - case OdbcType.Real: - return true; - } - return false; - } - - - public boolean isWritable(int column) throws SQLException{ - Object obj = getColumnMeta(column, "IsReadOnly"); - return !Convert.ToBoolean(obj); - } - - - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - private Object getColumnMeta(int column, String metaKey) throws SQLException{ - try{ - DataRow columnMeta = schema.get_Rows().get_Item(column-1); - return columnMeta.get_Item(metaKey); - }catch(ArrayIndexOutOfBoundsException ex){ - throw new SQLException("Invalid column number ("+column+"). A number between 1 and "+schema.get_Rows().get_Count()+" is valid.", "S1002"); - } - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcStatement.java b/openjdk/sun/jdbc/odbc/JdbcOdbcStatement.java deleted file mode 100644 index 358ae0e7..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcStatement.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - Copyright (C) 2009, 2011 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.sql.*; - -import cli.System.Data.*; -import cli.System.Data.Common.*; -import cli.System.Data.Odbc.*; - -/** - * This JDBC Driver is a wrapper to the ODBC.NET Data Provider. - */ -public class JdbcOdbcStatement implements Statement{ - - private final JdbcOdbcConnection jdbcConn; - - protected final OdbcCommand command; - - private final int resultSetType; - - private final int resultSetConcurrency; - - private DbDataReader reader; - - private ResultSet rs; - - private int updateCount; - - private boolean isClosed; - - private ResultSet moreResults; - - public JdbcOdbcStatement(JdbcOdbcConnection jdbcConn, OdbcCommand command, int resultSetType, int resultSetConcurrency){ - this.jdbcConn = jdbcConn; - this.command = command; - this.resultSetType = resultSetType; - this.resultSetConcurrency = resultSetConcurrency; - } - - - public void addBatch(String sql) throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void cancel() throws SQLException{ - try{ - command.Cancel(); - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - public void clearBatch() throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void clearWarnings() throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void close() throws SQLException{ - isClosed = true; - if(rs != null){ - rs.close(); - } - if(reader != null){ - reader.Close(); - } - command.Dispose(); - } - - - public boolean execute(String sql) throws SQLException{ - try{ - if(sql != null){ - command.set_CommandText(sql); - } - command.ExecuteNonQuery(); - return false; - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - public boolean execute(String sql, int autoGeneratedKeys){ - throw new UnsupportedOperationException(); - } - - - public boolean execute(String sql, int[] columnIndexes){ - throw new UnsupportedOperationException(); - } - - - public boolean execute(String sql, String[] columnNames){ - throw new UnsupportedOperationException(); - } - - - public int[] executeBatch() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public ResultSet executeQuery(String sql) throws SQLException{ - try{ - if(sql != null){ - command.set_CommandText(sql); - } - if(resultSetConcurrency == ResultSet.CONCUR_UPDATABLE){ - rs = new JdbcOdbcUpdateableResultSet(command); - }else{ - if(resultSetType == ResultSet.TYPE_FORWARD_ONLY){ - reader = command.ExecuteReader(); - rs = new JdbcOdbcResultSet(this, reader); - }else{ - OdbcDataAdapter da = new OdbcDataAdapter(command); - DataTable dt = new DataTable(); - da.Fill(dt); - rs = new JdbcOdbcDTResultSet(dt); - } - } - return rs; - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - public int executeUpdate(String sql) throws SQLException{ - try{ - if(sql != null){ - command.set_CommandText(sql); - } - updateCount = command.ExecuteNonQuery(); - return updateCount; - }catch(Throwable ex){ - throw JdbcOdbcUtils.createSQLException(ex); - } - } - - - public int executeUpdate(String sql, int autoGeneratedKeys){ - throw new UnsupportedOperationException(); - } - - - public int executeUpdate(String sql, int[] columnIndexes){ - throw new UnsupportedOperationException(); - } - - - public int executeUpdate(String sql, String[] columnNames){ - throw new UnsupportedOperationException(); - } - - - public Connection getConnection(){ - return jdbcConn; - } - - - public int getFetchDirection(){ - return ResultSet.FETCH_UNKNOWN; - } - - - public int getFetchSize(){ - return 0; - } - - - public ResultSet getGeneratedKeys(){ - throw new UnsupportedOperationException(); - } - - - public int getMaxFieldSize() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getMaxRows() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public boolean getMoreResults() throws SQLException{ - try{ - if(moreResults != null){ - rs = moreResults; - moreResults = null; - return true; - } - boolean isNext = reader.NextResult(); - if(isNext){ - rs = new JdbcOdbcResultSet(this, reader); - return true; - } - rs = null; - return false; - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - public boolean getMoreResults(int current) throws SQLException{ - // TODO Auto-generated method stub - return false; - } - - - public int getQueryTimeout(){ - return command.get_CommandTimeout(); - } - - - public ResultSet getResultSet(){ - return rs; - } - - - public int getResultSetConcurrency(){ - return resultSetConcurrency; - } - - - public int getResultSetHoldability() throws SQLException{ - // TODO Auto-generated method stub - return 0; - } - - - public int getResultSetType(){ - return resultSetType; - } - - - public int getUpdateCount(){ - return updateCount; - } - - - public SQLWarning getWarnings() throws SQLException{ - // TODO Auto-generated method stub - return null; - } - - - public boolean isClosed(){ - return isClosed; - } - - - public void setCursorName(String name) throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void setEscapeProcessing(boolean enable) throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void setFetchDirection(int direction){ - // ignore it - } - - - public void setFetchSize(int rows){ - // ignore it - } - - - public void setMaxFieldSize(int max) throws SQLException{ - // TODO Auto-generated method stub - - } - - - public void setMaxRows(int max) throws SQLException{ - // TODO Auto-generated method stub - - } - - - public boolean isPoolable(){ - return false; - } - - - public void setPoolable(boolean poolable) throws SQLException{ - // ignore it - } - - - public void setQueryTimeout(int seconds){ - command.set_CommandTimeout(seconds); - } - - - public boolean isWrapperFor(Class<?> iface){ - return iface.isAssignableFrom(this.getClass()); - } - - - public <T>T unwrap(Class<T> iface) throws SQLException{ - if(isWrapperFor(iface)){ - return (T)this; - } - throw new SQLException(this.getClass().getName() + " does not implements " + iface.getName() + ".", "01000"); - } - - /** - * Close the DbDataReader if there are no more results. - * This give some blocking free without calling close() explicit. - * If there are more results then we need to save it. - */ - void closeReaderIfPossible(){ - ResultSet currentRs = rs; - boolean isMoreResults; - try{ - isMoreResults = getMoreResults(); - }catch(SQLException ex){ - isMoreResults = false; - } - if(!isMoreResults){ - reader.Close(); //this give the ODBC cursor free - }else{ - moreResults = rs; - } - rs = currentRs; - } - - - /** - * {@inheritDoc} - */ - public void closeOnCompletion() throws SQLException { - } - - - /** - * {@inheritDoc} - */ - public boolean isCloseOnCompletion() throws SQLException { - return false; - } - -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcUpdateableResultSet.java b/openjdk/sun/jdbc/odbc/JdbcOdbcUpdateableResultSet.java deleted file mode 100644 index a3ce0ffe..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcUpdateableResultSet.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2009 Volker Berlin (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import java.sql.*; - -import cli.System.Data.*; -import cli.System.Data.Odbc.*; - -/** - * @author Volker Berlin - */ -public class JdbcOdbcUpdateableResultSet extends JdbcOdbcDTResultSet{ - - private final OdbcDataAdapter da; - - private final DataTable data; - - private DataRow insertRow; - - - public JdbcOdbcUpdateableResultSet(OdbcCommand cmd){ - this(new DataTable(), cmd); - } - - - private JdbcOdbcUpdateableResultSet(DataTable data, OdbcCommand cmd){ - super(data, CONCUR_UPDATABLE); - this.data = data; - da = new OdbcDataAdapter(cmd); - da.Fill(data); - OdbcCommandBuilder cmdBldr = new OdbcCommandBuilder(da); - cmdBldr.GetUpdateCommand(); // throw an exception if update is not possible, we want a very early exception - } - - - @Override - protected DataRow getDataRow() throws SQLException{ - if(insertRow != null){ - return insertRow; - } - return super.getDataRow(); - } - - - @Override - protected void setDataRow() throws SQLException{ - insertRow = null; - super.setDataRow(); - } - - - @Override - public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException{ - try{ - x = JdbcOdbcUtils.convertJava2Net(x, scaleOrLength); - getDataRow().set_Item(columnIndex - 1, x); - }catch(ArrayIndexOutOfBoundsException ex){ - throw new SQLException("Invalid column number (" + columnIndex + "). A number between 1 and " - + data.get_Columns().get_Count() + " is valid.", "S1002", ex); - } - } - - - @Override - public void updateRow() throws SQLException{ - if(insertRow != null){ - throw new SQLException("Cursor is on the insert row."); - } - try{ - da.Update(data); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public void deleteRow() throws SQLException{ - if(insertRow != null){ - throw new SQLException("Cursor is on the insert row."); - } - try{ - getDataRow().Delete(); // Delete the current row - da.Update(data); - setDataRow(); // set a new Current Row - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - } - - - @Override - public void insertRow() throws SQLException{ - if(insertRow == null){ - throw new SQLException("Cursor is not on the insert row."); - } - try{ - getRows().Add(insertRow); - insertRow = null; - da.Update(data); - last(); - }catch(Throwable th){ - throw JdbcOdbcUtils.createSQLException(th); - } - - } - - - @Override - public void moveToInsertRow(){ - insertRow = data.NewRow(); - } - - - @Override - public void moveToCurrentRow(){ - insertRow = null; - } - - - @Override - public void cancelRowUpdates() throws SQLException{ - getDataRow().CancelEdit(); - } - - - @Override - public boolean rowDeleted(){ - return false; - } - - - @Override - public boolean rowInserted(){ - return false; - } - - - @Override - public boolean rowUpdated(){ - return false; - } -} diff --git a/openjdk/sun/jdbc/odbc/JdbcOdbcUtils.java b/openjdk/sun/jdbc/odbc/JdbcOdbcUtils.java deleted file mode 100644 index c5497e30..00000000 --- a/openjdk/sun/jdbc/odbc/JdbcOdbcUtils.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - Copyright (C) 2009, 2010 Volker Berlin (i-net software) - Copyright (C) 2011 Karsten Heinrich (i-net software) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jeroen Frijters - jeroen@frijters.net - - */ -package sun.jdbc.odbc; - -import ikvm.lang.CIL; - -import java.math.BigDecimal; -import java.sql.*; -import java.util.Calendar; -import java.util.HashMap; - -import cli.System.DBNull; -import cli.System.TimeSpan; -import cli.System.Data.DbType; -import cli.System.Data.Common.DbException; -import cli.System.Data.Odbc.*; -import cli.System.Globalization.CultureInfo; - -/** - * @author Volker Berlin - */ -public class JdbcOdbcUtils{ - - private static final HashMap<String, String> classNameMap = new HashMap<String, String>(); - static{ - classNameMap.put("System.String", "java.lang.String"); - classNameMap.put("System.Int16", "java.lang.Short"); - classNameMap.put("System.Int32", "java.lang.Integer"); - classNameMap.put("System.Int64", "java.lang.Long"); - classNameMap.put("System.Double", "java.lang.Double"); - classNameMap.put("System.Decimal", "java.math.BigDecimal"); - classNameMap.put("System.DateTime", "java.sql.Timestamp"); - classNameMap.put("System.TimeSpan", "java.sql.Time"); - } - - - /** - * Solve a mapping between .NET class names and the equivalent Java class names for - * ResultSetMetaData.getColumnClassName - * - * @param netClassName - * the .NET class name - * @return the Java class name - */ - public static String getJavaClassName(String netClassName){ - String javaClassName = classNameMap.get(netClassName); - if(javaClassName != null){ - return javaClassName; - } - return "java.lang.Object"; - } - - - /** - * Convert a .NET Object in the equals Java Object. - * - * @param obj - * the .NET Object - * @return a Java Object - */ - public static java.lang.Object convertNet2Java(java.lang.Object obj){ - if(obj instanceof cli.System.Int64){ - return Long.valueOf(CIL.unbox_long(obj)); - } - if(obj instanceof cli.System.Int32){ - return Integer.valueOf(CIL.unbox_int(obj)); - } - if(obj instanceof cli.System.Int16){ - return Short.valueOf(CIL.unbox_short(obj)); - } - if(obj instanceof cli.System.Byte){ - return Byte.valueOf(CIL.unbox_byte(obj)); - } - if(obj instanceof cli.System.Double){ - return Double.valueOf(CIL.unbox_double(obj)); - } - if(obj instanceof cli.System.Single){ - return Float.valueOf(CIL.unbox_float(obj)); - } - if(obj instanceof cli.System.Boolean){ - return Boolean.valueOf(CIL.unbox_boolean(obj)); - } - if(obj instanceof cli.System.Decimal){ - return new BigDecimal(((cli.System.Decimal)obj).ToString(CultureInfo.get_InvariantCulture())); - } - if(obj instanceof cli.System.DateTime){ - return convertDateTimeToTimestamp((cli.System.DateTime)obj); - } - if(obj instanceof cli.System.TimeSpan){ - cli.System.TimeSpan ts = (cli.System.TimeSpan)obj; - return new Time(ts.get_Hours(), ts.get_Minutes(), ts.get_Seconds()); - } - if(obj instanceof cli.System.DBNull){ - return null; - } - return obj; - } - - /** - * Converts a .NET DateTime to a Timestamp in the current Timezone - * @param obj the dateTime - * @return the conveted time stamp - */ - public static Timestamp convertDateTimeToTimestamp( cli.System.DateTime obj) { - long javaMillis = getJavaMillis(obj); - int seconds = (int)(javaMillis / 1000); - int nanos = (int)((javaMillis % 1000) * 1000000); - return new Timestamp( 70, 0, 1, 0, 0, seconds, nanos ); - } - - - /** - * Convert a Java Object in the equals .NET Object. - * - * @param obj - * Java Object - * @param length - * the length of data if obj is a stream - * @return .NET Object - */ - public static Object convertJava2Net(Object obj, int length){ - // TODO use the length with streams - return convertJava2Net(obj); - } - - - /** - * Convert a Java Object in the equals .NET Object. - * - * @param obj - * Java Object - * @return a .NET Object - */ - public static Object convertJava2Net(Object obj){ - if(obj == null){ - return DBNull.Value; - } - if(obj instanceof Double){ - return CIL.box_double(((Double)obj).doubleValue()); - } - if(obj instanceof Float){ - return CIL.box_float(((Float)obj).floatValue()); - } - if(obj instanceof Long){ - return CIL.box_long(((Long)obj).longValue()); - } - if(obj instanceof Integer){ - return CIL.box_int(((Integer)obj).intValue()); - } - if(obj instanceof Short){ - return CIL.box_short(((Short)obj).shortValue()); - } - if(obj instanceof Byte){ - return CIL.box_byte(((Byte)obj).byteValue()); - } - if(obj instanceof Boolean){ - return CIL.box_boolean(((Boolean)obj).booleanValue()); - } - if(obj instanceof Time){ - Time ts = (Time)obj; - return new TimeSpan(ts.getHours(), ts.getMinutes(), ts.getSeconds()); - } - if(obj instanceof java.util.Date){ - long ticks = getNetTicks((java.util.Date)obj); - return new cli.System.DateTime(ticks); - } - if(obj instanceof BigDecimal){ - return cli.System.Decimal.Parse(obj.toString(), CultureInfo.get_InvariantCulture()); - } - return obj; - } - - - /** - * Get the milliseconds in the Java range from a .NET DateTime object. - * - * @param dt - * the DateTime object - * @return the milliseconds since 1970-01-01 - */ - public static long getJavaMillis(cli.System.DateTime dt){ - // calculation copied from System.currentTimeMillis() - long january_1st_1970 = 62135596800000L; - return dt.get_Ticks() / 10000L - january_1st_1970; - } - - - /** - * Get the ticks for a System.DateTime from a java.util.Date - * - * @param date - * the java.util.Date - * @return ticks - */ - public static long getNetTicks(java.util.Date date){ - // inverse from getJavaMillis - long january_1st_1970 = 62135596800000L; - return (date.getTime() + january_1st_1970) * 10000L; - } - - - /** - * Convert a local (current default) Date to a Date in the time zone of the given calendar. Do nothing if date or - * calendar is null. - * - * @param date - * the converting Date - * @param cal - * the Calendar with the time zone - */ - public static void convertLocalToCalendarDate(java.util.Date date, Calendar cal){ - if(date == null || cal == null){ - return; - } - cal.set(date.getYear() + 1900, date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date - .getSeconds()); - long millis = cal.getTimeInMillis() / 1000 * 1000 + date.getTime() % 1000; - date.setTime(millis); - } - - - /** - * Convert a Date in the calendar time zone to a date in the local (current default) time zone. Do nothing if date - * or calendar is null. - * - * @param date - * @param cal - */ - public static void convertCalendarToLocalDate(java.util.Date date, Calendar cal){ - if(date == null || cal == null){ - return; - } - cal.setTimeInMillis(date.getTime()); - date.setYear(cal.get(Calendar.YEAR) - 1900); - date.setMonth(cal.get(Calendar.MONTH)); - date.setDate(cal.get(Calendar.DAY_OF_MONTH)); - date.setHours(cal.get(Calendar.HOUR_OF_DAY)); - date.setMinutes(cal.get(Calendar.MINUTE)); - date.setSeconds(cal.get(Calendar.SECOND)); - } - - - /** - * The only valid Exception for JDBC is a SQLException. Here we create one based on the real exception. - * - * @param th - * any Throwable that occur - * @return a SQLException, never null - */ - public static SQLException createSQLException(Throwable th){ - if(th instanceof SQLException){ - return (SQLException)th; - } - if(th instanceof OdbcException){ - SQLException sqlEx = null; - OdbcErrorCollection errors = ((OdbcException)th).get_Errors(); - for(int e = 0; e < errors.get_Count(); e++){ - OdbcError err = errors.get_Item(e); - SQLException newEx = new SQLException(err.get_Message(), err.get_SQLState(), err.get_NativeError()); - if(sqlEx == null){ - sqlEx = newEx; - }else{ - sqlEx.setNextException(newEx); - } - } - if(sqlEx != null){ - sqlEx.initCause(th); - return sqlEx; - } - } - if(th instanceof DbException){ - DbException dbEx = (DbException)th; - return new SQLException(dbEx.get_Message(), "S1000", dbEx.get_ErrorCode(), th); - } - return new SQLException(th); - } - - - /** - * Convert a value from java.sql.Types to a value from to a System.Data.DbType - * - * @param type - * a JDBC type - * @return a ADO.NET type - * @throws SQLException - * if the type can not be converted - */ - public static int convertJdbc2AdoNetType(int type) throws SQLException{ - switch(type){ - case Types.BIGINT: - return DbType.Int64; - case Types.BINARY: - case Types.BLOB: - case Types.LONGVARBINARY: - case Types.VARBINARY: - return DbType.Binary; - case Types.BIT: - case Types.BOOLEAN: - return DbType.Boolean; - case Types.CHAR: - return DbType.AnsiStringFixedLength; - case Types.CLOB: - case Types.DATALINK: - case Types.LONGVARCHAR: - case Types.NULL: // we hope that the DBMS can map any NULL values from VARCHAR - case Types.VARCHAR: - return DbType.AnsiString; - case Types.DATE: - return DbType.Date; - case Types.DECIMAL: - case Types.NUMERIC: - return DbType.Decimal; - case Types.DOUBLE: - return DbType.Double; - case Types.FLOAT: - case Types.REAL: - return DbType.Single; - case Types.INTEGER: - return DbType.Int32; - case Types.JAVA_OBJECT: - return DbType.Object; - case Types.LONGNVARCHAR: - case Types.NCLOB: - case Types.NVARCHAR: - return DbType.String; - case Types.NCHAR: - return DbType.StringFixedLength; - case Types.ROWID: - return DbType.Guid; - case Types.SMALLINT: - return DbType.Int16; - case Types.SQLXML: - return DbType.Xml; - case Types.TIME: - return DbType.Time; - case Types.TIMESTAMP: - return DbType.DateTime; - case Types.TINYINT: - return DbType.Byte; - case Types.ARRAY: - case Types.DISTINCT: - case Types.OTHER: - case Types.REF: - case Types.STRUCT: - break; - - } - throw new SQLException("Not supported JDBC type:" + type); - } -} |