aspose file tools*
The moose likes JDBC and the fly likes JDBC connection on SQL Server 2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC connection on SQL Server 2005" Watch "JDBC connection on SQL Server 2005" New topic
Author

JDBC connection on SQL Server 2005

Sinisa Popovic
Greenhorn

Joined: Nov 04, 2010
Posts: 3
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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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

Joined: Nov 04, 2010
Posts: 3
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!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sinisa Popovic
Greenhorn

Joined: Nov 04, 2010
Posts: 3
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

Joined: Apr 14, 2004
Posts: 10336

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC connection on SQL Server 2005