2 // Mainsoft.Data.Jdbc.Providers.OracleProvider
5 // Konstantin Triger <kostat@mainsoft.com>
6 // Boris Kirzner <borisk@mainsoft.com>
8 // (C) 2006 Mainsoft Corporation (http://www.mainsoft.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Collections
;
34 using Mainsoft
.Data
.Configuration
;
35 using System
.Reflection
;
37 namespace Mainsoft
.Data
.Jdbc
.Providers
39 public class OracleProvider
: GenericProvider
43 private const string Port
= "Port";
53 public OracleProvider (IDictionary providerInfo
) : base (providerInfo
)
57 #endregion // Constructors
61 #endregion // Properties
65 public override IConnectionStringDictionary
GetConnectionStringBuilder (string connectionString
)
67 IConnectionStringDictionary conectionStringBuilder
= base.GetConnectionStringBuilder (connectionString
);
69 string port
= (string) conectionStringBuilder
[Port
];
70 if (port
== null || port
.Length
== 0) {
71 port
= (string) ProviderInfo
[Port
];
72 conectionStringBuilder
.Add (Port
, port
);
75 return conectionStringBuilder
;
78 public override java
.sql
.Connection
GetConnection(IConnectionStringDictionary conectionStringBuilder
) {
79 return new OracleConnection(base.GetConnection (conectionStringBuilder
));
85 #region OracleConnection
87 sealed class OracleConnection
: Connection
{
89 public OracleConnection(java
.sql
.Connection connection
)
92 public override java
.sql
.CallableStatement
prepareCall(string arg_0
) {
93 return base.prepareCall (arg_0
);
96 public override java
.sql
.CallableStatement
prepareCall(string arg_0
, int arg_1
, int arg_2
) {
97 return new OracleCallableStatement(base.prepareCall (arg_0
, arg_1
, arg_2
));
100 public override java
.sql
.CallableStatement
prepareCall(string arg_0
, int arg_1
, int arg_2
, int arg_3
) {
101 return new OracleCallableStatement(base.prepareCall (arg_0
, arg_1
, arg_2
, arg_3
));
104 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
) {
105 return new OraclePreparedStatement(base.prepareStatement (arg_0
));
108 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
, int arg_1
) {
109 return new OraclePreparedStatement(base.prepareStatement (arg_0
, arg_1
));
112 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
, int arg_1
, int arg_2
) {
113 return new OraclePreparedStatement(base.prepareStatement (arg_0
, arg_1
, arg_2
));
116 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
, int arg_1
, int arg_2
, int arg_3
) {
117 return new OraclePreparedStatement(base.prepareStatement (arg_0
, arg_1
, arg_2
, arg_3
));
120 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
, int[] arg_1
) {
121 return new OraclePreparedStatement(base.prepareStatement (arg_0
, arg_1
));
124 public override java
.sql
.PreparedStatement
prepareStatement(string arg_0
, string[] arg_1
) {
125 return new OraclePreparedStatement(base.prepareStatement (arg_0
, arg_1
));
131 sealed class OraclePreparedStatement
: PreparedStatement
, IPreparedStatement
{
132 readonly MethodInfo _info
;
134 public OraclePreparedStatement(java
.sql
.PreparedStatement statement
)
136 _info
= Wrapped
.GetType().GetMethod("setFixedCHAR");
139 #region IPreparedStatement Members
141 public void setBit(int parameterIndex
, int value) {
142 base.setInt(parameterIndex
, value);
145 public void setChar(int parameterIndex
, string value) {
147 base.setString(parameterIndex
, value);
151 _info
.Invoke(Wrapped
, new object[] {
152 new java
.lang
.Integer(parameterIndex
),
156 public void setNumeric(int parameterIndex
, java
.math
.BigDecimal
value) {
157 base.setBigDecimal(parameterIndex
, value);
160 public void setReal(int parameterIndex
, double value) {
161 base.setDouble(parameterIndex
, value);
167 sealed class OracleCallableStatement
: CallableStatement
, IPreparedStatement
{
168 readonly MethodInfo _info
;
170 public OracleCallableStatement(java
.sql
.CallableStatement statement
)
172 _info
= Wrapped
.GetType().GetMethod("setFixedCHAR");
175 #region IPreparedStatement Members
177 public void setBit(int parameterIndex
, int value) {
178 base.setInt(parameterIndex
, value);
181 public void setChar(int parameterIndex
, string value) {
183 base.setString(parameterIndex
, value);
187 _info
.Invoke(Wrapped
, new object[] {
188 new java
.lang
.Integer(parameterIndex
),
192 public void setNumeric(int parameterIndex
, java
.math
.BigDecimal
value) {
193 base.setBigDecimal(parameterIndex
, value);
196 public void setReal(int parameterIndex
, double value) {
197 base.setDouble(parameterIndex
, value);