aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
diff options
context:
space:
mode:
authorlbsa712008-02-13 13:39:51 +0000
committerlbsa712008-02-13 13:39:51 +0000
commit4880bd121e737e0a5c384fddf61bd220c77ef88a (patch)
treec3597cb34642611869ff26c559708a45956fa4cc /OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
parent* Added openlifegrid.com to testers and patchers (diff)
downloadopensim-SC_OLD-4880bd121e737e0a5c384fddf61bd220c77ef88a.zip
opensim-SC_OLD-4880bd121e737e0a5c384fddf61bd220c77ef88a.tar.gz
opensim-SC_OLD-4880bd121e737e0a5c384fddf61bd220c77ef88a.tar.bz2
opensim-SC_OLD-4880bd121e737e0a5c384fddf61bd220c77ef88a.tar.xz
* Split out MSSQLManager Test/Init into each provider.
* Made regions table name configurable (MSSQL only) * Added a note in ini.example pointing out that the sql resources have to change if you change table names * Removed duplicate picker method from GridData interface [Provided by openlifegrid.com]
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLManager.cs67
1 files changed, 1 insertions, 66 deletions
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
index e54cde1..5c3e94f 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs
@@ -52,16 +52,8 @@ namespace OpenSim.Framework.Data.MSSQL
52 /// <summary> 52 /// <summary>
53 /// Connection string for ADO.net 53 /// Connection string for ADO.net
54 /// </summary> 54 /// </summary>
55 private string connectionString; 55 private readonly string connectionString;
56 56
57 /// <summary>
58 /// Initialises and creates a new Sql connection and maintains it.
59 /// </summary>
60 /// <param name="hostname">The Sql server being connected to</param>
61 /// <param name="database">The name of the Sql database being used</param>
62 /// <param name="username">The username logging into the database</param>
63 /// <param name="password">The password for the user logging in</param>
64 /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
65 public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId, 57 public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId,
66 string password) 58 string password)
67 { 59 {
@@ -71,7 +63,6 @@ namespace OpenSim.Framework.Data.MSSQL
71 ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" + 63 ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" +
72 password + ";"; 64 password + ";";
73 dbcon = new SqlConnection(connectionString); 65 dbcon = new SqlConnection(connectionString);
74 TestTables(dbcon);
75 dbcon.Open(); 66 dbcon.Open();
76 } 67 }
77 catch (Exception e) 68 catch (Exception e)
@@ -80,61 +71,6 @@ namespace OpenSim.Framework.Data.MSSQL
80 } 71 }
81 } 72 }
82 73
83 private bool TestTables(IDbConnection conn)
84 {
85 IDbCommand cmd = Query("SELECT * FROM regions", new Dictionary<string, string>());
86 //SqlCommand cmd = (SqlCommand)dbcon.CreateCommand();
87 //cmd.CommandText = "SELECT * FROM regions";
88 try
89 {
90 conn.Open();
91 cmd.ExecuteNonQuery();
92 cmd.Dispose();
93 conn.Close();
94 }
95 catch (Exception)
96 {
97 m_log.Info("[DATASTORE]: MSSQL Database doesn't exist... creating");
98 InitDB(conn);
99 }
100 cmd = Query("select top 1 webLoginKey from users", new Dictionary<string, string>());
101 try
102 {
103 conn.Open();
104 cmd.ExecuteNonQuery();
105 cmd.Dispose();
106 conn.Close();
107 }
108 catch (Exception)
109 {
110 conn.Open();
111 cmd = Query("alter table users add column [webLoginKey] varchar(36) default NULL", new Dictionary<string, string>());
112 cmd.ExecuteNonQuery();
113 cmd.Dispose();
114 conn.Close();
115 }
116 return true;
117 }
118
119 private void InitDB(IDbConnection conn)
120 {
121 string createRegions = defineTable(createRegionsTable());
122 Dictionary<string, string> param = new Dictionary<string, string>();
123 IDbCommand pcmd = Query(createRegions, param);
124 if (conn.State == ConnectionState.Closed)
125 {
126 conn.Open();
127 }
128 pcmd.ExecuteNonQuery();
129 pcmd.Dispose();
130
131 ExecuteResourceSql("Mssql-users.sql");
132 ExecuteResourceSql("Mssql-agents.sql");
133 ExecuteResourceSql("Mssql-logs.sql");
134
135 conn.Close();
136 }
137
138 private DataTable createRegionsTable() 74 private DataTable createRegionsTable()
139 { 75 {
140 DataTable regions = new DataTable("regions"); 76 DataTable regions = new DataTable("regions");
@@ -253,7 +189,6 @@ namespace OpenSim.Framework.Data.MSSQL
253 { 189 {
254 try 190 try
255 { 191 {
256 //string connectionString = "Data Source=WRK-OU-738\\SQLEXPRESS;Initial Catalog=rex;Persist Security Info=True;User ID=sa;Password=rex";
257 // Close the DB connection 192 // Close the DB connection
258 dbcon.Close(); 193 dbcon.Close();
259 // Try reopen it 194 // Try reopen it