JDBC-ODBC does not work for long datatypes using prepared statements
Suren Babu
Greenhorn
Joined: Oct 23, 2000
Posts: 27
posted
0
Database: MS SQL 2000 Platform: Windows 2000 sp2, Windows NT sp6a Protocol to DB: TCPIP JDBC-ODBC does not work for long datatypes using prepared statements. I use sample database pubs for this. I have a created table called base... create table base ( id$ bigint, name varchar(80) ) where i inserted couple of rows with id$ containing values ranging from 2^8, 2^16, 2^31, 2^32, 2^63. Executing the following code for id$ values less than 2^31 works fine. Exceeding that range didn't return me any rows even though i have rows in table. Here is the code... import java.sql.*; import java.io.*; public class TestJDBCODBC { Connection conn = null ; long rowCnt = 0; public TestJDBCODBC( String args[] ) throws Exception { rowCnt = Long.parseLong( args[0] ) ;
public void testSampleDB() throws Exception { System.out.println("testSampleDB"); s //String Query = "SELECT rowcnt FrOM sysindexes where rowcnt=?"; String Query = "SELECT id$, name FrOM base where id$=?";
Correct, it doesn't work for get/setLong etc. Use get/setString for all your calls instead. I'm pretty sure this has worked me in the past. Dave.
Suren Babu
Greenhorn
Joined: Oct 23, 2000
Posts: 27
posted
0
Thanks a lot Dave ... Need some more clarifications regarding this... 1\ Moving setLong to setString works for all databases?. Our product supports Sybase, Oracle , MSSQL. 2\ Any idea how reliable is Sun's JDBC-ODBC Driver. Shall we go ahead with this for product based development. 3\ Do you know any URLs which has all the known issues / defects in Sun's JDBC-ODBC bridge. Thanks