aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs37
1 files changed, 28 insertions, 9 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 8e91693..9b8e2fa 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Mono.Data.SqliteClient; 33using Mono.Data.Sqlite;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
@@ -48,16 +48,35 @@ namespace OpenSim.Data.SQLite
48 protected string m_Realm; 48 protected string m_Realm;
49 protected FieldInfo m_DataField = null; 49 protected FieldInfo m_DataField = null;
50 50
51 protected static SqliteConnection m_Connection;
52 private static bool m_initialized;
53
51 public SQLiteGenericTableHandler(string connectionString, 54 public SQLiteGenericTableHandler(string connectionString,
52 string realm, string storeName) : base(connectionString) 55 string realm, string storeName) : base(connectionString)
53 { 56 {
54 m_Realm = realm; 57 m_Realm = realm;
55 if (storeName != String.Empty) 58
59 if (!m_initialized)
56 { 60 {
57 Assembly assem = GetType().Assembly; 61 m_Connection = new SqliteConnection(connectionString);
62 //Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
63 m_Connection.Open();
64
65 if (storeName != String.Empty)
66 {
67 Assembly assem = GetType().Assembly;
68 //SqliteConnection newConnection =
69 // (SqliteConnection)((ICloneable)m_Connection).Clone();
70 //newConnection.Open();
71
72 //Migration m = new Migration(newConnection, assem, storeName);
73 Migration m = new Migration(m_Connection, assem, storeName);
74 m.Update();
75 //newConnection.Close();
76 //newConnection.Dispose();
77 }
58 78
59 Migration m = new Migration(m_Connection, assem, storeName); 79 m_initialized = true;
60 m.Update();
61 } 80 }
62 81
63 Type t = typeof(T); 82 Type t = typeof(T);
@@ -125,7 +144,7 @@ namespace OpenSim.Data.SQLite
125 144
126 protected T[] DoQuery(SqliteCommand cmd) 145 protected T[] DoQuery(SqliteCommand cmd)
127 { 146 {
128 IDataReader reader = ExecuteReader(cmd); 147 IDataReader reader = ExecuteReader(cmd, m_Connection);
129 if (reader == null) 148 if (reader == null)
130 return new T[0]; 149 return new T[0];
131 150
@@ -180,7 +199,7 @@ namespace OpenSim.Data.SQLite
180 result.Add(row); 199 result.Add(row);
181 } 200 }
182 201
183 CloseReaderCommand(cmd); 202 //CloseCommand(cmd);
184 203
185 return result.ToArray(); 204 return result.ToArray();
186 } 205 }
@@ -229,7 +248,7 @@ namespace OpenSim.Data.SQLite
229 248
230 cmd.CommandText = query; 249 cmd.CommandText = query;
231 250
232 if (ExecuteNonQuery(cmd) > 0) 251 if (ExecuteNonQuery(cmd, m_Connection) > 0)
233 return true; 252 return true;
234 253
235 return false; 254 return false;
@@ -242,7 +261,7 @@ namespace OpenSim.Data.SQLite
242 cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); 261 cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
243 cmd.Parameters.Add(new SqliteParameter(field, val)); 262 cmd.Parameters.Add(new SqliteParameter(field, val));
244 263
245 if (ExecuteNonQuery(cmd) > 0) 264 if (ExecuteNonQuery(cmd, m_Connection) > 0)
246 return true; 265 return true;
247 266
248 return false; 267 return false;