diff options
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs deleted file mode 100644 index 78761be..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008 Intel Corporation | ||
3 | * All rights reserved. | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * -- Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * -- Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * -- Neither the name of the Intel Corporation nor the names of its | ||
14 | * contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Xml; | ||
32 | using ExtensionLoader.Config; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | |||
35 | namespace OpenSim.Grid.AssetInventoryServer.Extensions | ||
36 | { | ||
37 | public static class DBConnString | ||
38 | { | ||
39 | private static string connectionString; | ||
40 | |||
41 | /// <summary> | ||
42 | /// Parses the MySQL connection string out of either the asset server | ||
43 | /// .ini or a OpenSim-style .xml file and caches the result for future | ||
44 | /// requests | ||
45 | /// </summary> | ||
46 | public static string GetConnectionString(IniConfigSource configFile) | ||
47 | { | ||
48 | if (connectionString == null) | ||
49 | { | ||
50 | // Try parsing from the ini file | ||
51 | try | ||
52 | { | ||
53 | // Load the extension list (and ordering) from our config file | ||
54 | IConfig extensionConfig = configFile.Configs["MySQL"]; | ||
55 | connectionString = extensionConfig.GetString("database_connect", null); | ||
56 | } | ||
57 | catch (Exception) { } | ||
58 | |||
59 | if (connectionString != null) | ||
60 | { | ||
61 | // Force MySQL's broken connection pooling off | ||
62 | MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(connectionString); | ||
63 | builder.Pooling = false; | ||
64 | if (String.IsNullOrEmpty(builder.Database)) | ||
65 | Logger.Log.Error("No database selected in the connectionString: " + connectionString); | ||
66 | connectionString = builder.ToString(); | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | Logger.Log.Error("Database connection string is missing, check that the database_connect line is " + | ||
71 | "correct and uncommented in AssetInventoryServer.ini"); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return connectionString; | ||
76 | } | ||
77 | } | ||
78 | } | ||