Is Microsoft JDBC driver extremely slow or i did something wrong...
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alex_Cai
Posted On:   Tuesday, July 30, 2002 01:29 AM

Hello, I have downloaded the JDBC driver from Microsoft (http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml). I ran it from RedHat Linux (7.2) with JDK 1.4, calling SQLserver running on WIN2000 server. Here is my code (very simple) - =========================================== import java.sql.*; import java.util.*; public class TestSQL { public static void main (String[] arg) { try { String query = "SELECT * FROM publishers"; Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.16   More>>

Hello, I have downloaded the JDBC driver from Microsoft (http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml). I ran it from RedHat Linux (7.2) with JDK 1.4, calling SQLserver running on WIN2000 server. Here is my code (very simple) -

			
===========================================
import java.sql.*;
import java.util.*;

public class TestSQL {

public static void main (String[] arg) {

try {
String query = "SELECT * FROM publishers";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.22:1433", "alex", "xxxx");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
String pub_id = rs.getString("pub_id");
String pub_name = rs.getString("pub_name");
String city = rs.getString("city");
String country = rs.getString("country");
System.out.println(pub_id + " -- " + pub_name + " -- " + city + " -- " + country);
}

stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

===============================================================

The result looks fine (a total of 8 rows retrieved). But it took a total of (5.3s real, 2.8s user, 0.05s sys). In particular - Class.forName() took 1.5 seconds, DriverManager.getConnection() took 2.5 seconds. Did I do anything wrong? (my TCP/IP connection to the database server is fine, and i don't expect this being the problem.) or has anyone had similar experience? Any help is greatly appreciated. thanks, alex    <<Less

Re: Is Microsoft JDBC driver extremely slow or i did something wrong...

Posted By:   David_Saintloth  
Posted On:   Thursday, August 1, 2002 10:27 AM

Hi Alex,


I don't have an answer but rather a question, I see that
you got the connection to work but I am still
having problems. I get the following error:





java.sql.SQLException: [Microsoft][SqlServer2000 Driver for JDBC][SqlServer] Login failed for user 'testdb'. Reason: Not associated with a trusted SQL Server connection.



What does this mean, ? I am using a dbase url that looks
like this in the driver manager:





DriverManager.getConnection("jdbc:microsoft:sqlserver://dbasebox:1433","testdb","");



Is there some configuration I have to perform on the sql
server, to allow it to accept the connection request?


Any help you can provide would be greatly appreciated.


Regards,

Dsl

Re: Is Microsoft JDBC driver extremely slow or i did something wrong...

Posted By:   Bozidar_Dangubic  
Posted On:   Tuesday, July 30, 2002 07:20 AM

why don't you run this in the loop and see what performance you get then. if you are just starting the VM and loading JDBC driver and getting the first connection, there is some overhead associated with that. however, performance should really speed up on subsequent calls to the database because the driver is already loaded into VM. also, look into connection pooling to enhance the performance even further. overall, I do not think that the performance of microsoft's driver is slow. my only problem is that it is missing bunch of features and does not run well on jdk1.4. other than that, performance-wise, for the query you are executing you should be fine but always remember that some overhead will occur the first time you execute this.
About | Sitemap | Contact