Neven,

Thanks for the response. Yes, I checked and the HibernateUtil.class is where 
you said it would be. I also find hibernate3.jar under my WEB-INF/lib 
directory. Is there some kind of environment variable I need to set so that the 
HibernateUtil.class file is found?

David 

 

 

-----Original Message-----
From: Neven Cvetkovic <neven.cvetko...@gmail.com>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Tue, Apr 2, 2013 12:45 pm
Subject: Re: Trouble loading MS SQl Server database driver in Tomcat 7.0.37


David

My bad, I gave you the wrong code for testing database connections. I was
just typing the code from my head, I did not test it myself. I probably
should have used Eclipse before I gave you the code ;)

Here's a better version:

...
<%
    javax.naming.InitialContext naming = null;
    *java.sql.Connection* connection = null;
    *javax.sql.DataSource datasource = null;*
    try {
        naming = new javax.naming.InitialContext();
        datasource = (*javax.sql.DataSource*)
naming.lookup("java:comp/env/jdbc/smswebdb");
        connection = datasource.getConnection();
        connection.close();
        out.println("Connection has successfully obtained from datasource.
connection=" + connection);
    } catch (javax.naming.NamingException ne) {
        ne.printStackTrace();
        out.println("Datasource is not bound to JNDI: " + ne);
    } catch (*java.sql.SQLException* sqle) {
        sqle.printStackTrace();
        out.println("Problem with a SQL connection: " + sqle);
    } catch (Exception e) {
        e.printStackTrace();
        out.println("Something else went wrong: " + e);
    }
%>
...


So the correct classes are:
java.sql.Connection, java.sql.SQLException, javax.sql.DataSource (thanks
Dan)

Again, this is probably a very dirty way to test database connection pools
(datasources) managed by your Tomcat, and it just helps you troubleshoot
your connection setup.


About your second issue (unrelated) - Dan had a great question - check
where your *com.systemsmadesimple.hibernate.HibernateUtil* class is
deployed. This is a class that your developers wrote, and probably resides
in 
SystemsMadeSimple.war/WEB-INF/classes/com/systemsmadesimple/hibernate/Hibernate.class,
unless packaged as JAR.

Also, check that you have the Hibernate jar files as well. JBoss (I assume
you are migrating from JBoss 5.x) probably has Hibernate libraries
included, Tomcat does not, your application needs to pack these libraries.
All application-packaged third-party libraries (or your application shared
libraries) should reside in SystemsMadeSimple.war/WEB-INF/lib
directory. Although,
I think your previous console output showed that your Hibernate code was
being parsed, so Hibernate jars are probably packaged properly.

Cheers!

 

Reply via email to