aspose file tools*
The moose likes Servlets and the fly likes Cannot Connect to MySql DataBase from Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot Connect to MySql DataBase from Servlet" Watch "Cannot Connect to MySql DataBase from Servlet" New topic
Author

Cannot Connect to MySql DataBase from Servlet

Mohammad Ali
Greenhorn

Joined: Jan 03, 2006
Posts: 11
I desigend a J2EE Aplication using JSP and Servlets in MVC design.
My system was working great untill i tried using filter for gzip compression for response output , after i used filter gzip, my whole application is destroyed, I cannot able to connect to my Mysql data base, my connection object always returns NULL, i tried every thing re-installing the mysql driver, re-installing the NetBeans ide , nothing is working, i am not able to connect with the database.

This application was working perfect before i experimented with the Gzip filter.please any body can help me what i did wrong, did i corrupted tomcat server. My application is still on my laptop and is not have been loaded on internet yet. i am posting some errors it is showing on the tomcat log.

I Want to mention i am using connection pooling which was working great,
all the servlets are present in the application, the whole application and connection pooling was working great before i used this gzip filter.....Also i like to mention the main problem is when i try to load the driver for Mysql database in my java class it always returns a null connection object. I use Class.forName function in java to load a driver for mysql database.Following is the code where my appliacation returns null connection object

public static Connection ConnectDB(String NameParm, String PasswordParm) {
try {

String url = "jdbc:mysql://localhost:3306/mysql";

Class.forName("com.mysql.jdbc.Driver");
conn = null;
conn = DriverManager.getConnection(url, NameParm, PasswordParm);
System.out.println("Database connection established");
return conn;
} catch (Exception e)
{
System.err.println("Cannot connect to database server ");
return conn;
}
}

please guilde me.. my application is totally stoped at this moment.


=========== E R R O R S- ON TOMCAT LOG ============
Jan 3, 2006 3:28:16 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@3a9bba')
Jan 3, 2006 3:28:16 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@1c5ddc9')
Jan 3, 2006 3:28:16 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@163f7a1')
Jan 3, 2006 3:28:16 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jan 3, 2006 3:28:16 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Jan 3, 2006 3:28:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet ShadiManager as unavailable
Jan 3, 2006 3:28:32 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /CofeeAdvice threw load() exception
javax.servlet.UnavailableException: Couldn't create connection pool
at com.example.model.ServletController.init(ServletController.java:69)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:589)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:536)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Jan 3, 2006 3:28:33 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 3, 2006 3:28:33 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jan 3, 2006 3:28:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.NoClassDefFoundError: javax/faces/FacesException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3618)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:589)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:536)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Jan 3, 2006 3:28:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
[ January 03, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

"Java Faces",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot Connect to MySql DataBase from Servlet
 
Similar Threads
Problem starting up servlet-examples & jsp-examples
struts validator plug in error
Having issues with Tomcat 6.x
Error in tomcat 5.5
Getting error----NoContextLoaderListener registered