-->
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.  [ 1 post ] 
Author Message
 Post subject: MySQLSyntaxErrorException while sessionfactory on MySQL5.0
PostPosted: Thu Sep 28, 2006 4:01 am 
Newbie

Joined: Wed Jun 07, 2006 10:31 am
Posts: 3
Location: pune, india
All Details bewl on format required. Opening session factory works if I use addCLass merthod
whihc uses individual hbm.xml files. But if I use hibernate.cfg.xml (listed below, using configuration constructor
it throws an exception in mySQL hierarchy!!!

also I don't understand why am getting net/sf/ehcache/CacheException
as all jars from Hibernate 3.1's lib directory are included in the [project.

Hibernate version: 3.1

Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="SFN" >

<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/bfl</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">suhasw</property>
<property name="hibernate.connection.password">ram681</property>
<!-- property name="hibernate.connection.pool_size"></property -->

<!-- dialect for MySQL -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<!-- <property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
-->
<mapping resource="Post.hbm.xml"/>
<mapping resource="Topic.hbm.xml"/>
<mapping resource="User.hbm.xml"/>

</session-factory>
</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
Problematic code inside the constuctor
// Create the SessionFactory
cfg = new Configuration();
cfg.configure( "hibernate.cfg.xml" );
System.out.println( "created configuration successfully" );
factory= cfg.buildSessionFactory();
System.out.println( "created session factory" );

If I use the foloowing code with everything rremaining same it works fine
cfg = new Configuration();
cfg.addClass(discussion.User.class)
.addClass(discussion.Topic.class)
.addClass(discussion.Post.class);
factory= cfg.buildSessionFactory();
System.out.println( "created session factory" );

Full stack trace of any exception that occurs:

Name and version of the database you are using:

MySQL 5.0 on Windows XP with Connector/J 5.0.3

The generated SQL (show_sql=true):

Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1.3
Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=suhasw , hibertate.connection.password=ram681, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.show_sql=true, hibernate.connection.url=jdbc:mysql://localhost/bfl, hibernate.connection.driver_class=com.mysql.jdbc.Driver}
Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
Sep 28, 2006 12:53:12 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: Post.hbm.xml
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.Post -> posts
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: Topic.hbm.xml
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.Topic -> topics
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: User.hbm.xml
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: discussion.User -> users
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: SFN
created configuration successfully
Sep 28, 2006 12:53:13 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: discussion.Topic.posts -> posts
Sep 28, 2006 12:53:13 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Sep 28, 2006 12:53:13 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Sep 28, 2006 12:53:13 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
Sep 28, 2006 12:53:13 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/bfl
Sep 28, 2006 12:53:13 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=suhasw, password=****}
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
WARNING: Could not obtain connection metadata
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Access denied for user 'suhasw'@'localhost' to database 'bfl'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at discussion.BoardManager.<init>(BoardManager.java:27)
at discussion.BoardManager.main(BoardManager.java:131)
Sep 28, 2006 12:53:14 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
Sep 28, 2006 12:53:14 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
Sep 28, 2006 12:53:14 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Sep 28, 2006 12:53:14 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Sep 28, 2006 12:53:14 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
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.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:327)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at discussion.BoardManager.<init>(BoardManager.java:27)
at discussion.BoardManager.main(BoardManager.java:131)

[b]Debug level Hibernate log excerpt:[/b]


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

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.