From 1b7f1c956c86458bc0cee341ea95ee593be76703 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 2 May 2008 18:59:12 +0000 Subject: plumb in connection string to the user database paths. mysql and mssql just ignore this for now, but it lets us get connect strings to sqlite and nhibernate. --- OpenSim/Data/MSSQL/MSSQLUserData.cs | 7 ++++--- OpenSim/Data/MySQL/MySQLUserData.cs | 6 +++--- OpenSim/Data/NHibernate/NHibernateUserData.cs | 18 ++++++++++++------ OpenSim/Data/SQLite/SQLiteUserData.cs | 8 ++++++-- OpenSim/Data/UserDataBase.cs | 2 +- 5 files changed, 26 insertions(+), 15 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs index a4c5068..d54af82 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs @@ -55,10 +55,11 @@ namespace OpenSim.Data.MSSQL /// /// Loads and initialises the MySQL storage plugin /// - override public void Initialise() + override public void Initialise(string connect) { - // Load from an INI file connection details - // TODO: move this to XML? + // TODO: do something with the connect string instead of + // ignoring it. + IniFile iniFile = new IniFile("mssql_connection.ini"); string settingDataSource = iniFile.ParseFileReadValue("data_source"); string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index c374bf2..b448715 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -55,10 +55,10 @@ namespace OpenSim.Data.MySQL /// /// Loads and initialises the MySQL storage plugin /// - override public void Initialise() + override public void Initialise(string connect) { - // Load from an INI file connection details - // TODO: move this to XML? Yes, PLEASE! + // TODO: actually do something with our connect string + // instead of loading the second config IniFile iniFile = new IniFile("mysql_connection.ini"); string settingHostname = iniFile.ParseFileReadValue("hostname"); diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index 2e55e03..6a830f6 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -35,6 +36,7 @@ using NHibernate.Cfg; using NHibernate.Expression; using NHibernate.Mapping.Attributes; using OpenSim.Framework; +using Environment=NHibernate.Cfg.Environment; namespace OpenSim.Data.NHibernate { @@ -48,20 +50,24 @@ namespace OpenSim.Data.NHibernate private Configuration cfg; private ISessionFactory factory; - public override void Initialise() + public override void Initialise(string connect) { - // TODO: hard coding for sqlite based stuff to begin with, just making it easier to test + char[] split = {';'}; + string[] parts = connect.Split(split, 3); + if (parts.Length != 3) { + // TODO: make this a real exception type + throw new Exception("Malformed Inventory connection string '" + connect + "'"); + } // This is stubbing for now, it will become dynamic later and support different db backends cfg = new Configuration(); cfg.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider"); cfg.SetProperty(Environment.Dialect, - "NHibernate.Dialect.SQLiteDialect"); + "NHibernate.Dialect." + parts[0]); cfg.SetProperty(Environment.ConnectionDriver, - "NHibernate.Driver.SqliteClientDriver"); - cfg.SetProperty(Environment.ConnectionString, - "URI=file:User.db,version=3"); + "NHibernate.Driver." + parts[1]); + cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); HbmSerializer.Default.Validate = true; diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index bca5401..aa7a849 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -64,9 +64,13 @@ namespace OpenSim.Data.SQLite private SqliteDataAdapter daf; SqliteConnection g_conn; - override public void Initialise() + override public void Initialise(string connect) { - SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); + // default to something sensible + if (connect == "") + connect = "URI=file:userprofiles.db,version=3"; + + SqliteConnection conn = new SqliteConnection(connect); TestTables(conn); // This sucks, but It doesn't seem to work with the dataset Syncing :P diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index fc33376..2ddeccf 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs @@ -51,7 +51,7 @@ namespace OpenSim.Data public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); public abstract string Version {get;} public abstract string Name {get;} - public abstract void Initialise(); + public abstract void Initialise(string connect); public abstract List GeneratePickerResults(LLUUID queryID, string query); public abstract UserAppearance GetUserAppearance(LLUUID user); public abstract void UpdateUserAppearance(LLUUID user, UserAppearance appearance); -- cgit v1.1