This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JDBC connection on SQL Server 2005

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm moving our development environment for a JSP application on a new machine.
The application is using a newer version of SQL Server. Moving from SQL Server 2000 to SQL Server 2005.

When I try to open it in IE, it gives me the following error:
org.apache.jasper.JasperException: Exception in JSP: /includes/DBLayer.jsp:47

44: String password=getControlSetting(env+"DBPassword",r);
45: String selectMethod=getControlSetting(env+"SelectionMethod",r);
46: constring = url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";
47: Class.forName(getControlSetting(env+"DBClass",r));
48: conn = java.sql.DriverManager.getConnection(constring,userName,password);
49: conn.setCatalog(databaseName);
50: } catch (Exception e){


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

javax.servlet.ServletException: Bad version number in .class file
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index_jsp._jspService(index_jsp.java:985)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


I've spent several hours trying to figure out what's wrong. Do you have any idea?
I have checked Tomcat's classpath and it seems to be alright, pointing to the right version of sql driver.

Thank you.
 
Marshal
Posts: 25671
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat can't load that class, which it looks like it's the JDBC driver class, because that class was compiled with a version of Java which Tomcat doesn't understand. This would be a later Java version than the one Tomcat is running under.

For example you might be running Tomcat with a Java 5 JDK but the device driver was compiled with a Java 6 JDK.
 
Sinisa Popovic
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:For example you might be running Tomcat with a Java 5 JDK but the device driver was compiled with a Java 6 JDK.



Hi Paul,

ok, it makes sense.
I have Java 5 installed on this machine and used older version of JDBC driver: mssqlserver.jar
It worked fine with SQL Server 2000.

Now, when I upgraded to SQL Server 2005, I also downloaded a new version of JDBC driver: sqljdbc4.jar
But it seems that this driver was made in Java 6.

I returned to the old version of the JDBC driver mssqlserver.jar and it works.

I still don't understand how is it possible that the older version of JDBC driver works with newer version of SQL Server?

Thank you very much for your help!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The protocol that is used by the driver (TDS) has not changed from one version of the server to another. The 2000 version is not a good driver.
 
Sinisa Popovic
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Sturrock wrote:The 2000 version is not a good driver.



mssqlserver.jar is the old, SQL Server 2000 driver.

However I have to use it because the new driver doesn't work with Java 5.
I can't upgrade to Java 6 right now.

Is there a new driver that works with java 5?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't use the MS 2000 driver even with SQL Server 2000 - it is bug-ridden.

jTDS is a much better alternative. The will have a version that works with legacy Java versions.
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic