Skip to content

Commit 236a275

Browse files
author
Mike Doerfler
committed
Added better error messages for situation where required assemblies to
create the connection and command are not in the bin or gac. SVN: trunk@1149
1 parent 41c9810 commit 236a275

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

src/NHibernate/Driver/FirebirdDriver.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Data;
3-
using System.Reflection;
42

53
namespace NHibernate.Driver
64
{
@@ -16,6 +14,16 @@ public FirebirdDriver()
1614
{
1715
connectionType = System.Type.GetType("FirebirdSql.Data.Firebird.FbConnection, FirebirdSql.Data.Firebird");
1816
commandType = System.Type.GetType("FirebirdSql.Data.Firebird.FbCommand, FirebirdSql.Data.Firebird");
17+
18+
if( connectionType==null || commandType==null )
19+
{
20+
throw new HibernateException(
21+
"The IDbCommand and IDbConnection implementation in the Assembly FirebirdSql.Data could not be found. " +
22+
"Please ensure that the Assemblies needed to communicate with Firebird " +
23+
"are in the Global Assembly Cache or in a location that NHibernate " +
24+
"can use System.Type.GetType(string) to load the types from."
25+
);
26+
}
1927
}
2028

2129
public override System.Type CommandType

src/NHibernate/Driver/MySqlDataDriver.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
using System;
2-
using System.Data;
3-
using System.Reflection;
4-
5-
using NHibernate.Dialect;
6-
using NHibernate.SqlCommand;
72

83
namespace NHibernate.Driver
94
{
@@ -18,7 +13,8 @@ namespace NHibernate.Driver
1813
/// the Assembly <c>MySql.Data.dll</c>.
1914
/// </p>
2015
/// <p>
21-
/// Please check the products website <a href="http://www.mysql.com/products/connector/net/">http://www.mysql.com/products/connector/net/</a>
16+
/// Please check the products website
17+
/// <a href="http://www.mysql.com/products/connector/net/">http://www.mysql.com/products/connector/net/</a>
2218
/// for any updates and or documentation.
2319
/// </p>
2420
/// </remarks>
@@ -31,6 +27,16 @@ public MySqlDataDriver()
3127
{
3228
connectionType = System.Type.GetType("MySql.Data.MySqlClient.MySqlConnection, MySql.Data");
3329
commandType = System.Type.GetType("MySql.Data.MySqlClient.MySqlCommand, MySql.Data");
30+
31+
if( connectionType==null || commandType==null )
32+
{
33+
throw new HibernateException(
34+
"The IDbCommand and IDbConnection implementation in the Assembly MySql.Data could not be found. " +
35+
"Please ensure that the Assemblies MySql.Data.dll and ICSharpCode.SharpZipLib.dll " +
36+
"are in the Global Assembly Cache or in a location that NHibernate " +
37+
"can use System.Type.GetType(string) to load the types from."
38+
);
39+
}
3440
}
3541

3642
public override System.Type CommandType
@@ -44,26 +50,33 @@ public override System.Type ConnectionType
4450
}
4551

4652
/// <summary>
47-
/// MySqlData does not use named parameters in the sql.
53+
/// MySql.Data uses named parameters in the sql.
4854
/// </summary>
49-
/// <value><c>false</c> becuase MySql uses <c>?</c> in the sql.</value>
55+
/// <value><c>true</c> - MySql uses <c>?</c> in the sql.</value>
5056
public override bool UseNamedPrefixInSql
5157
{
5258
get {return true;}
5359
}
5460

61+
/// <summary>
62+
///
63+
/// </summary>
5564
public override bool UseNamedPrefixInParameter
5665
{
5766
get {return true;}
5867
}
5968

69+
/// <summary>
70+
/// MySql.Data use the <c>?</c> to locate parameters in sql.
71+
/// </summary>
72+
/// <value><c>?</c> is used to locate parameters in sql.</value>
6073
public override string NamedPrefix
6174
{
6275
get {return "?";}
6376
}
6477

6578
/// <summary>
66-
/// The ByteFX driver does NOT support more than 1 open IDataReader
79+
/// The MySql.Data driver does NOT support more than 1 open IDataReader
6780
/// with only 1 IDbConnection.
6881
/// </summary>
6982
/// <value><c>false</c> - it is not supported.</value>
@@ -76,6 +89,7 @@ public override bool SupportsMultipleOpenReaders
7689
/// With the Gamma MySql.Data provider it is throwing an exception with the
7790
/// message "Expected End of data packet" when a select command is prepared.
7891
/// </summary>
92+
/// <value><c>false</c> - it is not supported.</value>
7993
public override bool SupportsPreparingCommands
8094
{
8195
get { return false; }

src/NHibernate/Driver/NpgsqlDriver.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Data;
3-
using System.Reflection;
42

53
namespace NHibernate.Driver
64
{
@@ -16,7 +14,8 @@ namespace NHibernate.Driver
1614
/// NHibernate to load it.
1715
/// </p>
1816
/// <p>
19-
/// Please check the products website <a href="http://www.postgresql.org/">http://www.postgresql.org/</a>
17+
/// Please check the products website
18+
/// <a href="http://www.postgresql.org/">http://www.postgresql.org/</a>
2019
/// for any updates and or documentation.
2120
/// </p>
2221
/// <p>
@@ -33,6 +32,16 @@ public NpgsqlDriver()
3332
{
3433
connectionType = System.Type.GetType("Npgsql.NpgsqlConnection, Npgsql");
3534
commandType = System.Type.GetType("Npgsql.NpgsqlCommand, Npgsql");
35+
36+
if( connectionType==null || commandType==null )
37+
{
38+
throw new HibernateException(
39+
"The IDbCommand and IDbConnection implementation in the Assembly Npgsql.dll could not be found. " +
40+
"Please ensure that the Assemblies needed to communicate with PostgreSQL " +
41+
"are in the Global Assembly Cache or in a location that NHibernate " +
42+
"can use System.Type.GetType(string) to load the types from."
43+
);
44+
}
3645
}
3746

3847
public override System.Type CommandType

src/NHibernate/Driver/OracleClientDriver.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
namespace NHibernate.Driver
66
{
77
/// <summary>
8-
/// A NHibernate Driver for using the Oracle DataProvider
9-
/// <see cref="System.Data.OracleClient.OracleConnection"/>.
8+
/// A NHibernate Driver for using the Oracle DataProvider.
109
/// </summary>
1110
public class OracleClientDriver: DriverBase
1211
{

0 commit comments

Comments
 (0)