-->
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.  [ 2 posts ] 
Author Message
 Post subject: tutorial - mysql can't connect - database name not selected
PostPosted: Thu Aug 17, 2006 8:13 pm 
Newbie

Joined: Thu Aug 17, 2006 7:42 pm
Posts: 2
Location: San Francisco
what is the name of the database to be created and selected (for the Events tutorial) in the mySQL connection settings? Is there somewhere else to put the name into the build configuration?

The Events Tutorial database setup doesn't specify a database name in the connection configuration template. This works for hsqldb, but mySQL needs a database name specification, as shown by the error:

Caused by: java.sql.SQLException: No database selected

I have tried specifying "test" as a database name, but that doesn't work - it says it doesn't exist which is true.

Hibernate connected to mySQL successfully in installation test Auction app. see below. Also I have successfully done the Events tutorial once through completely using hsqldb. The second time through I want to do it with mySQL.

Notes:


Settings:
mysql in the "Day 1" test portion of the tutorial (auction app) from URL: http://www.hibernate.org/152.html, with the following settings for hibernate.properties:

hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/test
hibernate.connection.username gavin
hibernate.connection.password

but then later the instructions won't work for mysql...

On the "Day 2" section (http://www.hibernate.org/hib_docs/v3/re ... orial.html) the hsqldb connection setting works properly without specifying database name. the mysql connection setting needs a database name, shown by my hibernate output error:

Caused by: java.sql.SQLException: No database selected


Needs database name:

mysql setting:
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

These analogous settings work with hsqldb:

hsqldb connection setting:
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>


Last edited by sfmission on Fri Aug 18, 2006 1:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 8:59 pm 
Newbie

Joined: Tue Jul 11, 2006 10:41 pm
Posts: 11
Hi ,

I have tested hibernate using mysql and it works

I believe u need to change to connection url to
"jdbc:mysql:///<your database name>"

Below are my setting for mysql when i tested.
Code:
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql:///ecom</property>
        <property name="hibernate.connection.username">testing</property>
        <property name="hibernate.connection.password">password</property>
        <property name="dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
        <property name="show_sql">true</property>
       
        <mapping resource="com/Event.hbm.xml"/>
        <mapping resource="com/User.hbm.xml"/>




Regards,

Don't Forget to Rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.