-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problems with MySQL and catalog statement in mapping files
PostPosted: Tue Jun 21, 2005 11:52 am 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Hibernate version:
3.0.5
Mapping documents:
<class name="com.declivis.pos.AdminRole" table="admin_roles" catalog="pos">
Full stack trace of any exception that occurs:
java.sql.SQLException: No database selected
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2385)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2306)
.....
Name and version of the database you are using:
MySQL 4.1.something

I'm attempting to map an Object with Hibernate and MySQL by providing a JDBC connection to MySQL that does not directly supply the database name and rather uses the "catalog=" statement in the mapping files. This works without incident against SQL Server [of course with the proviso that "schema=dbo" is also specified]

My question is - has anyone gotten this working in MySQL? Do I need to specify the schema? It seems that for now, I can't actually do this. I read up on the documentation of the MySQL JDBC connector and it does support the getCatalog() call, but it would seem that either Hibernate is not performing it or I'm missing something in my configs.

Thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 12:18 pm 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
In my experience, instead of separating out the catalog and schema, mysql uses the form:

Code:
catalog_schema_tablename


inside the database for the tablename, removing the catalog and underscore if the catalog is not present, and the schema and underscore if the schema is also no present. For this reason, all operations must occur within a database.

Examples:

table a with schema b and catalog c:

c_b_a

table a with no schema and catalog c:

c__a

table a with schema b:

b_a


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 12:26 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Interesting information - in looking at the logs, there are two underscores so you may be correct. But it's also my understanding that the use of the underscore is as much a problem as not specifying the schema as MySQL uses a dot to separate database.schema.table

Unless I'm missing a runtime or compile-time element on MySQL that would allow this separator charater to be changed.

I know that in org.hibernate.dialect.MySQLDialect the method getSchemaSeparator() returns an underscore.


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