Back Forum Reply New

My SQL 5

mons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communication failure during handshake. Is there a MySQL server running on localhost:3306?)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at org..orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:80)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at org..orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:777)
at org..orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:703)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org..beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
at org..context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317)
at org..web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org..web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
at org..web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
at org..web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3659)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4097)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
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)
Caused by: java.sql.SQLException: Communication failure during handshake. Is there a MySQL server running on localhost:3306?
at com.mysql.jdbc.MysqlIO.init(MysqlIO.java:692)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1657)
at com.mysql.jdbc.Connection.connectionInit(Connection.java:1076)
at com.mysql.jdbc.Driver.connect(Driver.java:313)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
... 32 more
2006-09-27 11:00:42,841 [main] INFO  org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5Dialect
2006-09-27 11:00:42,851 [main] INFO  org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
2006-09-27 11:00:42,851 [main] INFO  org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2006-09-27 11:00:42,851 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2006-09-27 11:00:42,851 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabledShahzad, the error states that the server configuration is incorrect - the client cannot connect to the server (
Is there a MySQL server running on localhost:3306?)

Try doing some diagnostics separately - i.e. run a mysql client and try connecting
to the server making sure you use the same parameters and settings.
Note that this problem is not Spring-specific - you simply don't have the mysql
configuration correct.

Hi,  i have checked with MySQLFront with same username and password.And it works f9.

Hi Shahzad,

I had something similar before when running mysql in a Linux box - JDBC couldn't connect while some client tools could. I found out that for JDBC to be able to connect to mysql server, the server must have tcp/ip mode connection enabled and mine was only set up with the shared-memory mode. Don't know if your problem is caused by exactly that, just a thought.

HTH.

Hi Shahzad,

I had a devil of a time trying to connect using apache commons.  But switching to C3P0 made life easier, imho.
Cheers,
Peter Adelmann

Hi,
Can u send me cp30 configuations.

thanx

Sure,

First, there are many posts on this site regarding it.  I did a search and got back some great info.  I went to the projects/c3p0/ and grabbed the latest.  I used one of the jars when I was working with mySQL.  The docs are great that come along.  Here's the entry which I put in my ApplicationContext.xml (the database name was ripit)

Code:      lt;bean id=quot;c3p0DataSourcequot; class=quot;com.mchange.v2.c3p0.ComboPooledDataSourcequot;   destroy-method=quot;closequot;gt;       lt;property name=quot;driverClassquot;gt;lt;valuegt;com.mysql.jdbc.Driverlt;/valuegt;lt;/propertygt;       lt;property name=quot;jdbcuclquot;gt;lt;valuegt;jdbc:mysql--localhost:3306/ripitlt;/valuegt;lt;/propertygt;       lt;property name=quot;userquot;gt;lt;valuegt;rootlt;/valuegt;lt;/propertygt;       lt;property name=quot;passwordquot;gt;lt;valuegt;peterlt;/valuegt;lt;/propertygt;   lt;/beangt;
I didn't have much of a problem after that...
Hope this helps....
Peter
¥
Back Forum Reply New