標籤:
今天使用Tomcat串連sql Server 2008 enterprise的時候,報錯:
HTTP Status 500 - Servlet execution threw an exceptiontype Exception reportmessage Servlet execution threw an exceptiondescription The server encountered an internal error that prevented it from fulfilling this request.exceptionjavax.servlet.ServletException: Servlet execution threw an exceptionspt.servlet.filter.EncodingFilter.doFilter(EncodingFilter.java:24)root causejava.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver : Unsupported major.minor version 51.0 (unable to load class com.microsoft.sqlserver.jdbc.SQLServerDriver)org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2961)org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)java.lang.Class.forName0(Native Method)java.lang.Class.forName(Class.java:169)spt.server.jdbc.db.BasicDB.getConnection(BasicDB.java:260)spt.server.jdbc.db.BasicDB.getPreparedStatement(BasicDB.java:268)spt.server.jdbc.db.BasicDB.getAQIDayByCityCodeAndDate(BasicDB.java:136)spt.service.AQIDayService.getAQIDay(AQIDayService.java:33)spt.servlet.JsonServlet.doPost(JsonServlet.java:34)spt.servlet.JsonServlet.doGet(JsonServlet.java:53)javax.servlet.http.HttpServlet.service(HttpServlet.java:620)javax.servlet.http.HttpServlet.service(HttpServlet.java:727)spt.servlet.filter.EncodingFilter.doFilter(EncodingFilter.java:24)note The full stack trace of the root cause is available in the Apache Tomcat/7.0.57 logs.Apache Tomcat/7.0.57
JDK的版本號碼對應:
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).
由此可知,上述錯誤是由於jTDS需要jdk7,而你使用的JDK版本不是jdk7。
ref: http://shalousoft.com/go_newsForum.action?op=d3a91dac-6b7c-11e3-8e31-5254001578d1
Tomcat - java.lang.UnsupportedClassVersionError:Unsupported major.minor version 51.0 (unable to load class com.microsoft.sqlserver.jdbc.SQLS