JDBC Performance - Connections and Sockets
m_z_taylor at hotmail.com
Wed Jul 12 12:56:46 EDT 2000
Hi - I am using the freeTDS JDBC driver to MS SQL and have a question.
Consider the following ..
Statement s1 = con.createStatement()
Statement s2 = con.createStatement()
ResultSet rs1 = s1.executeQuery()
ResultSet rs2 = s2.executeQuery()
rs1 read some rows
rs2 read some rows
rs1 read more rows
rs2 read more rows
The freeTDS driver seems to logon with username, password etc for each
statement s1 and s2. This can be seen using the SQL Server trace utility.
Using commercial drivers such as iNet and JTurbo there is only one login.
This makes the execution of the above code generally much, much faster.
Some questions :-
1. Why does the driver create >1 logon? Surely once a logon is accepted
that is enough.
2. FreeTDS creates a new socket to SQL Server for each statement - that
makes sense so it can
independently read result sets rs1 and rs2. Do the commercial drivers also
create a new socket
for each statement? If they do not then how would they separate rs1's data
from rs2's data?
3. It would seem that the ideal would be to logon once but then use that
logon for each new socket
that is required. This is the approach of say ODBC which gets a handle when
it logs in and specifies
that handle for each new statement. So we would have a socket for each
statement but the logon overhead
More information about the FreeTDS