22

I'm trying to use the Java JTDS driver to connect to my database in Scala . However, whenever I try to use it I get an error that the version(of java?) is wrong.

java.lang.UnsupportedClassVersionError: net/sourceforge/jtds/jdbcx/JtdsDataSource : Unsupported major.minor version 51.0

object DaoDriverAdaptor {
  import java.sql.{DriverManager, Connection}

  private def loadDriver() {
    try {
      Class.forName("net.sourceforge.jtds.jdbcx.JtdsDataSource")
    } catch {
      case e: Exception  => {
        println("ERROR: Driver not available: " + e.getMessage)
        throw e
      }
    }
  }
  • Scala version : 2.9.2
  • Java Version : 1.6
  • Using jtds 1.3.0
  • Output of java -version:

java version "1.6.0_35" Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811) Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

stan
  • 4,752
  • 4
  • 43
  • 68

2 Answers2

40

Yes, your Java runtime is too old, according to Java class file format:

  • J2SE 7 = 51 (0x33 hex),
  • J2SE 6.0 = 50 (0x32 hex),
  • J2SE 5.0 = 49 (0x31 hex),
  • JDK 1.4 = 48 (0x30 hex),
  • JDK 1.3 = 47 (0x2F hex),
  • JDK 1.2 = 46 (0x2E hex),
  • JDK 1.1 = 45 (0x2D hex).

51.0 means you need Java 7 to run some of the classes in your project. And you are right it's jTDS that's causing the problem (from jTDS JDBC Driver 1.2.7 and 1.3.0 released):

Version 1.3.0 is the first Java 7 compatible version of the driver and

Either upgrade to Java 7 (always a good idea) or downgrade to some older jTDS driver.

Tomasz Nurkiewicz
  • 311,858
  • 65
  • 665
  • 652
  • 1
    Scala still isn't 100% compatible with JDK7, so I'll stick to the older driver for now. Thanks! – stan Nov 15 '12 at 18:27
10

From the release notes:

You should only stick to the jTDS 1.2.x line of the driver if you require to use Java versions prior to Java 7.

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758