File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat app not connecting to server (jdbc) 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 » Products » Tomcat
Bookmark "Tomcat app not connecting to server (jdbc)" Watch "Tomcat app not connecting to server (jdbc)" New topic
Author

Tomcat app not connecting to server (jdbc)

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 399
I'm going to post an error message below and hope that someone can get a good strong hint from it about what the problem is making a jdbc call here. I've spent quite a bit of time on this problem, that uses code and set-ups that have been working very well on the original development computer. I've checked the installation settings several times to insure that they're the same on another computer. I've run tests, repeatedly checked set-ups and installations, turned the firewall off, etc. etc. etc. Right now, it seems to be down to getting a hint from this error message. Can anyone understand it? What's it trying to tell me?



Correlation does not prove causality.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

All it tells me is that a NullPointerException was thrown at line 73 of the nu.isr.hll.webshop.core.HLListProcess class, in the initialize method. Is that your code? If so, then you should look there. If not, then you should track down the owner and ask them to help you out.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 399
Paul Clapham wrote:All it tells me is that a NullPointerException was thrown at line 73 of the nu.isr.hll.webshop.core.HLListProcess class, in the initialize method. Is that your code? If so, then you should look there. If not, then you should track down the owner and ask them to help you out.




Yes, it's my code. The null pointer is the connection I'm trying to make to the database (Connection con). The first two lines are telling me that don't have a connection to the database; using code that works perfectly on the development machine. I've even previously, on the dev machine, successfully adjusted this code to connect to other databases in the LAN. On the problem machine, I've even involved a db administrator in trying various ways of specifying the db in the connection call that isn't working there.

What I'm hoping at this point is that there's more useful info in the error message. Like, does something in the neighborhood of say anything new? I vaguely remember looking at something to do with Valves in one of the Tomcat configuration files while setting up the development machine. This is new to me though. If I did something like that, it would have seemed quite obscure and I was just following a set of instructions. Haven't done anything like that on the problem machine ... although I've tried to compare files in Tomcat's config folder to be sure they're the same.

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 399
jdbc driver wasn't loading.

Looks like the problem comes down to a buggy Microsoft jdbc driver. According to the documentation, sqljdbc4 does not require explicit driver registration. Version 4 should do that automatically. Works fine on the Microsoft Vista dev machine. But it didn't work when I installed the app on Windows 7 (They are two different OS here, and I'm guessing that matters.)

Had to include Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

Now it works!

I'm going to add a caveat here. A good reason to use jdbc is that you don't need to rewrite your code to switch database systems. Doing something based on a nonstandard Microsoft feature is a bad idea in the first place. I've been thinking about that for the past hour, wondering why I fell for it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat app not connecting to server (jdbc)