Skip to Content.
Sympa Menu

freetds - RE: [freetds] FreeTds JDBC driver

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] FreeTds JDBC driver
  • Date: Thu, 19 Jun 2003 14:34:25 +0100

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




  • [freetds] FreeTds JDBC driver, Eyal Yekutiel, 06/19/2003
    • <Possible follow-up(s)>
    • RE: [freetds] FreeTds JDBC driver, Thompson, Bill D (London), 06/19/2003

Archive powered by MHonArc 2.6.24.

Top of Page