wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes Can get mysql DB connection from class, but can't get from servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Can get mysql DB connection from class, but can Watch "Can get mysql DB connection from class, but can New topic
Author

Can get mysql DB connection from class, but can't get from servlet.

Boris Lyadov
Greenhorn

Joined: Sep 18, 2009
Posts: 3
Hi All.
In my simplest training application I have to create Class DbConnector.class which is returning mysql DB connection. I'm calling this class from LoginManager.class where I'm checking username and password. Runnig in Eclipse console and it's working properly. After that I made export my project into connector.jar file.
Now I create a new tomcat project and add this connector.jar into the buildpath. In class LoginServlet I made import of connector and calling LoginManager.class. So when I'm calling LoginServlet from login.jsp file I'm getting error
"com.mysql.jdbc.CommunicationsException: Communications link failure"
Driver loaded, but cannot connect to db: jdbc:mysql://localhost:3306/bill_base?useUnicode=yes&characterEncoding=utf-8

Below please find source of DbConnector, LoginManager,LoginServlet and login.jsp
Please help.
_______________________________________________________________________________________________________________
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

Hi Boris,

welcome to Java Ranch !!

UseCodeTags. Code is difficult to read. You can edit your post to include them using the button or re-post the question with proper formatting.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Boris Lyadov
Greenhorn

Joined: Sep 18, 2009
Posts: 3
Thank you. Excuse me, didn't pay my attention to the tags from the begining.
Boris Lyadov
Greenhorn

Joined: Sep 18, 2009
Posts: 3
Ok. I've deployed this application directly on Tomcat, instead running it from Eclipse tomcat plugin. Now it's working.
Any idea?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

As this is now an Eclipse question, it has been moved to the IDEs forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can get mysql DB connection from class, but can't get from servlet.