Skip to Content.
Sympa Menu

freetds - JDBC Sybase Intermittent Login Error problem and solution

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Jason Goemaat <jasong AT netins.net>
  • To: 'FreeTDS' <freetds AT franklin.oit.unc.edu>
  • Subject: JDBC Sybase Intermittent Login Error problem and solution
  • Date: Wed, 14 Jul 1999 21:00:48 -0500


Client: JDK 1.1 and 1.2 on Windows NT and Solaris
Server: Sybase Adaptive Server Enterprise 11.5.1 on Solaris

I have been getting two errors occasionally, not together. The first one
occurs very rarely, the second occurs more often (about 1 in 10 connects)
from FreeTDS-JDBC. This is the first error:

---------- begin error message ----------
java.sql.SQLException: Unknown packet type 0x0
Packet header is
0000 00 00 00 fa 00 00 00 00 |........|

at com.internetcds.jdbc.tds.Driver.connect(Driver.java:280)
at java.sql.DriverManager.getConnection(Compiled Code)
at TestFreeTDS.FreeConnect(Compiled Code)
at TestFreeTDS.main(TestFreeTDS.java:61)
---------- end error message ----------

This is the other error message:
---------- begin error message ----------
java.sql.SQLException: Logon failed. Msg 5703, Lvl 0, State 1,
Changed language setting to 'us_english'.
, Server , Procedure , Line 1
0 connection are in use by this program
at
com.internetcds.jdbc.tds.Connection.allocateTds(Connection.java:341)
at com.internetcds.jdbc.tds.Connection.<init>(Connection.java:169)
at com.internetcds.jdbc.tds.Driver.connect(Driver.java:257)
at java.sql.DriverManager.getConnection(Compiled Code)
at TestFreeTDS.FreeConnect(Compiled Code)
at TestFreeTDS.main(TestFreeTDS.java:61)
---------- end error message ----------

First to help diagnose the error I modified Tds.logon() to output the
message if it gets a PacketErrorResult from the command.

//---------- begin code snippet ----------
if (result instanceof PacketErrorResult)
{
System.err.println("Tds.logon() - PacketErrorResult!");
System.err.println(" PacketType - " + result.getPacketType());
System.err.println(" Message - '" +
((PacketErrorResult)result).getMsg() + "'");
isOkay = false;
}
//---------- end code snippet ----------

This showed me a message saying something to the effect that the language
"*&#~~" could not be found (random garbage characters). On the server
there was a stack error in the log files.

I used a proxy program I wrote to store the data going through in the
packets to the server from JDBC and from a test program. There were
several discrepancies in the login packet. Most notably, the packet from
FreeTDS was 0x024C long and the reference packet was 0x0248 long. After a
lot of tinkering and examining the code, I found the problem.

The remote password section is not sent correctly according to the comments
at the top of the Tds.logon() method. I changed the part to the following:

//---------- begin code snippet ----------
// remote passwords - JLG - commented two lines and added five
// comm.appendString(password, 255, (byte)0);
// comm.appendByte((byte)password.length());
comm.appendByte((byte)0); // magic3
comm.appendByte((byte)password.length());
comm.appendString(password, 30, (byte)0);
comm.appendString("", 223, (byte)0);
comm.appendByte((byte)(password.length() + 2));
//---------- end code snippet ----------

This is the commented declaration for this section:
* -- 202 -- DBCHAR magic3; -- 0, dont know this one either --
* -- 203 -- DBTINYINT password2_length;
* -- 204 -- DBCHAR password2[30];
* -- 234 -- DBCHAR magic4[223];
* -- 457 -- DBTINYINT password2_length_plus2;

After making this change, I haven't had a connection problem yet.

Jason Goemaat
jasong AT netins.net





Archive powered by MHonArc 2.6.24.

Top of Page