[freetds] problem with the driver
web guy
web-guy01 at attbi.com
Mon Jan 6 22:08:01 EST 2003
Fahad,
Part, or perhaps all, of your problem may be caused by using the
wrong method. If recid is numeric, you should use getInt not
getString. So try this line:
int rec_id = rs.getInt("recid");
Tim
----- Original Message -----
From: Fahad Javed
To: freetds at lists.ibiblio.org
Sent: Thursday, January 02, 2003 4:22 PM
Subject: [freetds] problem with the driver
I have a simple script that runs on Unix and accesses MS SQL Server. The problem I'm having is that I cannot read numeric defined datatypes. I received the following error:
com.internetcds.jdbc.tds.TdsConfused: Protocol confusion- Was expecting a lengt5
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at com.internetcds.jdbc.tds.TdsException.<init>(TdsException.java:52)
at com.internetcds.jdbc.tds.TdsConfused.<init>(TdsConfused.java:46)
at com.internetcds.jdbc.tds.Tds.getDecimalValue(Compiled Code)
at com.internetcds.jdbc.tds.Tds.getRow(Compiled Code)
at com.internetcds.jdbc.tds.Tds.processSubPacket(Compiled Code)
at com.internetcds.jdbc.tds.ResultSet_base.next(Compiled Code)
at jdbc.main(Compiled Code)
Got an exception!
Protocol confusion- Was expecting a length of 17, got 5
Here are the column defs:
Name DataType Length Value
--------------------------------------------------------------------------------------
recid numeric 18,0 12345678901
account varchar 50 00100101
Heres the script:
java.sql.Connection conn = DriverManager.getConnection(url, usr, pswd);
java.sql.Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT recid, account FROM some_table");
while ( rs.next() ) {
String rec_id = rs.getString("recid");
String acct = rs.getString("account");
System.out.println("Record Id: " + rec_id);
System.out.println("Account: " + acct.trim());
}
conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
I get this message even if I don't set rec_id variable and ignore recid.
If I remove recid from Select, script executes without error........
Can you help me with that
Thanks
Fahad Javed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ibiblio.org/pipermail/freetds/attachments/20030106/d2f295bd/attachment.htm
More information about the FreeTDS
mailing list