-->
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: Connecting to MySQL
PostPosted: Mon Mar 19, 2007 12:44 pm 
Newbie

Joined: Mon Mar 19, 2007 12:37 pm
Posts: 1
Hi,

I am having some difficulty connecting to a MySQL database using NHibernate.

I get the error:

Quote:
"Could not create the driver from NHibernate.Driver.MySqlDataDriver"


I have searched for reasons why this might be, and have included MySQL.Data as a reference in the project, but nothing I try seems to resolve the problem.

The more specific inner exception is:

Quote:
"The IDbCommand and IDbConnection implementation in the assembly MySql.Data could not be found. Ensure that the assembly MySql.Data is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly."


I have used the following method to connect to the database:

Code:
         props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
            props["hibernate.dialect"] = "NHibernate.Dialect.MySQLDialect";
            props["hibernate.connection.driver_class"] = "NHibernate.Driver.MySqlDataDriver";
         props["hibernate.connection.connection_string"] = "Server=localhost;Database=mydatabase;User ID=myusername;Password=mypassword;CharSet=win1250" ;


Where mydatabase, myusername and mypassword are replaced by their correct equivalents.


Any assitance you might be able to give would be gratefully appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 12:15 pm 
Newbie

Joined: Thu Aug 10, 2006 12:27 pm
Posts: 8
You need to get the MySql.Data.dll from the Mysql site, it is the ado.net driver that the nhibernate will use to talk to your mysql db. You can get it from http://dev.mysql.com/downloads/connector/net/5.0.html.

That dll has to be where nhibernate can find it. I usually have it to be always copied to the bin directory of the application. Not sure what others do ...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 10:38 am 
Newbie

Joined: Mon May 14, 2007 10:34 am
Posts: 3
This was a tricky one for us - remember to have mysql.data in your OUTPUT APPLICATION directory, NOT just referenced in your library. I.e. the actual startup project also needs a reference to it.


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.