freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Raul" <spopa AT tiscalinet.it>
- To: freetds AT franklin.oit.unc.edu
- Subject: Patching FreeTDS for SQLServer2000
- Date: Mon, 12 Mar 2001 10:57:58 -0500
Hi folks!
I succeeded to working with freeTDS and MSSQLServer 2000 by patching the
code in Statement class, method getMoreResults.
Without this small patch the very first time i made a query on the
database I caught the folllowing exception: Protocol confusion. Got a
0x79 packet. I found that if the statement is cached in the system table
syscacheobjects of the Master database the quesry runs succesfully,
otherwise I catch the Exception. This, of course, doesn't occur in SQL
7.0. By inspecting the classes I found thet the 0x79 packet was declared
but not used in the statement class then I made this small correction:
From
public boolean getMoreResults() throws SQLException
{
SQLException exception = null;
if (tds == null)
{
throw new SQLException("Statement is closed");
}
updateCount = -1; // Do we need this global variable?
if (!tds.moreResults())
{
return false;
}
closeResults(); // Reset all internal variables (why is this done
here?)
try
{
tds.isResultSet();
// Keep eating garbage and warnings until we reach the next
result
while (!tds.isResultSet() && !tds.isEndOfResults())
{
if (tds.isProcId())
{
tds.processSubPacket();
}
else if (tds.isDoneInProc())
{
PacketDoneInProcResult tmp =
(PacketDoneInProcResult)tds.processSubPacket();
}
else if (tds.isTextUpdate())
{
PacketResult tmp1 =
(PacketResult)tds.processSubPacket();
}
else if (tds.isMessagePacket() || tds.isErrorPacket())
{
PacketMsgResult tmp =
(PacketMsgResult)tds.processSubPacket();
exception = warningChain.addOrReturn(tmp);
}
else
{
throw new SQLException("Protocol confusion. "
+ "Got a 0x"
+ Integer.toHexString((tds.peek() &
0xff))
+ " packet");
}
} // end while
if (exception != null)
{
try
{
tds.discardResultSet(null);
}
catch(java.io.IOException e)
{
throw new SQLException("Error discarding result set while
processing sql error- " +
exception.getMessage() +
"\nIOException was " +
e.getMessage());
}
catch(com.internetcds.jdbc.tds.TdsException e)
{
throw new SQLException("Error discarding result set while
processing sql error- " +
exception.getMessage() +
"\nIOException was " +
e.getMessage());
}
throw exception;
}
if (tds.isEndOfResults())
{
PacketEndTokenResult end =
(PacketEndTokenResult)tds.processSubPacket();
updateCount = end.getRowCount();
return false;
}
else if (tds.isResultSet())
{
return true;
}
else
{
throw new SQLException("Protocol confusion. "
+ "Got a 0x"
+ Integer.toHexString((tds.peek() &
0xff))
+ " packet");
}
}
catch(java.io.IOException e)
{
throw new SQLException("Network error- " + e.getMessage());
}
catch(com.internetcds.jdbc.tds.TdsException e)
{
throw new SQLException("TDS error- " + e.getMessage());
}
}
-
Patching FreeTDS for SQLServer2000,
Raul, 03/12/2001
- <Possible follow-up(s)>
- Patching FreeTDS for SQLServer2000, Raul, 03/12/2001
- Re: Patching FreeTDS for SQLServer2000, Bob Kline, 03/12/2001
- Re: Patching FreeTDS for SQLServer2000, Raul, 03/13/2001
- Re: Patching FreeTDS for SQLServer2000, Bob Kline, 03/13/2001
Archive powered by MHonArc 2.6.24.