Hi there,

I'm hoping i have all the correct terminology...

Current hardware/software setup
Windows Server 2000 (Live)
Tomcat version 5.59.
Java: Sun JDK 1.42_09 (need to use this as i have an application that wasn't written by me, but doesn't seem to work in 1.5)
Windows Server 2003 running SQL Server 2000.
JDBC: TWFreeTDS

Class c = Class.forName("com.thinweb.tds.Driver"); //The Driver
dbConn = DriverManager.getConnection("jdbc:twtds:sqlserver://SQLServer00/Catalog;user=user;password=password;TDS=7.0");

The connection works with SQL Server 2000.

New Hardware/software setup:
Windows Server 2008.  Dev computer is Windows 7 32 bit.
Tomcat version 5.59.
Java: Sun JDK 1.42_09 (need to use this as i have an application that wasn't written by me, but doesn't seem to work in 1.5)
SQL Server 2005 on Windows Server 2008.
JDBC: jTDS via JDNI (both are located in the common/lib folder.
Updated all commons (collections 3.2.1, dbcp 1.22, pool 1.53) to the latest available. Also located in the common/lib folder, and not located in the webapps' lib folder.

At first i tried to see if FreeTDS would work with SQL Server 2005, but from what i can see, it doesn`t go through.

So i decided to change the url to jTDS, but again the connection doesn't go through. I'm not even sure if i have the right connection url, but when i have tried to use it, it just doesn't connect.

Class c = Class.forName("net.sourceforge.jtds.jdbc.Driver"); //The Driver
dbConn = DriverManager.getConnection("jdbc:jtds:sqlserver://SQLServer05/Catalog;user=user;password=password;TDS=8.0");

I've made sure that all security stuff is correct on both, and in fact, NetBeans connects just fine to SQL Server 2005. But there is a schema that i don`t understand how it gets in there.

Considering this, i decided to try and use the JDNI.

I have set up everything that i can see based on the instructions i found.

Files currently listed in "common/lib"
activation.jar
commons-collections-3.2.1.jar
commons-dbcp-1.2.2.jar
commons-el.jar
commons-pool-1.5.3.jar
jasper-compiler.jar
jasper-compiler-jdt.jar
jasper-runtime.jar
jsp-api.jar
jtds-1.2.4.jar
mail.jar
naming-factory.jar
naming-resources.jar
servlet-api.jar
tools.jar

Here is the Context.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/App">

<Resource
name="jdbc/Conn"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://sql2005:1433/Catalog"
username="username"
password="password"
maxActive="20"
maxIdle="10"
maxWait="-1"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />

</Context>

web.xml (rest is snipped, only to show the relevent info).
 <resource-ref>
   <description>
     Resource reference to a factory for java.sql.Connection instances
that may be used for talking to a particular database that is configured
        in the server.xml file.
   </description>
   <res-ref-name>jdbc/Conn</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
 </resource-ref>

Even though the above in web.xml says that discusses making a config change in the server xml, i didn`t make any changes there.

Here is my code in the bean that i had set up for connecting to the database.
ConnectionBean.java (only the method is shown).

   public Connection getConnection()
           throws SQLException {
       Connection dbConn = null;
       InitialContext initCtx = null;
       DataSource ds = null;

       try {
           log.info("Context");
           initCtx = new InitialContext();
           if (initCtx == null) {
               log.info("No Context");
           }

           log.info("Datasource checking");
           ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/Conn");
           if (ds == null) {
               log.info("Datasource not found");
           }

           log.info("Getting Connection");
           dbConn = ds.getConnection();
           if (dbConn == null) {
               log.info("Could not get connection");
           }
       } catch (SQLException e) {
           log.info("SQLException: " + e);
       } catch (NamingException e) {
           log.info(e.getMessage());
       }

       return dbConn;
}

Here is the stdout when i try and run the bean.
2009/10/16 15:37:09 - Context
2009/10/16 15:37:09 - Datasource checking
2009/10/16 15:37:09 - Getting Connection
AbandonedObjectPool is used (org.apache.commons.dbcp.abandonedobjectp...@10a5c21)
  LogAbandoned: true
  RemoveAbandoned: true
  RemoveAbandonedTimeout: 60

This is the error i get when i try and connect to the database via the bean above.

16-Oct-2009 3:37:09 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError: java.lang.Integer.valueOf(I)Ljava/lang/Integer;
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.unpackProperties(ConnectionJDBC2.java:1221) at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:280) at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
        at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294) at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at Beans.ConnectionBean.getConnection(ConnectionBean.java:183)
        at org.apache.jsp.page_jsp._jspService(org.apache.jsp.page_jsp:152)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.valves.FastCommonAccessLogValve.invoke(FastCommonAccessLogValve.java:481) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:534)

I am hoping someone can see where i am going wrong here...

Thank you.
...Robin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to