diff options
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 8e91693..b39bb19 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | |||
@@ -48,16 +48,33 @@ 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 | m_Connection.Open(); | ||
63 | |||
64 | if (storeName != String.Empty) | ||
65 | { | ||
66 | Assembly assem = GetType().Assembly; | ||
67 | SqliteConnection newConnection = | ||
68 | (SqliteConnection)((ICloneable)m_Connection).Clone(); | ||
69 | newConnection.Open(); | ||
70 | |||
71 | Migration m = new Migration(newConnection, assem, storeName); | ||
72 | m.Update(); | ||
73 | newConnection.Close(); | ||
74 | newConnection.Dispose(); | ||
75 | } | ||
58 | 76 | ||
59 | Migration m = new Migration(m_Connection, assem, storeName); | 77 | m_initialized = true; |
60 | m.Update(); | ||
61 | } | 78 | } |
62 | 79 | ||
63 | Type t = typeof(T); | 80 | Type t = typeof(T); |
@@ -125,7 +142,7 @@ namespace OpenSim.Data.SQLite | |||
125 | 142 | ||
126 | protected T[] DoQuery(SqliteCommand cmd) | 143 | protected T[] DoQuery(SqliteCommand cmd) |
127 | { | 144 | { |
128 | IDataReader reader = ExecuteReader(cmd); | 145 | IDataReader reader = ExecuteReader(cmd, m_Connection); |
129 | if (reader == null) | 146 | if (reader == null) |
130 | return new T[0]; | 147 | return new T[0]; |
131 | 148 | ||
@@ -180,7 +197,7 @@ namespace OpenSim.Data.SQLite | |||
180 | result.Add(row); | 197 | result.Add(row); |
181 | } | 198 | } |
182 | 199 | ||
183 | CloseReaderCommand(cmd); | 200 | CloseCommand(cmd); |
184 | 201 | ||
185 | return result.ToArray(); | 202 | return result.ToArray(); |
186 | } | 203 | } |
@@ -229,7 +246,7 @@ namespace OpenSim.Data.SQLite | |||
229 | 246 | ||
230 | cmd.CommandText = query; | 247 | cmd.CommandText = query; |
231 | 248 | ||
232 | if (ExecuteNonQuery(cmd) > 0) | 249 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
233 | return true; | 250 | return true; |
234 | 251 | ||
235 | return false; | 252 | return false; |
@@ -242,7 +259,7 @@ namespace OpenSim.Data.SQLite | |||
242 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); | 259 | cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field); |
243 | cmd.Parameters.Add(new SqliteParameter(field, val)); | 260 | cmd.Parameters.Add(new SqliteParameter(field, val)); |
244 | 261 | ||
245 | if (ExecuteNonQuery(cmd) > 0) | 262 | if (ExecuteNonQuery(cmd, m_Connection) > 0) |
246 | return true; | 263 | return true; |
247 | 264 | ||
248 | return false; | 265 | return false; |