In .:
[mono.git] / mcs / class / System.Data / Test / DataProviderTests / datareadertests / OdbcDataReaderTest.cs
1 //
2 // OdbcDataReaderTest.cs 
3 //
4 // Author:
5 //   Satya Sudha K (ksathyasudha@novell.com)
6 //
7 //
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.Data;
32 using System.Data.Odbc;
33
34 namespace MonoTests.System.Data {
35         
36         public class MySqlOdbcRetrieve : MySqlRetrieve {
37                 
38                 public MySqlOdbcRetrieve (string database) : base (database) 
39                 {
40                 }
41                 
42                 // returns a Open connection 
43                 public override void GetConnection () 
44                 {
45                         string connectionString = null;
46                         try {
47                                 connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
48                         } catch (Exception e) {
49                                 Console.WriteLine ("Error reading the config file"); 
50                                 Console.WriteLine (e.Message);
51                                 return;
52                         }
53                         
54                         con = new OdbcConnection (connectionString);
55                         try {
56                                 con.Open ();
57                         } catch (Exception e) {
58                                 Console.WriteLine ("Cannot establish connection with the database");
59                                 con = null;
60                         }
61                 }
62         }
63         
64         public class MsSqlOdbcRetrieve : MsSqlRetrieve {
65                 
66                 public MsSqlOdbcRetrieve (string database) : base (database) 
67                 {
68                 }
69                 
70                 // returns a Open connection 
71                 public override void GetConnection () 
72                 {
73                         string connectionString = null;
74                         try {
75                                 connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
76                         } catch (Exception e) {
77                                 Console.WriteLine ("Error reading the config file");
78                                 Console.WriteLine (e.Message);
79                                 return;
80                         }
81
82                         con = new OdbcConnection (connectionString);
83                         try {
84                                 con.Open ();
85                         } catch (Exception e) {
86                                 Console.WriteLine ("Cannot establish connection with the database");
87                                 con = null;
88                         }
89                 }
90         }
91
92         public class OracleOdbcRetrieve : OraRetrieve {
93                 
94                 public OracleOdbcRetrieve (string database) : base (database) 
95                 {
96                 }
97                 
98                 // returns a Open connection 
99                 public override void GetConnection () 
100                 {
101                         string connectionString = null;
102                         try {
103                                 connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
104                         } catch (Exception e) {
105                                 Console.WriteLine ("Error reading the config file");
106                                 Console.WriteLine (e.Message);
107                                 return;
108                         }
109
110                         con = new OdbcConnection (connectionString);
111
112                         try {
113                                 con.Open ();
114                         } catch (Exception e) {
115                                 Console.WriteLine ("Cannot establish connection with the database");
116                                 con = null;
117                         }
118                 }
119         }
120
121         public class PostgreOdbcRetrieve : MySqlRetrieve {
122                 
123                 public PostgreOdbcRetrieve (string database) : base (database) 
124                 {
125                 }
126                 
127                 // returns a Open connection 
128                 public override void GetConnection () 
129                 {
130
131                         string connectionString = null;
132                         try {
133                                 connectionString = ConfigClass.GetElement (configDoc, "database", "OdbcConnString");
134                         } catch (Exception e) {
135                                 Console.WriteLine ("Error reading the config file");
136                                 Console.WriteLine (e.Message);
137                                 return;
138                         }
139                         
140                         con = new OdbcConnection (connectionString);
141                         try {
142                                 con.Open ();
143                         } catch (Exception e) {
144                                 Console.WriteLine ("Cannot establish connection with the database");
145                                 con = null;
146                         }
147                 }
148         }
149 }