Home > Hibernate, Java, JDBC > Use the New JDBC Driver for MS SQL Server

Use the New JDBC Driver for MS SQL Server

I’ve used MySQL with my example on my Hibernate posts but since we are using MS SQL Server 2000 in my class(I know, we should be upgrading to at least SQL Server 2005…) I thought I’d create an example using SQL Server.

So there I was reconstructing everything that I mentioned starting with Java Persistence with Hibernate Part 2 – Getting Started until I was done with my test class to see if everything works and that’s what I was expecting but I was wrong. Instead I got this error:

Exception in thread "main" java.lang.AbstractMethodError: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z


I immediately blamed the JDBC driver I have for SQL Server 2000 and then I also remembered that there’s a new JDBC version already for SQL Server. Sure enough when I changed to sqljdbc4.jar(I’m using JDK 6.0, use sqljdbc.jar for JDK 5.0) and changed the driver class to com.microsoft.sqlserver.jdbc.SQLServerDriver everything went smoothly and the application executed correctly.

Hope this helps someone cause it’s really hard to find the solution for the error that I encountered if you’re not familiar with the history of JDBC with SQL Server. For more information on using the new driver please visit Using the JDBC Driver.

Advertisement
  1. jrp
    December 10, 2009 at 12:25 am | #1

    Man, thanks for posting this!! you really helped me. I would not have solved it myself. Greetings from Catalonia

    • josebobsantos
      May 19, 2010 at 5:23 pm | #2

      No problem

  2. blm
    December 31, 2009 at 11:43 pm | #3

    HUGE help!! Thanks for publishing your findings.

    • josebobsantos
      May 19, 2010 at 5:23 pm | #4

      Glad this post helped!

  3. moo2
    February 24, 2010 at 10:33 am | #5

    Pretty good help. Thanks! – solved my problem

    • josebobsantos
      May 19, 2010 at 5:21 pm | #6

      You’re welcome!

  4. Mohan
    May 19, 2010 at 5:00 pm | #7

    Did you change your database to 2005 or did these drivers worked with 2000 it self

    • josebobsantos
      May 19, 2010 at 5:20 pm | #8

      Hi Mohan,

      The drivers worked with 2000.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.