Question

I'm going to start a new project - rewriting an existing system (PHP + SQL Server) from scratch because of some very serious limitations by design.

We have some quite good knowledge of SQL Server (currently we're using SQL Server 2000 in existing system) and we would like to employ its newer version (2008 I guess) in our new project.

I am really fond of technologies that Java offers - particularly Spring Framework and Wicket and I am quite familiar with Java from others projects and assignments before. Therefore, we consider using Java and Microsoft SQL Server.

There are two JDBC drivers for SQL Server - jTDS and Microsoft's one - http://msdn.microsoft.com/en-us/data/aa937724.aspx. I think we should test both of them.

Are there any limitations in such solution I should know of? Has someone experience with such a technology combination?

Was it helpful?

Solution

I've worked on a project using MSQL Server in conjunction with a Java Stack. It works very well and as long, since JDBC shouldn't really care about your database. We used ehcache together with Hibernate and had problems with the MS JDBC Driver, so we switched to jtds and it works really good.

It's quite a while ago, so you still might wanna give the MS driver a chance...

OTHER TIPS

I don't know about Java and 2008... but you shouldn't have too much trouble with Java and SQL2000. As lubos suggested, you'd be doing yourself a favour to look at c# but if you're much more comfortable with Java then there shouldn't be any real limitations as the JDBC connector is supported by Microsoft

We've been running an application using Hibernate talking to multiple remote MSQL Server instances for a few years now and we also switched to the jTDS driver early on after a few issues with the M$ driver. Since the switch we haven't had any issues at all. However, it's not a complicated application so it doesn't use any LOB's. Hope that helps.

jTDS is excellent. I've been using it for years without issue in high-availability production environments.

I would lean towards the jTDS driver. The MSSQL driver has a limitation where you cannot re-read the same column twice. This happens frequently when using Hibernate.

The JDBC driver works well with SQL Server 2008, I've not had any problems with it. The version that you need to download depends on the version of the JRE you have installed. JRE6 uses JDBC4, JRE7 uses JDBC4.1, etc. Once you download the correct driver from Microsoft and run the installer you will need to copy the sqljdbc_auth.dll from the \auth directory to the c:\windows\system32 directory. Then can then use this code to make a connection:

In your header:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

and in your class:

public class connectToSQL {

    public void connectToDB() throws Exception {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String connectionUrl = "jdbc:sqlserver://<IPADDRESS>:<PORT>;DatabaseName=<NAME OF DATABASE TO CONNECT TO>;IntegratedSecurity=false";    
        Connection con = DriverManager.getConnection(connectionUrl, "<SQL SERVER USER LOGIN>", "<SQL SERVER PASSWORD>");
        Statement s = con.createStatement();
        ResultSet r = s.executeQuery("SELECT * FROM <TABLENAME TO SELECT FROM>");
        while (r.next()) {
            System.out.println(r.getString(1));
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top