-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem connecting to MySQL database.
PostPosted: Mon May 23, 2005 4:46 am 
Newbie

Joined: Mon May 23, 2005 4:32 am
Posts: 4
I am very new to hibernate. I am using MySQL version 4.1.11 and hibernate 3.0.3.

I have created a simple database with 1 table (pages). I have created a hibernate config xml and a mapping file for my pages table. I have created a HibernateSessionFactory class. In my method to get the current session, my code never executes pas thte call to "cfg.buildSessionFactory()".

the last lines of the hibernate log4j log file are:
*******************************************
2005-05-23 18:10:33,476 INFO org.hibernate.connection.DriverManagerConnectionProvider configure (PAULRUSSELL\Administrator) - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/boeing
2005-05-23 18:10:33,476 INFO org.hibernate.connection.DriverManagerConnectionProvider configure (PAULRUSSELL\Administrator) - connection properties: {user=root, password=dog}
2005-05-23 18:10:33,476 DEBUG org.hibernate.connection.DriverManagerConnectionProvider getConnection (PAULRUSSELL\Administrator) - total checked-out connections: 0
2005-05-23 18:10:33,486 DEBUG org.hibernate.connection.DriverManagerConnectionProvider getConnection (PAULRUSSELL\Administrator) - opening new JDBC connection
2005-05-23 18:10:33,676 INFO org.hibernate.connection.DriverManagerConnectionProvider close () - cleaning up connection pool: jdbc:mysql://localhost/boeing
*******************************************

I also have another error in my servlet log file:
*******************************************
2005-05-23 18:10:33,616 [Thread-4] ERROR com.interface.ui.base.ui.portal (PAULRUSSELL\Administrator) - An exception was caught while rendering portlet cu.create_content.portlet: java/sql/Savepoint
*******************************************

Why aren't I getting any errors logged to my hibernate log file? Any suggestions what I am doing wrong?


hibernate.cfg.xml
*******************************************
<hibernate-configuration>

<session-factory>
<!-- properties -->
<property name="connection.username">root</property>
<property name="connection.password">dog</property>
<property name="connection.url">jdbc:mysql://localhost/test_db</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="connection.pool_size">1</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>

<!-- mapping files -->
<mapping resource="Pages.hbm.xml"/>
</session-factory>

</hibernate-configuration>
*******************************************

Pages.hbm.xml
*******************************************
<hibernate-mapping package="com.test.business">

<class name="Pages" table="pages">
<id name="pageId" column="page_id" type="java.lang.String">
<generator class="assigned"/>
</id>

</class>

</hibernate-mapping>
*******************************************



Any help or pointers are greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 8:15 am 
Newbie

Joined: Mon May 23, 2005 4:32 am
Posts: 4
I think it was related to the fact I have to use jdk 1.3

When I used an mysql connector earlier then version 3.1, it got further. But I still get the following exception. Does this look like it is just getting refused from connecting to my database? They are both on the same machine, and I am tyring to log in as root. Does that message saying "Could not obtain connection metadata", just mean it coldn't connect to the database?

2005-05-23 22:02:50,847 DEBUG org.hibernate.connection.DriverManagerConnectionProvider getConnection (PAULRUSSELL\Administrator) - opening new JDBC connection
2005-05-23 22:02:50,967 WARN org.hibernate.cfg.SettingsFactory buildSettings (PAULRUSSELL\Administrator) - Could not obtain connection metadata
java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
at com.mysql.jdbc.MysqlIO.init(MysqlIO.java:619)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1605)
at com.mysql.jdbc.Connection.connectionInit(Connection.java:1056)
at com.mysql.jdbc.Driver.connect(Driver.java:297)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:141)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:68)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
at com.boeing.data.HibernateSessionFactory.currentSession(Unknown Source)
at com.boeing.events.content.CreateServlet.insertPage(Unknown Source)
at com.boeing.events.content.CreateServlet.processRequest(Unknown Source)
at com.boeing.events.content.CreateServlet.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 8:36 am 
Newbie

Joined: Mon May 23, 2005 4:32 am
Posts: 4
Solved it.

Turns out jdk1.3, requires mysql connector prior to version 3.1.

however if you go use a pre3.0 or early version of 3.0, it is incompatible with the latest version of MySQL.
http://forums.mysql.com/read.php?39,6448,7377#msg-7377


Sorry, this wasn't related to hibernate at all. I realise now I shouldn't have posted this here.[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 01, 2005 11:04 am 
Newbie

Joined: Wed Jun 01, 2005 11:00 am
Posts: 17
Location: UK
Hi,

Has having a similar problem. Fixed it by using MySQL Connector/J 3.0
seems to work and I dont get the connection exceptions.
Hope you got a work around.

Ben


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.