Question

I googled a lot but I can't figure out the reason of this strange behaviour. I'm using microsoft sql server 2012 with windows authentication. I'm connecting like that:

try {
  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  conn = DriverManager.getConnection("jdbc:sqlserver://MY-PC:1433;databaseName=database;integratedSecurity=true");
} catch (Exception e) {
  System.out.println("failed" + e.getMessage());
  e.printStackTrace();
}

This connection is aproximately 3 times faster than when I use jtds driver (and also add .jar to project library and so on) net.sourceforge.jtds.jdbc.Driver and appropriate connection string (jdbc:jtds:sqlserver://MY-PC:1433/database;instance=SQLEXPRESS).

Does anybody know why? I read that jtds driver is much faster than sqldbc drivers, but I don't know what I'm doing wrong.

Thank you

Was it helpful?

Solution

jTDS driver has a lot of improvements related to the way queries work after the connection is made. Their benchmark does not mention the initial connection speed: http://jtds.sourceforge.net/benchTest.html. They only measure operations that are executed after connection is already active.

I suspect that connection initialization code is slower than for other drivers. That's why it is worth keeping a connection pool of precreated connections to get maximum performance. In fact it's true about any driver.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top