You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by "Martin Kalén (JIRA)" <ji...@apache.org> on 2005/04/20 23:48:25 UTC

[jira] Commented: (OJB-26) JDBC-ODBC bridge problem

     [ http://issues.apache.org/jira/browse/OJB-26?page=comments#action_63325 ]
     
Martin Kalén commented on OJB-26:
---------------------------------

If using an RsIterator (as the SequenceManagerHighLowImpl will do), OJB will start by retrieving the columns from the ResultSet that are part of the primary key.

This is done by calling readPkValuesFrom in RsIterator#getObjectFromResultSet.

In this case there is a non-composite primary key consisting of the "tableName" attribute, ie the "A0.TABLENAME" in your SQL.

Is there a MS SQL-server problem with populating a ResultSet with:
 SELECT A0.VERSION,A0.MAX_KEY,A0.GRAB_SIZE,A0.TABLENAME,A0.FIELDNAME FROM OJB_HL_SEQ A0 WHERE A0.TABLENAME = ?

 followed by rs.getString(4)?

I would assume this is a generic MS SQL issue, not a JDBC-ODBC bridge problem?

Please check the MS SQL type of the fields _before_ field #4 and comment back on this issue, if one of those types are "magic" there can be ResultSet restrictions on the order in which data can be read. (Binary and/or unique identity type fields are prone to have this sort of constraint.)


> JDBC-ODBC bridge problem
> ------------------------
>
>          Key: OJB-26
>          URL: http://issues.apache.org/jira/browse/OJB-26
>      Project: OJB
>         Type: Bug
>   Components: PB-API
>     Versions: 1.0.3
>  Environment: ODBC (MDAC 2.8)
> JDBC-ODBC bridge
> SQL Server
>     Reporter: Viet Kévin
>     Priority: Blocker

>
> Hi, 
> OJB is not compatible with JDBC-ODBC Bridge.
> ODBC complains about an "invalid descriptor index" when accessing data from a ResultSet.
> It seems that the order used to access the ResultSet data is not the same as the one used to create the SQL query.
> ex :
> SELECT col1, col2, col3 FROM table;
> => ojb is trying to read col3 then odbc fails;
> Can OJB developpers fill me with some JDBC driver type 2 or type 3
> that are compatible with OJB 1.0.1 to 1.0.3 ?
> Here is the log trace from jdbc-odbc bridge :
> *Connection.prepareStatement (SELECT A0.VERSION,A0.MAX_KEY,A0.GRAB_SIZE,A0.TABLENAME,A0.FIELDNAME FROM OJB_HL_SEQ A0 WHERE A0.TABLENAME = ?)
> Allocating Statement Handle (SQLAllocStmt), hDbc=431038872
> hStmt=431039416
> Setting statement option (SQLSetStmtOption), hStmt=431039416, fOption=6, vParam=0
> Setting statement option (SQLSetStmtOption), hStmt=431039416, fOption=7, vParam=1
> Preparing (SQLPrepare), hStmt=431039416, szSqlStr=SELECT A0.VERSION,A0.MAX_KEY,A0.GRAB_SIZE,A0.TABLENAME,A0.FIELDNAME FROM OJB_HL_SEQ A0 WHERE A0.TABLENAME = ?
> Number of parameter markers (SQLNumParams), hStmt=431039416
> value=1
> Registering Statement sun.jdbc.odbc.JdbcOdbcPreparedStatement@15b28d8
> Binding IN string parameter (SQLBindParameter), hStmt=431039416, ipar=1, SQLtype=12, precision=8000, scale=0, rgbValue=[B@1b4df9c
> *PreparedStatement.executeQuery
> *PreparedStatement.execute
> Free statement (SQLFreeStmt), hStmt=431039416, fOption=0
> Executing (SQLExecute), hStmt=431039416
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> Fetching (SQLFetch), hStmt=431039416
> *ResultSet.getMetaData
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> *ResultSetMetaData.getColumnName (1)
> Column attributes (SQLColAttributes), hStmt=431039416, icol=1, type=1
> value (String)=VERSION
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> *ResultSetMetaData.getColumnName (2)
> Column attributes (SQLColAttributes), hStmt=431039416, icol=2, type=1
> value (String)=MAX_KEY
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> *ResultSetMetaData.getColumnName (3)
> Column attributes (SQLColAttributes), hStmt=431039416, icol=3, type=1
> value (String)=GRAB_SIZE
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> *ResultSetMetaData.getColumnName (4)
> Column attributes (SQLColAttributes), hStmt=431039416, icol=4, type=1
> value (String)=TABLENAME
> Number of result columns (SQLNumResultCols), hStmt=431039416
> value=5
> *ResultSetMetaData.getColumnName (5)
> Column attributes (SQLColAttributes), hStmt=431039416, icol=5, type=1
> value (String)=FIELDNAME
> Column attributes (SQLColAttributes), hStmt=431039416, icol=5, type=2
> value (int)=12
> Column attributes (SQLColAttributes), hStmt=431039416, icol=5, type=3
> value (int)=70
> Get string data (SQLGetData), hStmt=431039416, column=5, maxLen=71
> deprecatedColumn
> Column attributes (SQLColAttributes), hStmt=431039416, icol=4, type=2
> value (int)=12
> Column attributes (SQLColAttributes), hStmt=431039416, icol=4, type=3
> value (int)=175
> Get string data (SQLGetData), hStmt=431039416, column=4, maxLen=176
> RETCODE = -1
> ERROR - Generating SQLException...
> SQLException: SQLState(S1002) vendor code(0)
> java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]invalid descriptor index
> 	at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
> 	at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
> 	at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
> 	at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
> 	at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
> 	at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
> 	at org.apache.ojb.broker.util.JdbcTypesHelper$T_Varchar.readValueFromResultSet(Unknown Source)
> 	at org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectFromColumn(Unknown Source)
> 	at org.apache.ojb.broker.util.JdbcTypesHelper$BaseType.getObjectFromColumn(Unknown Source)
> 	at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readValuesFrom(Unknown Source)
> 	at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readPkValuesFrom(Unknown Source)
> 	at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source)
> 	at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
> 	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source)
> 	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source)
> 	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source)
> 	at org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.lookupStoreSequence(Unknown Source)
> 	at org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.getSequence(Unknown Source)
> 	at org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.getUniqueLong(Unknown Source)
> 	at org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueValue(Unknown Source)
> 	at org.apache.ojb.broker.util.BrokerHelper.setAutoIncrementValue(Unknown Source)
> 	at org.apache.ojb.broker.util.BrokerHelper.getValuesForObject(Unknown Source)
> 	at org.apache.ojb.broker.util.BrokerHelper.getKeyValues(Unknown Source)
> 	at org.apache.ojb.broker.Identity.init(Unknown Source)
> 	at org.apache.ojb.broker.Identity.<init>(Unknown Source)
> 	at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
> 	at com.is2france.framework.middleware.services.IssosPersistenceBrokerImpl.store(IssosPersistenceBrokerImpl.java:52)
> 	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)
> 	at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)
> ....
> /* business code  */
> ....
> *ResultSet.close
> N.B: this trace occurs when ojb is trying to retrieve a new id from the sequence generator table. But it happens on the rest of application.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org