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: "NHibernate provided connection" doesn't work
PostPosted: Tue Aug 08, 2006 6:14 am 
Newbie

Joined: Tue Aug 08, 2006 5:51 am
Posts: 9
Hi,

I'm trying to connect NHibernate to a MySQL database, following the lead of the NHibernate Quick Start Guide.
It works fine using a user provided connection like this:
ISession session = factory.OpenSession(myConnection);

However when using a NHibernate provided connection ( ISession session = factory.OpenSession();) I get an error "cannot open connection" when starting a transaction or simply accessing the database.
I get the same error when trying to access the session.Connection property (so I can't check it either).

The session.IsOpen and session.IsConnected properties are both true.
A correct connectionstring is provided through the app.config file and it is verified to be present in the Configuration object.

NHibernate newbie, using Visual Studio 2005, C#, MySQL 4.1.1.13a-nt, MySQL connector/NET 1.0.07, NHibernate 1.0.2.
I tried different connection strings, moving/copying/reinstalling assemblies, several other tutorials but the problem remains.

What am I missing?

Your help is much appreciated.
Regards Tonn.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 7:41 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Please post the entire exception information, including stack trace and inner exceptions.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 8:35 am 
Newbie

Joined: Tue Aug 08, 2006 5:51 am
Posts: 9
Thanks, Sergey. Good tip!

Hadn't gone deep enough.
FYI: "cannot open connection" > "Could not create connection from Driver" > #42000Unknown character set: 'Win1250'

MySQL doesn't support this character set. Nor does id support Win1252 or iso-8859-1. There is an impressive amount of NHibernate / MySQL examples around that can't work.

Solution: do not specify a CharSet (which is using the default) or specify 'latin1' if you want to use codepage 1252 like I do.
Find character sets supported by MySQL here: http://dev.mysql.com/doc/refman/5.1/en/charset-charsets.html


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.