2012-11-15 69 views
22

我正嘗試使用Java JTDS驅動程序連接到我在Scala中的數據庫。但是,每當我嘗試使用它時,我都會得到(Java?)版本錯誤的錯誤。使用JTAG與Scala不支持的版本錯誤

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 
     } 
    } 
    } 
  • 斯卡拉版本:2.9.2
  • Java版本:1.6
  • 使用JTDS 1.3.0
  • Java的版本的輸出:

Java版本Java™SE運行環境(版本1.6.0_35-b10-428-11M3811)「1.6.0_35」爪哇熱點(TM)64位服務器VM(建立20.10-b01-428,混合模式)

回答

40

是,你的Java運行時太舊,根據Java class file format

  • J2SE 7 = (0x33十六進制),
  • J2SE 6.0 = 50(0x32十六進制),
  • J2SE 5.0 = 49(0X31十六進制),
  • JDK 1.4 = 48(的0x30十六進制),
  • JDK 1.3 = 47( 0x2F他x),
  • JDK 1.2 = 46(0x2E hex),
  • JDK 1.1 = 45(0x2D hex)。

51.0表示您需要Java 7來運行項目中的某些類。而且你是正確的它是造成問題JTDS(從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

請升級到Java 7(總是一個好主意)或降級到一些老司機JTDS。

+1

斯卡拉仍然不符合JDK7 100%兼容,所以我會堅持舊的驅動程序了。謝謝! –

10

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.

相關問題