db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viet Kévin (JIRA) <j...@apache.org>
Subject [jira] Commented: (OJB-26) JDBC-ODBC bridge problem
Date Tue, 26 Apr 2005 08:00:27 GMT
     [ http://issues.apache.org/jira/browse/OJB-26?page=comments#action_63756 ]
     
Viet Kévin commented on OJB-26:
-------------------------------

Hi Martin, thanx for your move.

The fact is that I've tried what you're talking about (sql query) outside OJB with a JDBC
call.

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); throws the same exception that I've reported previously (Invalid
descriptor index).

Googlized this exception and I could read that this problem probably occurs in ODBC. (ODBC
resultSets are not very sympathics ... ).
It sounds strange for me that those resultSet are so restrictive !

Also, we've tried to use a JDBC Type 4 driver (JTDS), there is no problem with the application.
(in fact we wish to use it, but ours customers environment forced us to use the JDBC-ODBC
bridge)

By the way, OJB was compatible with this bridge in the 1.0 RC6 release. Maybe you have changed
the way of building your queries and the resultSet reading.

For the moment, we use a rather dangerous solution, we have wrapped the JDBC-ODBC bridge by
proxying Connection, *Statement, ResultSet. 
When OJB queries our ResultSet we queries the proxied ResultSet (in the right order!) and
cache the data in a map which serve OJB.
This is a Temporary Solution.

Is it possible that OJB creates sql queries and get the data from resultSet in the same order
?
I think that it can be achevied by keeping the field descriptors order in the repository.xml
. 
We have already tried to reorder our repository.xml but unfortunatelly all combination fails.
Or maybe we are misunderstanding the way we can order it.

Please, give me our feelings about my comments.

Thanx again
VIET Kévin


> 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


Mime
View raw message