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)
Best Answer
Yes, your Java runtime is too old, according to Java class file format:
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):
Either upgrade to Java 7 (always a good idea) or downgrade to some older jTDS driver.