[freetds] FreeTds JDBC driver

Thompson, Bill D (London) ThompBil at exchange.uk.ml.com
Thu Jun 19 09:34:25 EDT 2003


Hi Eyal,

I've never looked at the JDBC driver code - I don't even know where the code
is...but the problem looks familiar.

The handling of numeric datatypes in the TDS protocol (not just in freeTDS,
but the sybase and Microsoft versions too) has a history to it.
Earlier versions of the TDS protocol didn't handle numeric data at all. I'm
not sure if TDS 4.2 falls into that category but I think it may...
I also believe that in some versions of the protcol, numeric data came down
the wire as a fixed number of bytes (17, actually).
In TDS 7, which Microsoft SQL server 7 will talk, the length of numeric data
is variable, depending upon the precision & scale of the numeric column.
I suspect the JDBC driver code harks back to a time when the length of a
numeric column was fixed....but that's just a guess.
If you made the precision and scale of the numeric column default (to (38,8)
I believe) , that may generate the 17 byte numeric that the jdbc code seems
to be expecting...

Hope this helps,

Bill


> -----Original Message-----
> From:	Eyal Yekutiel [SMTP:eyal at e4x.com]
> Sent:	19 June 2003 14:17
> To:	freetds at lists.ibiblio.org
> Subject:	[freetds] FreeTds JDBC driver
> 
> Hi all,
> 
> I send this email to you , cause I can't find reference anywhere to my
> problem.
> 
> I use FreeTds JDBC Driver to connect MS SQL Server 7.0 from my Java
> Application .
> 
> When I try to select Numeric column from a table, I get an exception when
> trying to call ResultSet.next() .
> Thats before I try to get any value.
> 
> Please advise what am I doing wrong
> Thanks in advance
> Eyal
> 
> The exception I get is :
> com.internetcds.jdbc.tds.TdsConfused: Protocol confusion- Was expecting a
> length of 17, got 9
> 	at com.internetcds.jdbc.tds.Tds.getDecimalValue(Tds.java:909)
> 	at com.internetcds.jdbc.tds.Tds.getRow(Tds.java:1139)
> 	at com.internetcds.jdbc.tds.Tds.processSubPacket(Tds.java:717)
> 	at
> com.internetcds.jdbc.tds.ResultSet_base.next(ResultSet_base.java:735)
> 	at e4x.test.DBTest.queryDB(DBTest.java:67)
> 	at e4x.test.DBTest.main(DBTest.java:147)
> 
> My code:
> 
>             Statement stmnt = null;
>             ResultSet rs = null;
>             try
>             {
>                 stmnt = conn.createStatement();
>                 rs = stmnt.executeQuery("Select Value from Quotes");
> 
>                 if (rs.next())
>                 {
>                     result = rs.getString(1);
>                 }
>             }
>             catch (Exception ex)
>             {
>                 ex.printStackTrace();
>             }
>             finally
>             {
>                 try
>                 {
>                     if (rs != null)
>                         rs.close();
>                 }
>                 catch (Exception ex)
>                 {
>                     ex.printStackTrace();
>                 }
> 
>                 try
>                 {
>                     if (stmnt != null)
>                         stmnt.close();
>                 }
>                 catch (Exception ex)
>                 {
>                     ex.printStackTrace();
>                 }
>             }
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds




More information about the FreeTDS mailing list