From: Alexander Köplinger Date: Thu, 7 Aug 2014 19:09:54 +0000 (+0200) Subject: [Cleanup] Removed files that imported Java namespaces X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=c685b217646d271e70063173171a98159109ab2b;p=mono.git [Cleanup] Removed files that imported Java namespaces They were once part of a special Java target profile, but this is no longer used today. --- diff --git a/mcs/class/Novell.Directory.Ldap/Makefile b/mcs/class/Novell.Directory.Ldap/Makefile index 725938c3522..7ecbff311e9 100644 --- a/mcs/class/Novell.Directory.Ldap/Makefile +++ b/mcs/class/Novell.Directory.Ldap/Makefile @@ -24,14 +24,6 @@ $(RESULTCODE_MESSAGES): Novell.Directory.Ldap.Utilclass/ResultCodeMessages.txt EXTRA_DISTFILES = \ Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs \ - Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs \ - Novell.Directory.Ldap.Security.jvm/ChangeLog \ - Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs \ - Novell.Directory.Ldap.Security.jvm/SecureStream.cs \ - Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs \ Novell.Directory.Ldap.Utilclass/ExceptionMessages.resx \ Novell.Directory.Ldap.Utilclass/ExceptionMessages.txt \ Novell.Directory.Ldap.Utilclass/ResultCodeMessages.resx \ diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes deleted file mode 100644 index f4322cac4e6..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/AuthenticationCallbackHandler.cs -crlf -/CreateContextPrivilegedAction.cs -crlf -/ExchangeTokenPrivilegedAction.cs -crlf -/Krb5Helper.cs -crlf -/SecureStream.cs -crlf -/UnwrapPrivilegedAction.cs -crlf -/WrapPrivilegedAction.cs -crlf diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs deleted file mode 100644 index 486ab61b5e2..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.AuthenticationCallbackHandler.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; - -using javax.security.auth.callback; -using java.io; - -namespace Novell.Directory.Ldap.Security -{ - internal class AuthenticationCallbackHandler : CallbackHandler - { - - #region Fields - - private readonly string _username; - private readonly string _password; - - #endregion //Fields - - #region Constructors - - public AuthenticationCallbackHandler(string username, string password) - { - _username = username; - _password = password; - } - - #endregion // Constructors - - #region Methods - - public void handle(Callback [] callbacks) - { - for (int i = 0; i < callbacks.Length; i++) { - if (callbacks [i] is NameCallback) { - NameCallback nc = (NameCallback) callbacks [i]; - nc.setName (_username); - } - else if (callbacks [i] is PasswordCallback) { - PasswordCallback pc = (PasswordCallback) callbacks [i]; - pc.setPassword (_password.ToCharArray ()); - } - else { - throw new UnsupportedCallbackException (callbacks [i], "Unrecognized Callback"); - } - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog deleted file mode 100644 index be95898738f..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog +++ /dev/null @@ -1,27 +0,0 @@ -2005-11-06 Konstantin Triger - - * SecureStream.cs, CreateContextPrivilegedAction.cs, Krb5Helper.cs: - create GSSCredential only once, cleanup - -2005-11-03 Konstantin Triger - - * CreateContextPrivilegedAction.cs: always require mutual auth; - require integrity by default. - * Krb5Helper.cs: for wrap/unwrap: always create MessageProp with - pribState set. - -2005-14-08 Boris Kirzner - * Krb5Helper.cs: ExchangeTokens does proper final handshaking. Wrap/Unwrap - perform no action if no integrity and encryption accured. - * SecureStream.cs: Private convertion methods became internal, used by - Krb5Helper. - -2005-28-07 Boris Kirzner - * Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/SecureStream.cs, - Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs, - Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs: added - new classes implementing kerberos authntication support. diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs deleted file mode 100644 index 73b280f5581..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Novell.Directory.Ldap.Security.CreateContextPrivilegedAction.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; - -using java.security; -using org.ietf.jgss; - -namespace Novell.Directory.Ldap.Security -{ - internal class CreateContextPrivilegedAction : PrivilegedAction - { - #region Fields - - private readonly bool _encryption; - private readonly bool _signing; - private readonly bool _delegation; - private readonly string _name; - private readonly string _clientName; - private readonly string _mech; - - #endregion //Fields - - #region Constructors - - public CreateContextPrivilegedAction(string name, string clientName, string mech, bool encryption, bool signing, bool delegation) - { - _name = name; - _clientName = clientName; - _mech = mech; - _encryption = encryption; - _signing = signing; - _delegation = delegation; - } - - #endregion // Constructors - - #region Methods - - public object run() - { - try { - Oid krb5Oid = new Oid (_mech); - GSSManager manager = GSSManager.getInstance (); - GSSName clientName = - manager.createName(_clientName, GSSName__Finals.NT_USER_NAME); - GSSCredential clientCreds = - manager.createCredential(clientName, - GSSContext__Finals.INDEFINITE_LIFETIME, - krb5Oid, - GSSCredential__Finals.INITIATE_ONLY); - -// try { - GSSName serverName = manager.createName (_name, GSSName__Finals.NT_HOSTBASED_SERVICE, krb5Oid); - GSSContext context = manager.createContext (serverName, krb5Oid, clientCreds, GSSContext__Finals.INDEFINITE_LIFETIME); - - context.requestMutualAuth(true); - context.requestConf (_encryption); - if (!_encryption || _signing) - context.requestInteg (!_encryption || _signing); - context.requestCredDeleg (_delegation); - - return context; -// } -// finally { -// // Calling this throws GSSException: Operation unavailable... -// clientCreds.dispose(); -// } - } - catch (GSSException e) { - throw new PrivilegedActionException (e); - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs deleted file mode 100644 index b806967f333..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Novell.Directory.Ldap.Security.ExchangeTokenPrivilegedAction.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; - -using org.ietf.jgss; -using java.security; - -namespace Novell.Directory.Ldap.Security -{ - internal class ExchangeTokenPrivilegedAction : PrivilegedAction - { - #region Fields - - private readonly sbyte [] _token; - private readonly GSSContext _context; - - #endregion // Fields - - #region Constructors - - public ExchangeTokenPrivilegedAction(GSSContext context, sbyte [] token) - { - _token = token; - _context = context; - } - - #endregion // Constructors - - #region Methods - - public object run() - { - try { - sbyte [] token = _context.initSecContext (_token, 0, _token.Length); - return token; - } - catch (GSSException e) { - throw new PrivilegedActionException (e); - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs deleted file mode 100644 index 9b58ff50d9e..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs +++ /dev/null @@ -1,197 +0,0 @@ -// -// Novell.Directory.Ldap.Security.Krb5Helper.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using vmw.common; - -using java.security; -using javax.security.auth; -using org.ietf.jgss; - - -namespace Novell.Directory.Ldap.Security -{ - internal class Krb5Helper : IDisposable - { - enum QOP { - NO_PROTECTION = 1, - INTEGRITY_ONLY_PROTECTION = 2, - PRIVACY_PROTECTION = 4 - } - - #region Fields - - internal static readonly sbyte [] EmptyToken = new sbyte [0]; - - private readonly bool _encryption; - private readonly bool _signing; - private readonly bool _delegation; - - private readonly GSSContext _context; - - #endregion // Fields - - #region Constructors - - public Krb5Helper(string name, string clientName, Subject subject, AuthenticationTypes authenticationTypes, string mech) - { - _encryption = (authenticationTypes & AuthenticationTypes.Sealing) != 0; - _signing = (authenticationTypes & AuthenticationTypes.Signing) != 0; - _delegation = (authenticationTypes & AuthenticationTypes.Delegation) != 0; - - CreateContextPrivilegedAction action = new CreateContextPrivilegedAction (name, clientName, mech,_encryption,_signing,_delegation); - try { - _context = (GSSContext) Subject.doAs (subject,action); - } - catch (PrivilegedActionException e) { - throw new LdapException ("Problem performing token exchange with the server",LdapException.OTHER,"",e.getCause()); - } - } - - #endregion // Constructors - - #region Properties - - internal GSSContext Context - { - get { return _context; } - } - - #endregion // Properties - - #region Methods - - public sbyte [] ExchangeTokens(sbyte [] clientToken) - { - if (Context.isEstablished ()) { - if (clientToken == null || clientToken.Length == 0) - return Krb5Helper.EmptyToken; - - //final handshake - byte [] challengeData = (byte []) TypeUtils.ToByteArray (clientToken); - byte [] gssOutToken = Unwrap (challengeData, 0, challengeData.Length, new MessageProp (false)); - - QOP myCop = QOP.NO_PROTECTION; - - if (_encryption) - myCop = QOP.PRIVACY_PROTECTION; - else if (_signing || (((QOP)gssOutToken [0] & QOP.INTEGRITY_ONLY_PROTECTION) != 0)) - myCop = QOP.INTEGRITY_ONLY_PROTECTION; - - if ((myCop & (QOP)gssOutToken [0]) == 0) - throw new LdapException ("Server does not support the requested security level", 80, ""); - - int srvMaxBufSize = SecureStream.NetworkByteOrderToInt (gssOutToken, 1, 3); - - //int rawSendSize = Context.getWrapSizeLimit(0, _encryption, srvMaxBufSize); - - byte [] gssInToken = new byte [4]; - gssInToken [0] = (byte) myCop; - - SecureStream.IntToNetworkByteOrder (srvMaxBufSize, gssInToken, 1, 3); - - gssOutToken = Wrap (gssInToken, 0, gssInToken.Length, new MessageProp (true)); - - return TypeUtils.ToSByteArray (gssOutToken); - } - - sbyte [] token = Context.initSecContext (clientToken, 0, clientToken.Length); - - if (Context.isEstablished ()) { - - if (Context.getConfState () != _encryption) - throw new LdapException ("Encryption protocol was not established layer between client and server", 80, ""); - - if (Context.getCredDelegState () != _delegation) - throw new LdapException ("Credential delegation was not established layer between client and server", 80, ""); - - if (_signing && (Context.getIntegState () != _signing)) - throw new LdapException ("Signing protocol was not established layer between client and server", 80, ""); - - if (token == null) - return EmptyToken; - } - return token; - } - - public byte [] Wrap(byte [] outgoing, int start, int len) - { - return Wrap (outgoing, start, len, new MessageProp(true)); - } - - public byte [] Wrap(byte [] outgoing, int start, int len, MessageProp messageProp) - { - if (!Context.isEstablished ()) - throw new LdapException ("GSSAPI authentication not completed",LdapException.OTHER,""); - - if (!(Context.getConfState () || Context.getIntegState ())) { - // in the case no encryption and no integrity required - return the original data - byte [] buff = new byte [len]; - Array.Copy (outgoing, start, buff, 0, len); - return buff; - } - - sbyte [] result = Context.wrap (TypeUtils.ToSByteArray (outgoing), start, len, messageProp); - return (byte []) TypeUtils.ToByteArray (result); - } - - public byte [] Unwrap(byte [] incoming, int start, int len) - { - return Unwrap (incoming, start, len, new MessageProp(true)); - } - - public byte [] Unwrap(byte [] incoming, int start, int len, MessageProp messageProp) - { - if (!Context.isEstablished ()) - throw new LdapException ("GSSAPI authentication not completed",LdapException.OTHER,""); - - if (!(Context.getConfState () || Context.getIntegState ())) { - // in the case no encryption and no integrity required - return the original data - byte [] buff = new byte [len]; - Array.Copy (incoming, start, buff, 0, len); - return buff; - } - - sbyte [] result = Context.unwrap (TypeUtils.ToSByteArray (incoming), start, len, messageProp); - return (byte []) TypeUtils.ToByteArray (result); - } - - #endregion // Methods - - #region IDisposable Members - - public void Dispose() { - Context.dispose(); - } - - #endregion - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs deleted file mode 100644 index 08a37e6718c..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs +++ /dev/null @@ -1,208 +0,0 @@ -// -// Novell.Directory.Ldap.Security.SecureStream.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.IO; - -namespace Novell.Directory.Ldap.Security -{ - internal class SecureStream : Stream - { - #region Fields - - private readonly Stream _stream; - private readonly Krb5Helper _helper; - - private readonly byte [] _lenBuf = new byte [4]; - private byte [] _buffer; - private int _bufferPosition; - - #endregion // Fields - - #region Constructors - - public SecureStream(Stream stream, Krb5Helper helper): base () - { - _stream = stream; - _helper = helper; - } - - #endregion // Constructors - - #region Properties - - public override bool CanRead - { - get { return _stream.CanRead; } - } - - public override bool CanSeek - { - get { return _stream.CanSeek; } - } - - public override bool CanWrite - { - get { return _stream.CanWrite; } - } - - public override long Length - { - get { throw new NotSupportedException (); } - } - - public override long Position - { - get { throw new NotSupportedException (); } - set { throw new NotSupportedException (); } - } - - #endregion // Properties - - #region Methods - - public override void Flush() - { - _stream.Flush (); - } - - public override int Read( byte [] buffer, int offset, int count) - { - if (_buffer == null || _bufferPosition >= _buffer.Length) { - int actual = Fill (); - while (actual == 0) - actual = Fill (); - - if (actual == -1) - return -1; - } - - int available = _buffer.Length - _bufferPosition; - if (count > available) { - Array.Copy (_buffer, _bufferPosition, buffer, offset, available); - _bufferPosition = _buffer.Length; - return available; - } - else { - Array.Copy (_buffer, _bufferPosition, buffer, offset, count); - _bufferPosition += count; - return count; - } - } - - public override void Close() { - _stream.Close(); - _helper.Dispose(); - } - - private int Fill() - { - int actual = ReadAll (_lenBuf, 4); - - if (actual != 4) - return -1; - - int length = NetworkByteOrderToInt (_lenBuf, 0, 4); - -// if (length > _recvMaxBufSize) -// throw new LdapException(length + " exceeds the negotiated receive buffer size limit: " + _recvMaxBufSize, 80, ""); - - byte [] rawBuffer = new byte [length]; - actual = ReadAll (rawBuffer, length); - - if (actual != length) - throw new LdapException("Expected to read " + length + " bytes, but get " + actual, 80, ""); - - _buffer = _helper.Unwrap (rawBuffer, 0, length); - _bufferPosition = 0; - return _buffer.Length; - } - - private int ReadAll(byte [] buffer, int total) - { - int count = 0; - int pos = 0; - while (total > 0) { - count = _stream.Read (buffer, pos, total); - - if (count == -1) - break; - //return ((pos == 0) ? -1 : pos); - - pos += count; - total -= count; - } - return pos; - } - - public override long Seek(long offset, SeekOrigin loc) - { - return _stream.Seek (offset, loc); - } - - public override void SetLength(long value) - { - _stream.SetLength (value); - } - - public override void Write(byte [] buffer, int offset, int count) - { - // FIXME: use GSSCOntext.getWrapSizeLimit to divide the buffer - // Generate wrapped token - byte [] wrappedToken = _helper.Wrap (buffer, offset, count); - // Write out length - IntToNetworkByteOrder (wrappedToken.Length, _lenBuf, 0, 4); - _stream.Write (_lenBuf, 0, 4); - // Write out wrapped token - _stream.Write (wrappedToken, 0, wrappedToken.Length); - } - - internal static int NetworkByteOrderToInt(byte [] buf, int start, int count) - { - int answer = 0; - for (int i = 0; i < count; i++) { - answer <<= 8; - answer |= ((int)buf [start + i] & 0xff); - } - return answer; - } - - internal static void IntToNetworkByteOrder(int num, byte [] buf, int start, int count) - { - for (int i = count-1; i >= 0; i--) { - buf [start + i] = (byte)(num & 0xff); - num >>= 8; - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs deleted file mode 100644 index 7320678c9b9..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.UnwrapPrivilegedAction.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using vmw.common; - -using java.security; -using org.ietf.jgss; - -namespace Novell.Directory.Ldap.Security -{ - internal class UnwrapPrivilegedAction : PrivilegedAction - { - #region Fields - - private readonly byte [] _buffer; - private readonly int _start; - private readonly int _len; - private readonly GSSContext _context; - private readonly MessageProp _messageProperties; - - #endregion // Fields - - #region Constructors - - public UnwrapPrivilegedAction(GSSContext context, byte [] buffer, int start, int len, MessageProp messageProperties) - { - _buffer = buffer; - _start = start; - _len = len; - _context = context; - _messageProperties = messageProperties; - } - - #endregion // Constructors - - #region Methods - - public object run() - { - try { - sbyte [] result = _context.unwrap (TypeUtils.ToSByteArray (_buffer), _start, _len, _messageProperties); - return (byte []) TypeUtils.ToByteArray (result); - } - catch (GSSException e) { - throw new PrivilegedActionException (e); - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs deleted file mode 100644 index 8ec5a616765..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.WrapPrivilegedAction.cs -// -// Authors: -// Boris Kirzner -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using vmw.common; - -using java.security; -using org.ietf.jgss; - -namespace Novell.Directory.Ldap.Security -{ - internal class WrapPrivilegedAction : PrivilegedAction - { - #region Fields - - private readonly byte [] _buffer; - private readonly int _start; - private readonly int _len; - private readonly GSSContext _context; - private readonly MessageProp _messageProperties; - - #endregion // Fields - - #region Constructors - - public WrapPrivilegedAction(GSSContext context, byte [] buffer, int start, int len, MessageProp messageProperties) - { - _buffer = buffer; - _start = start; - _len = len; - _context = context; - _messageProperties = messageProperties; - } - - #endregion // Constructors - - #region Methods - - public object run() - { - try { - sbyte [] result = _context.wrap (TypeUtils.ToSByteArray (_buffer), _start, _len, _messageProperties); - return (byte []) TypeUtils.ToByteArray (result); - } - catch (GSSException e) { - throw new PrivilegedActionException (e); - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleCommand.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleCommand.cs deleted file mode 100644 index 1e59ffcf3a8..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleCommand.cs +++ /dev/null @@ -1,284 +0,0 @@ -// -// System.Data.OracleClient.OracleCommand -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; -using System.Globalization; - -using java.sql; -// Cannot use this because it makes ArrayList ambiguous reference -//using java.util; -#if !USE_DOTNET_REGEXP -using java.util.regex; -#endif - -namespace System.Data.OracleClient { - public sealed class OracleCommand : AbstractDbCommand { - - #region Fields -#if USE_DOTNET_REGEXP - internal static readonly Regex NamedParameterStoredProcedureRegExp = new Regex(@"^\s*{?\s*((?\:\w+)\s*=\s*)?call\s+(?(((\[[^\]]*\])|([^\.\(])*)\s*\.\s*){0,2}(\[[^\]]*\]|((\s*[^\.\(\)\{\}\s])+)))\s*(\(\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)?\s*(,\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)\s*)*\))?\s*}?\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); -#else - internal static readonly Pattern NamedParameterStoredProcedureRegExp = Pattern.compile(@"^\s*\{?\s*(?:(\:\w+)\s*=\s*)?call\s+((?:(?:(?:\[[^\]]*\])|(?:[^\.\(\)\{\}\[\]])*)\s*\.\s*){0,2}(?:\[[^\]]*\]|(?:(?:\s*[^\.\(\)\{\}\[\]])+)))\s*(?:\((.*)\))?\s*\}?\s*$", Pattern.CASE_INSENSITIVE); -#endif - internal static readonly SimpleRegex NamedParameterRegExp = new OracleParamsRegex(); - -// internal static readonly int oracleTypeRefCursor = java.sql.Types.OTHER; - - private int _currentParameterIndex = 0; - private ResultSet _currentRefCursor; - - #endregion // Fields - - #region Constructors - - /** - * Initializes a new instance of the OracleCommand class. - * The base constructor initializes all fields to their default values. - * The following table shows initial property values for an instance of SqlCommand. - */ - public OracleCommand() : this(null, null, null) { - } - - public OracleCommand(OracleConnection connection) : this(null, connection, null) { - } - - /** - * Initializes a new instance of the OracleCommand class with the text of the query. - * @param cmdText The text of the query. - */ - public OracleCommand(String cmdText) : this(cmdText, null, null) { - } - - /** - * Initializes a new instance of the OracleCommand class with the text of the query and a SqlConnection. - * @param cmdText The text of the query. - * @param connection A SqlConnection that represents the connection to an instance of SQL Server. - */ - public OracleCommand(String cmdText, OracleConnection connection) : this(cmdText, connection, null) { - } - - /** - * Initializes a new instance of the OracleCommand class with the text of the query, a SqlConnection, and the Transaction. - * @param cmdText The text of the query. - * @param connection A SqlConnection that represents the connection to an instance of SQL Server. - * @param transaction The SqlTransaction in which the OracleCommand executes. - */ - public OracleCommand( - String cmdText, - OracleConnection connection, - OracleTransaction transaction) - : base(cmdText, connection, transaction) { - } - - #endregion // Constructors - - #region Properties - - public new OracleConnection Connection { - get { return (OracleConnection)base.Connection; } - set { base.Connection = (AbstractDBConnection)value; } - } - - public new OracleParameterCollection Parameters { - get { - return (OracleParameterCollection)base.Parameters; - } - } - - public new OracleTransaction Transaction { - get { return (OracleTransaction)base.Transaction; } - set { base.Transaction = (DbTransaction)value; } - } - - protected override bool SkipParameter(DbParameter parameter) { - return ((OracleParameter)parameter).OracleType == OracleType.Cursor; - } - - protected sealed override ResultSet CurrentResultSet { - get { - try { - ResultSet resultSet = base.CurrentResultSet; - - if (resultSet != null) { - return resultSet; - } - return CurrentRefCursor; - } - catch(SQLException e) { - throw CreateException(e); - } - } - } - - private ResultSet CurrentRefCursor { - get { - if (_currentParameterIndex < 0) { - NextRefCursor(); - } - if (_currentRefCursor == null && _currentParameterIndex < InternalParameters.Count) { - _currentRefCursor = (ResultSet)((CallableStatement)Statement).getObject(_currentParameterIndex + 1); - } - return _currentRefCursor; - } - } - -#if USE_DOTNET_REGEX - protected override Regex StoredProcedureRegExp -#else - protected override java.util.regex.Pattern StoredProcedureRegExp { -#endif - get { return NamedParameterStoredProcedureRegExp; } - } - - protected override SimpleRegex ParameterRegExp { - get { return NamedParameterRegExp; } - } - - #endregion // Properties - - #region Methods - - protected override bool NextResultSet() { - try { - bool hasMoreResults = base.NextResultSet(); - - if (hasMoreResults) { - return true; - } - else { - return NextRefCursor(); - } - } - catch (SQLException e) { - throw CreateException(e); - } - } - - private bool NextRefCursor() { - _currentRefCursor = null; - for (_currentParameterIndex++;InternalParameters.Count > _currentParameterIndex;_currentParameterIndex++) { - OracleParameter param = (OracleParameter)InternalParameters[_currentParameterIndex]; - if (param.OracleType == OracleType.Cursor && ((param.Direction & ParameterDirection.Output) == ParameterDirection.Output)) - return true; - } - return false; - } - - public new OracleDataReader ExecuteReader() { - return (OracleDataReader)ExecuteReader(CommandBehavior.Default); - } - - public new OracleDataReader ExecuteReader(CommandBehavior behavior) { - return (OracleDataReader)base.ExecuteReader(behavior); - } - - public new OracleParameter CreateParameter() { - return (OracleParameter)CreateParameterInternal(); - } - - protected sealed override void CheckParameters() { - //TBD - } - - protected override AbstractDbParameter GetUserParameter(string parameterName, IList userParametersList, int userParametersListPosition) { - for(int i=0; i < userParametersList.Count; i++) { - OracleParameter userParameter = (OracleParameter)userParametersList[i]; - if (String.Compare(parameterName, userParameter.InternalPlaceholder.Trim(), true, CultureInfo.InvariantCulture) == 0) { - return userParameter; - } - } - - return null; - } - - protected override AbstractDbParameter GetReturnParameter (IList userParametersList) { - for(int i=0; i < userParametersList.Count; i++) { - AbstractDbParameter userParameter = (AbstractDbParameter)userParametersList[i]; - if (userParameter.Direction == ParameterDirection.ReturnValue) { - return userParameter; - } - } - - return null; - } - - protected sealed override DbParameter CreateParameterInternal() { - return new OracleParameter(); - } - - protected sealed override DbParameterCollection CreateParameterCollection(AbstractDbCommand parent) { - return new OracleParameterCollection((OracleCommand)parent); - } - - public override object Clone() { - OracleCommand clone = (OracleCommand)base.Clone(); - clone._currentParameterIndex = 0; - clone._currentRefCursor = null; - return clone; - } - - protected override void PrepareInternalParameters() { - InternalParameters.Clear(); - _currentParameterIndex = -1; - } - - - protected sealed override DbDataReader CreateReader() { - return new OracleDataReader(this); - } - - protected sealed override SystemException CreateException(SQLException e) { - return new OracleException(e,Connection); - } - - public object ExecuteOracleScalar() { - throw new NotImplementedException(); - } - -#if SUPPORT_ORACLE_TYPES - public int ExecuteOracleNonQuery( - out OracleString rowid - ) { - throw new NotImplementedException(); - } -#endif - - #endregion // Methods - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConnection.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConnection.cs deleted file mode 100644 index 6268f7e7577..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConnection.cs +++ /dev/null @@ -1,116 +0,0 @@ -// -// System.Data.OracleClient.OracleConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - - -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; -using System.Collections; - -using java.sql; - -using System.Configuration; -using Mainsoft.Data.Configuration; -using Mainsoft.Data.Jdbc.Providers; - -namespace System.Data.OracleClient { - public sealed class OracleConnection : AbstractDBConnection, System.ICloneable { - #region Events - - public event OracleInfoMessageEventHandler InfoMessage; - - #endregion // Events - - #region Constructors - - public OracleConnection() : this(null) { - } - - public OracleConnection(String connectionString) : base(connectionString) { - } - - #endregion // Constructors - - #region Methods - - protected override IConnectionProvider GetConnectionProvider() { - IDictionary conProviderDict = ConnectionStringDictionary.Parse(ConnectionString); - string provider = (string)conProviderDict["Provider"]; - if (provider == null) - provider = "ORACLECLIENT"; - - return GetConnectionProvider("Mainsoft.Data.Configuration/OracleClientProviders", provider); - } - - public new OracleTransaction BeginTransaction(IsolationLevel level) { - return new OracleTransaction(level, this); - } - - public new OracleTransaction BeginTransaction() { - return BeginTransaction(IsolationLevel.ReadCommitted); - } - - public new OracleCommand CreateCommand() { - return new OracleCommand(this); - } - - protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { - return BeginTransaction(); - } - - protected override DbCommand CreateDbCommand() { - return CreateCommand(); - } - - protected sealed override SystemException CreateException(SQLException e) { - return new OracleException(e,this); - } - - protected sealed override SystemException CreateException(string message) { - return new OracleException(message, null, this); - } - - protected sealed override void OnSqlWarning(SQLWarning warning) { - OracleErrorCollection col = new OracleErrorCollection(warning, this); - OnOracleInfoMessage(new OracleInfoMessageEventArgs(col)); - } - - private void OnOracleInfoMessage (OracleInfoMessageEventArgs value) { - if (InfoMessage != null) { - InfoMessage (this, value); - } - } - - #endregion // Methods - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConvert.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConvert.cs deleted file mode 100644 index e21da07a0f0..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleConvert.cs +++ /dev/null @@ -1,453 +0,0 @@ -// -// System.Data.Oracle.OracleConvert -// -// Authors: -// Konstantin Triger -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Collections; -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.OracleClient { - #region oracle.sql.Types constants - - internal enum JavaSqlTypes { - ARRAY = 2003 , - BIGINT = -5, - BINARY = -2 , - BIT = -7 , - BLOB = 2004, - BOOLEAN = 16, - CHAR = 1, - CLOB = 2005, - DATALINK = 70, - DATE = 91, - DECIMAL = 3, - DISTINCT = 2001, - DOUBLE = 8, - FLOAT = 6, - INTEGER = 4, - JAVA_OBJECT = 2000, - LONGVARBINARY = -4, - LONGVARCHAR = -1, - NULL = 0, - NUMERIC = 2 , - OTHER = 1111 , - REAL = 7 , - REF = 2006 , - SMALLINT = 5, - STRUCT = 2002, - TIME = 92, - TIMESTAMP = 93, - TINYINT = -6, - VARBINARY = -3, - VARCHAR = 12, - - //ORACLE types, see oracle.jdbc.OracleTypes - BINARY_FLOAT = 100, - BINARY_DOUBLE = 101, - ROWID = -8, - CURSOR = -10, - TIMESTAMPNS = -100, - TIMESTAMPTZ = -101, - TIMESTAMPLTZ = -102, - INTERVALYM = -103, - INTERVALDS = -104, - } - - #endregion - sealed class OracleConvert : DbConvert { - - #region .Net types constants - - internal static readonly Type TypeOfBoolean = typeof(Boolean); - internal static readonly Type TypeOfSByte = typeof(SByte); - internal static readonly Type TypeOfChar = typeof(Char); - internal static readonly Type TypeOfInt16 = typeof(Int16); - internal static readonly Type TypeOfInt32 = typeof(Int32); - internal static readonly Type TypeOfInt64 = typeof(Int64); - internal static readonly Type TypeOfByte = typeof(Byte); - internal static readonly Type TypeOfUInt16 = typeof(UInt16); - internal static readonly Type TypeOfUInt32 = typeof(UInt32); - internal static readonly Type TypeOfUInt64 = typeof(UInt64); - internal static readonly Type TypeOfDouble = typeof(Double); - internal static readonly Type TypeOfSingle = typeof(Single); - internal static readonly Type TypeOfDecimal = typeof(Decimal); - internal static readonly Type TypeOfString = typeof(String); - internal static readonly Type TypeOfDateTime = typeof(DateTime); - internal static readonly Type TypeOfObject = typeof(object); - internal static readonly Type TypeOfGuid = typeof(Guid); - internal static readonly Type TypeOfType = typeof(Type); - - // additional types - internal static readonly Type TypeOfByteArray = typeof(Byte[]); - internal static readonly Type TypeOfCharArray = typeof(Char[]); - internal static readonly Type TypeOfFloat = typeof (float); - internal static readonly Type TypeOfTimespan = typeof (TimeSpan); - static readonly Type TypeOfIDataReader = typeof(IDataReader); - - #endregion - - #region Methods - - internal static String JdbcTypeNameToDbTypeName(string jdbcTypeName) { - return jdbcTypeName.Trim();; - } - - internal static OracleType JdbcTypeToOracleType(int jdbcType) { - switch ((JavaSqlTypes)jdbcType) { - case JavaSqlTypes.ARRAY: return OracleType.Blob; - case JavaSqlTypes.BIGINT: return OracleType.Number; - case JavaSqlTypes.BINARY: return OracleType.Blob; - case JavaSqlTypes.BIT: return OracleType.Byte; - case JavaSqlTypes.BLOB: return OracleType.Blob; - case JavaSqlTypes.BOOLEAN: return OracleType.Byte; - case JavaSqlTypes.CHAR: return OracleType.Char; - case JavaSqlTypes.CLOB: return OracleType.Clob; -// case JavaSqlTypes.DATALINK: return OracleType.IUnknown; - case JavaSqlTypes.DATE: return OracleType.DateTime; - case JavaSqlTypes.DECIMAL: return OracleType.Number; -// case JavaSqlTypes.DISTINCT: return OracleType.IUnknown; - case JavaSqlTypes.DOUBLE: return OracleType.Double; - case JavaSqlTypes.FLOAT: return OracleType.Float; - case JavaSqlTypes.INTEGER: return OracleType.Int32; -// case JavaSqlTypes.JAVA_OBJECT: return OracleType.IUnknown; - case JavaSqlTypes.LONGVARBINARY: return OracleType.LongRaw; - case JavaSqlTypes.LONGVARCHAR: return OracleType.LongVarChar; -// case JavaSqlTypes.NULL: return OracleType.Empty; - case JavaSqlTypes.NUMERIC: return OracleType.Number; -// case JavaSqlTypes.OTHER: return OracleType.IUnknown; -// case JavaSqlTypes.REAL: return OracleType.Single; -// case JavaSqlTypes.REF: return OracleType.IUnknown; - case JavaSqlTypes.SMALLINT: return OracleType.Int16; -// case JavaSqlTypes.STRUCT: return OracleType.IUnknown; - case JavaSqlTypes.TIME: return OracleType.TimestampLocal; - case JavaSqlTypes.TIMESTAMP: return OracleType.Timestamp; - case JavaSqlTypes.TINYINT: return OracleType.Byte; - case JavaSqlTypes.VARBINARY: return OracleType.LongVarChar; - default: - case JavaSqlTypes.VARCHAR: return OracleType.VarChar; - - case JavaSqlTypes.BINARY_FLOAT: return OracleType.Float; - case JavaSqlTypes.BINARY_DOUBLE: return OracleType.Double; - case JavaSqlTypes.ROWID: return OracleType.RowId; - case JavaSqlTypes.CURSOR: return OracleType.Cursor; - case JavaSqlTypes.TIMESTAMPNS: return OracleType.Timestamp; - case JavaSqlTypes.TIMESTAMPTZ: return OracleType.TimestampWithTZ; - case JavaSqlTypes.TIMESTAMPLTZ: return OracleType.TimestampLocal; - case JavaSqlTypes.INTERVALYM: return OracleType.IntervalYearToMonth; - case JavaSqlTypes.INTERVALDS: return OracleType.IntervalDayToSecond; - } - } - - internal static OracleType ValueTypeToOracleType(Type type) { - switch (Type.GetTypeCode(type)) { - case TypeCode.Boolean: return OracleType.Byte; - case TypeCode.Byte: return OracleType.Byte; - case TypeCode.Char: return OracleType.Char; - case TypeCode.DateTime: return OracleType.DateTime; -// case TypeCode.DBNull: return OracleType.Empty; - case TypeCode.Decimal: return OracleType.Number; - case TypeCode.Double: return OracleType.Double; -// case TypeCode.Empty: return OracleType.Empty; - case TypeCode.Int16: return OracleType.Int16; - case TypeCode.Int32: return OracleType.Int32; - case TypeCode.Int64: return OracleType.Number; - default: - case TypeCode.Object: { - if (type.Equals(TypeOfByteArray)) return OracleType.Blob; - if (type.Equals(TypeOfTimespan)) return OracleType.Timestamp; - if (type.IsSubclassOf(TypeOfIDataReader)) return OracleType.Cursor; -// if (type.Equals(DbTypes.TypeOfGuid)) return OracleType.Guid; -// - if (type.IsEnum) - return ValueTypeToOracleType (Enum.GetUnderlyingType (type)); -// - return OracleType.VarChar; - } - case TypeCode.SByte: return OracleType.SByte; - case TypeCode.Single: return OracleType.Float; - case TypeCode.String: return OracleType.VarChar; - case TypeCode.UInt16: return OracleType.UInt16; - case TypeCode.UInt32: return OracleType.UInt32; - case TypeCode.UInt64: return OracleType.Number; - } - } - - internal static Type OracleTypeToValueType(OracleType oleDbType) { - switch (oleDbType) { -// case OracleType.BigInt : return DbTypes.TypeOfInt64;// typeof(long); -// case OracleType.Binary : return DbTypes.TypeOfByteArray; -// case OracleType.Boolean : return DbTypes.TypeOfBoolean; -// case OracleType.BSTR : return DbTypes.TypeOfString; - case OracleType.BFile : return TypeOfByteArray; - case OracleType.Blob : return TypeOfByteArray; - case OracleType.Byte : return TypeOfByte; - case OracleType.Char : return TypeOfString; - case OracleType.Clob : return TypeOfCharArray; - case OracleType.Cursor : return TypeOfIDataReader; - case OracleType.DateTime : return TypeOfDateTime; -// case OracleType.Currency : return TypeOfDecimal; -// case OracleType.Date : return TypeOfDateTime; -// case OracleType.DBDate : return TypeOfDateTime; -// case OracleType.DBTime : return TypeOfTimespan; -// case OracleType.DBTimeStamp : return TypeOfDateTime; -// case OracleType.Decimal : return TypeOfDecimal; - case OracleType.Double : return TypeOfDouble; - case OracleType.Float : return TypeOfFloat; - case OracleType.Int16 : return TypeOfInt16; - case OracleType.Int32 : return TypeOfInt32; - case OracleType.IntervalDayToSecond : return TypeOfTimespan; - case OracleType.IntervalYearToMonth : return TypeOfInt32; - case OracleType.LongRaw : return TypeOfByteArray; -// case OracleType.Empty : return null; //typeof(DBNull); -// case OracleType.Error : return typeof(Exception); -// case OracleType.Filetime : return TypeOfDateTime; -// case OracleType.Guid : return TypeOfGuid; -// case OracleType.IDispatch : return TypeOfObject; -// case OracleType.Integer : return TypeOfInt32; -// case OracleType.IUnknown : return TypeOfObject; -// case OracleType.LongVarBinary : return TypeOfByteArray; - case OracleType.LongVarChar : return TypeOfString; - case OracleType.NChar : return TypeOfString; - case OracleType.NClob : return TypeOfString; - case OracleType.Number : return TypeOfDecimal; - case OracleType.NVarChar : return TypeOfString; - case OracleType.Raw : return TypeOfByteArray; - - case OracleType.RowId : return TypeOfString; - case OracleType.SByte : return TypeOfSByte; - case OracleType.Timestamp : return TypeOfTimespan; - case OracleType.TimestampLocal : return TypeOfTimespan; - case OracleType.TimestampWithTZ : return TypeOfTimespan; - case OracleType.UInt16 : return TypeOfUInt16; - - case OracleType.UInt32 : return TypeOfUInt32; - case OracleType.VarChar : return TypeOfString; -// case OracleType.LongVarWChar : return TypeOfString; -// case OracleType.Numeric : return TypeOfDecimal; -// case OracleType.PropVariant : return TypeOfObject; -// case OracleType.Single : return TypeOfFloat; -// case OracleType.SmallInt : return TypeOfInt16; -// case OracleType.TinyInt : return TypeOfSByte; -// case OracleType.UnsignedBigInt : return TypeOfUInt64; -// case OracleType.UnsignedInt : return TypeOfUInt32; -// case OracleType.UnsignedSmallInt : return TypeOfUInt16; -// case OracleType.UnsignedTinyInt : return TypeOfByte; -// case OracleType.VarBinary : return TypeOfByteArray; -// case OracleType.VarChar : return TypeOfString; -// case OracleType.Variant : return TypeOfObject; -// case OracleType.VarNumeric : return TypeOfDecimal; -// case OracleType.VarWChar : return TypeOfString; -// case OracleType.WChar : return TypeOfString; - default : return TypeOfObject; - } - } - - internal static OracleType DbTypeToOracleType(DbType dbType) { - switch (dbType) { - case DbType.AnsiString : return OracleType.VarChar; - case DbType.Binary : return OracleType.Blob; - case DbType.Byte : return OracleType.Byte; - case DbType.Boolean : return OracleType.Byte; - case DbType.Currency : return OracleType.Number; - case DbType.Date : return OracleType.DateTime; - case DbType.DateTime : return OracleType.DateTime; - case DbType.Decimal : return OracleType.Number; - case DbType.Double : return OracleType.Double; - case DbType.Guid : return OracleType.Char; - case DbType.Int16 : return OracleType.Int16; - case DbType.Int32 : return OracleType.Int32; - case DbType.Int64 : return OracleType.Number; - case DbType.Object : return OracleType.Cursor; - case DbType.SByte : return OracleType.SByte; - case DbType.Single : return OracleType.Float; - case DbType.String : return OracleType.VarChar; - case DbType.Time : return OracleType.Timestamp; - case DbType.UInt16 : return OracleType.UInt16; - case DbType.UInt32 : return OracleType.UInt32; - case DbType.UInt64 : return OracleType.Number; - case DbType.VarNumeric : return OracleType.Number; - case DbType.AnsiStringFixedLength : return OracleType.NChar; - case DbType.StringFixedLength : return OracleType.Char; - default : throw ExceptionHelper.InvalidDbType((int)dbType); - } - } - - internal static DbType OracleTypeToDbType(OracleType oleDbType) { - switch (oleDbType) { - case OracleType.BFile : return DbType.Binary; - case OracleType.Blob : return DbType.Binary; - case OracleType.Byte : return DbType.Byte; - case OracleType.Char : return DbType.StringFixedLength; - case OracleType.Clob : return DbType.String; - case OracleType.Cursor : return DbType.Object; - case OracleType.DateTime : return DbType.DateTime; - case OracleType.Double : return DbType.Double; - case OracleType.Float : return DbType.Single; - case OracleType.Int16 : return DbType.Int16; - case OracleType.Int32 : return DbType.Int32; - case OracleType.IntervalDayToSecond : return DbType.Time; - case OracleType.IntervalYearToMonth : return DbType.Int32; - case OracleType.LongRaw : return DbType.Binary; - case OracleType.LongVarChar : return DbType.String; - case OracleType.NChar : return DbType.AnsiStringFixedLength; - case OracleType.NClob : return DbType.AnsiString; - case OracleType.Number : return DbType.VarNumeric; - case OracleType.NVarChar : return DbType.AnsiString; - case OracleType.Raw : return DbType.Binary; - - case OracleType.RowId : return DbType.AnsiStringFixedLength; - case OracleType.SByte : return DbType.SByte; - case OracleType.Timestamp : return DbType.Time; - case OracleType.TimestampLocal : return DbType.Time; - case OracleType.TimestampWithTZ : return DbType.Time; - case OracleType.UInt16 : return DbType.UInt16; - - case OracleType.UInt32 : return DbType.UInt32; - case OracleType.VarChar : return DbType.String; -// case OracleType.Empty : return DbType.Object; -// case OracleType.SmallInt : return DbType.Int16; -// case OracleType.Integer : return DbType.Int32; -// case OracleType.Single : return DbType.Single; -// case OracleType.Double : return DbType.Double; -// case OracleType.Currency : return DbType.Currency; -// case OracleType.Date : return DbType.DateTime; -// case OracleType.BSTR : return DbType.String; -// case OracleType.IDispatch : return DbType.Object; -// case OracleType.Error : return DbType.Object; -// case OracleType.Boolean : return DbType.Boolean; -// case OracleType.Variant : return DbType.Object; -// case OracleType.IUnknown : return DbType.Object; -// case OracleType.Decimal : return DbType.Decimal; -// case OracleType.TinyInt : return DbType.SByte; -// case OracleType.UnsignedTinyInt : return DbType.Byte; -// case OracleType.UnsignedSmallInt : return DbType.UInt16; -// case OracleType.UnsignedInt : return DbType.UInt32; -// case OracleType.BigInt : return DbType.Int64; -// case OracleType.UnsignedBigInt : return DbType.UInt64; -// case OracleType.Filetime : return DbType.DateTime; -// case OracleType.Guid : return DbType.Guid; -// case OracleType.Binary : return DbType.Binary; -// case OracleType.Char : return DbType.AnsiStringFixedLength; -// case OracleType.WChar : return DbType.StringFixedLength; -// case OracleType.Numeric : return DbType.Decimal; -// case OracleType.DBDate : return DbType.Date; -// case OracleType.DBTime : return DbType.Time; -// case OracleType.DBTimeStamp : return DbType.DateTime; -// case OracleType.PropVariant : return DbType.Object; -// case OracleType.VarNumeric : return DbType.VarNumeric; -// case OracleType.VarChar : return DbType.AnsiString; -// case OracleType.LongVarChar : return DbType.AnsiString; -// case OracleType.VarWChar : return DbType.String; -// case OracleType.LongVarWChar : return DbType.String; -// case OracleType.VarBinary : return DbType.Binary; -// case OracleType.LongVarBinary : return DbType.Binary; - default : throw ExceptionHelper.InvalidOleDbType((int)oleDbType); - } - } - - internal static int OracleTypeToJdbcType(OracleType oleDbType) { - switch(oleDbType) { - case OracleType.BFile : return (int)JavaSqlTypes.BINARY; - case OracleType.Blob : return (int)JavaSqlTypes.BINARY; - case OracleType.Byte : return (int)JavaSqlTypes.TINYINT; - case OracleType.Char : return (int)JavaSqlTypes.CHAR; - case OracleType.Clob : return (int)JavaSqlTypes.CLOB; - case OracleType.Cursor : return (int)JavaSqlTypes.CURSOR; - case OracleType.DateTime : return (int)JavaSqlTypes.TIMESTAMP; - case OracleType.Double : return (int)JavaSqlTypes.DOUBLE; - case OracleType.Float : return (int)JavaSqlTypes.FLOAT; - case OracleType.Int16 : return (int)JavaSqlTypes.SMALLINT; - case OracleType.Int32 : return (int)JavaSqlTypes.INTEGER; - case OracleType.IntervalDayToSecond : return (int)JavaSqlTypes.INTERVALDS; - case OracleType.IntervalYearToMonth : return (int)JavaSqlTypes.INTERVALYM; - case OracleType.LongRaw : return (int)JavaSqlTypes.LONGVARBINARY; - case OracleType.LongVarChar : return (int)JavaSqlTypes.LONGVARCHAR; - case OracleType.NChar : return (int)JavaSqlTypes.CHAR; - case OracleType.NClob : return (int)JavaSqlTypes.CLOB; - case OracleType.Number : return (int)JavaSqlTypes.NUMERIC; - case OracleType.NVarChar : return (int)JavaSqlTypes.VARCHAR; - case OracleType.Raw : return (int)JavaSqlTypes.BINARY; - - case OracleType.RowId : return (int)JavaSqlTypes.VARCHAR; - case OracleType.SByte : return (int)JavaSqlTypes.TINYINT; - case OracleType.Timestamp : return (int)JavaSqlTypes.TIMESTAMP; - case OracleType.TimestampLocal : return (int)JavaSqlTypes.TIMESTAMP; - case OracleType.TimestampWithTZ : return (int)JavaSqlTypes.TIMESTAMP; - case OracleType.UInt16 : return (int)JavaSqlTypes.SMALLINT; - - case OracleType.UInt32 : return (int)JavaSqlTypes.INTEGER; - case OracleType.VarChar : return (int)JavaSqlTypes.VARCHAR; -// case OracleType.BigInt : return Types.BIGINT; -// case OracleType.Binary : return Types.BINARY; -// case OracleType.Boolean : return Types.BIT; -// case OracleType.BSTR : return Types.VARCHAR; -// case OracleType.Char : return Types.CHAR; -// case OracleType.Currency : return Types.DECIMAL; -// case OracleType.Date : return Types.TIMESTAMP; -// case OracleType.DBDate : return Types.DATE; -// case OracleType.DBTime : return Types.TIME; -// case OracleType.DBTimeStamp : return Types.TIMESTAMP; -// case OracleType.Decimal : return Types.DECIMAL; -// case OracleType.Double : return Types.DOUBLE; -// case OracleType.Empty : return Types.NULL; -// case OracleType.Error : return Types.OTHER; -// case OracleType.Filetime : return Types.TIMESTAMP; -// case OracleType.Guid : return Types.CHAR; -// case OracleType.IDispatch : return Types.OTHER; //throw new ArgumentException("The " + oleDbType + " OracleType value is not supported."); -// case OracleType.Integer : return Types.INTEGER; -// case OracleType.IUnknown : return Types.OTHER; //throw new ArgumentException("The " + oleDbType + " OracleType value is not supported."); -// case OracleType.LongVarBinary : return Types.LONGVARBINARY; -// case OracleType.LongVarChar : return Types.LONGVARCHAR; -// case OracleType.LongVarWChar : return Types.LONGVARCHAR; -// case OracleType.Numeric : return Types.NUMERIC; -// case OracleType.PropVariant : return Types.OTHER; -// case OracleType.Single : return Types.FLOAT; -// case OracleType.SmallInt : return Types.SMALLINT; -// case OracleType.TinyInt : return Types.TINYINT; -// case OracleType.UnsignedBigInt : return Types.BIGINT; -// case OracleType.UnsignedInt : return Types.INTEGER; -// case OracleType.UnsignedSmallInt : return Types.SMALLINT; -// case OracleType.UnsignedTinyInt : return Types.TINYINT; -// case OracleType.VarBinary : return Types.VARBINARY; -// case OracleType.VarChar : return Types.VARCHAR; -// case OracleType.Variant : return Types.VARCHAR; -// case OracleType.VarNumeric : return Types.DECIMAL; -// case OracleType.VarWChar : return Types.VARCHAR; -// case OracleType.WChar : return Types.VARCHAR; - default : throw ExceptionHelper.InvalidOleDbType((int)oleDbType); - } - - #endregion // Methods - } - } -} diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleDataReader.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleDataReader.cs deleted file mode 100644 index 5c1fa39b70a..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleDataReader.cs +++ /dev/null @@ -1,276 +0,0 @@ -// -// System.Data.OracleClient.OracleDataReader -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.OracleClient { - public sealed class OracleDataReader : AbstractDataReader { - #region Fields - - #endregion // Fields - - #region Constructors - - internal OracleDataReader(OracleCommand command) : base(command) { - } - - #endregion // Constructors - - #region Methods - - protected sealed override SystemException CreateException(string message, SQLException e) { - return new OracleException(message,e, (OracleConnection)_command.Connection); - } - - protected sealed override SystemException CreateException(java.io.IOException e) { - return new OracleException(e, (OracleConnection)_command.Connection); - } - - public override String GetDataTypeName(int columnIndex) { - try { - string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1); - - return OracleConvert.JdbcTypeNameToDbTypeName(jdbcTypeName); - } - catch (SQLException e) { - throw CreateException(e); - } - } - - protected override int GetProviderType(int jdbcType) { - return (int)OracleConvert.JdbcTypeToOracleType(jdbcType); - } - - protected override IReaderCacheContainer CreateReaderCacheContainer(int jdbcType, int columnIndex) { - switch ((JavaSqlTypes)jdbcType) { - case JavaSqlTypes.BINARY_FLOAT: - jdbcType = (int)JavaSqlTypes.REAL; - break; - case JavaSqlTypes.BINARY_DOUBLE: - jdbcType = (int)JavaSqlTypes.DOUBLE; - break; - case JavaSqlTypes.ROWID: - jdbcType = (int)JavaSqlTypes.VARCHAR; - break; -// case JavaSqlTypes.CURSOR: -// jdbcType = JavaSqlTypes.OTHER; -// break; - case JavaSqlTypes.TIMESTAMPNS: - jdbcType = (int)JavaSqlTypes.TIMESTAMP; - break; - case JavaSqlTypes.TIMESTAMPTZ: - jdbcType = (int)JavaSqlTypes.TIMESTAMP; - break; - case JavaSqlTypes.TIMESTAMPLTZ: - jdbcType = (int)JavaSqlTypes.TIMESTAMP; - break; - case JavaSqlTypes.INTERVALYM: - jdbcType = (int)JavaSqlTypes.INTEGER; - break; - case JavaSqlTypes.INTERVALDS: - jdbcType = (int)JavaSqlTypes.TIMESTAMP; - break; - } - return base.CreateReaderCacheContainer (jdbcType, columnIndex); - } - - - protected override void SetSchemaType(DataRow schemaRow, ResultSetMetaData metaData, int columnIndex) { - JavaSqlTypes columnType = (JavaSqlTypes)metaData.getColumnType(columnIndex); - switch (columnType) { - case JavaSqlTypes.BINARY_FLOAT: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfFloat; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.BINARY_DOUBLE: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfDouble; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.ROWID: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfString; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.CURSOR: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfDouble; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.TIMESTAMPNS: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfTimespan; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.TIMESTAMPTZ: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfTimespan; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.TIMESTAMPLTZ: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfTimespan; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.INTERVALYM: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfUInt32; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - case JavaSqlTypes.INTERVALDS: - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = OracleConvert.TypeOfTimespan; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - default: - base.SetSchemaType(schemaRow, metaData, columnIndex); - break; - } - } - - public override decimal GetDecimal(int i) { - if (IsNumeric(i)) - return GetDecimalSafe(i); - - return base.GetDecimal(i); - } - - public override double GetDouble(int i) { - if (IsNumeric(i)) - return GetDoubleSafe(i); - - return base.GetDouble(i); - } - - public override float GetFloat(int i) { - if (IsNumeric(i)) - return GetFloatSafe(i); - - return base.GetFloat(i); - } -// -// OracleClient does not "excuse" for Int16 -// -// public override short GetInt16(int i) { -// if (IsNumeric(i)) -// return GetInt16Safe(i); -// -// return base.GetInt16(i); -// } - - - public override int GetInt32(int i) { - if (IsNumeric(i)) - return GetInt32Safe(i); - - return base.GetInt32(i); - } - - public override long GetInt64(int i) { - if (IsNumeric(i)) - return GetInt64Safe(i); - - return base.GetInt64(i); - } - -#if SUPPORT_ORACLE_TYPES - #region GetOracleXXX - - public OracleBFile GetOracleBFile( - int i - ) { - throw new NotImplementedException(); - } - - public OracleBinary GetOracleBinary( - int i - ) { - throw new NotImplementedException(); - } - - public OracleDateTime GetOracleDateTime( - int i - ) { - throw new NotImplementedException(); - } - - public OracleLob GetOracleLob( - int i - ) { - throw new NotImplementedException(); - } - - public OracleMonthSpan GetOracleMonthSpan( - int i - ) { - throw new NotImplementedException(); - } - - public OracleNumber GetOracleNumber( - int i - ) { - throw new NotImplementedException(); - } - - public OracleString GetOracleString( - int i - ) { - throw new NotImplementedException(); - } - - public OracleTimeSpan GetOracleTimeSpan( - int i - ) { - throw new NotImplementedException(); - } - - public object GetOracleValue( - int i - ) { - throw new NotImplementedException(); - } - - public int GetOracleValues( - object[] values - ) { - throw new NotImplementedException(); - } - - #endregion -#endif - - #endregion // Methods - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleError.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleError.cs deleted file mode 100644 index fbdb138062c..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleError.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -// System.Data.OleDb.OleDbError -// -// Authors: -// Konstantin Triger -// -// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.OracleClient { - using java.sql; - using System.Data.Common; - using System.Data.ProviderBase; - - [Serializable] - internal sealed class OracleError : AbstractDbError { - - internal OracleError(SQLException e, AbstractDBConnection connection) : base(e, connection) { - } - - public String Message { - get { - return DbMessage; - } - } - - public int NativeError { - get { - return DbErrorCode; - } - } - - public String Source { - get { - return DbSource; - } - } - - public String SQLState { - get { - return DbSQLState; - } - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleErrorCollection.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleErrorCollection.cs deleted file mode 100644 index 8ff780aa160..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleErrorCollection.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// System.Data.OleDb.OleDbErrorCollection -// -// Authors: -// Konstantin Triger -// -// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.OracleClient { - - - using System.Collections; - using java.sql; - using System.Data.Common; - using System.Data.ProviderBase; - - [Serializable] - public sealed class OracleErrorCollection : AbstractDbErrorCollection { - internal OracleErrorCollection(SQLException e, AbstractDBConnection connection) : base(e, connection) { - } - /** - * Gets the error at the specified index. - * - * @param index of the error - * @return Error on specified index - */ - internal OracleError this[int index] { - get { - return (OracleError)GetDbItem(index); - } - } - - protected override AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection) { - return new OracleError(e, connection); - } - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleException.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleException.cs deleted file mode 100644 index 155f986d2b7..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleException.cs +++ /dev/null @@ -1,153 +0,0 @@ -// -// System.Data.SqlClient.SqlException -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace System.Data.OracleClient { - - using java.sql; - - using System; - using System.Data.ProviderBase; - - /** - * The exception that is thrown when SQL Server returns a warning or error. - * This class cannot be inherited. - */ - - /* - * CURRENT LIMITATIONS - * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc) - * is not supported. - * 2. Method "void GetObjectData(...,...)" is not supported (serialization) - */ - - public sealed class OracleException : AbstractDbException { - internal OracleException(Exception cause, OracleConnection connection) : base(cause, connection) {} - - internal OracleException(SQLException cause, OracleConnection connection) : base(cause, connection) {} - - internal OracleException(string message, SQLException cause, OracleConnection connection) : base(message, cause, connection) {} - - protected override AbstractDbErrorCollection DbErrors { - get { - return Errors; - } - } - - - - /** - * Gets the severity level of the error returned from the SQL Server .NET - * Data Provider. - * @return severity level of the first error in the collection. - */ -// public byte Class { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].Class : (byte)0; -// } -// } - - /** - * Gets a collection of one or more SqlError objects that give detailed - * information about exceptions generated by the SQL Server .NET Data Provider. - * @return collection of SqlError objects - */ - internal OracleErrorCollection Errors { - get { - return new OracleErrorCollection(_cause, _connection); - } - } - - public int Code { - get { return DbErrorCode; } - } - - /** - * Gets the line number within the Transact-SQL command batch or stored - * procedure that generated the error. - * @return line number of the first error in the collection. - */ -// public int LineNumber { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].LineNumber : 0; -// } -// } - - /** - * Gets a number that identifies the type of error. - * @return number that identifies the type of first error in the collection - */ -// public int Number { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].Number : 0; -// } -// } - - /** - * Gets the name of the stored procedure or remote procedure call (RPC) - * that generated the error. - * @return name of the stored procedure - */ -// public String Procedure { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].Procedure : null; -// } -// } - - /** - * Gets the name of the computer running an instance of SQL Server - * that generated the error. - * @return name of the computer where error generated - */ -// public String Server { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].Server : null; -// } -// } - - - /** - * Gets a numeric error code from SQL Server that represents an error, - * warning or "no data found" message. - * @return numeric error code from SQL Server - */ -// public byte State { -// get { -// SqlErrorCollection errors = Errors; -// return errors.Count > 0 ? errors[0].State : (byte)0; -// } -// } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleParameter.cs b/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleParameter.cs deleted file mode 100644 index d6b4e11e7e0..00000000000 --- a/mcs/class/System.Data.OracleClient/System.Data.OracleClient.jvm/OracleParameter.cs +++ /dev/null @@ -1,230 +0,0 @@ -// -// System.Data.OracleClient.OracleParameter -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Text; -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; -using System.Globalization; - -using java.sql; -using java.lang; - -namespace System.Data.OracleClient { - public sealed class OracleParameter : AbstractDbParameter, ICloneable { - - #region Fields - - OracleType _oleDbType = OracleType.VarChar; - - #endregion // Fields - - #region Constructors - - public OracleParameter() { - } - - public OracleParameter(String parameterName, Object value) - : this (parameterName, OracleType.VarChar, 0, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, value) { - IsDbTypeSet = false; - } - - public OracleParameter(String parameterName, OracleType dbType) - : this (parameterName, dbType, 0, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, null) { - } - - public OracleParameter(String parameterName, OracleType dbType, int size) - : this (parameterName, dbType, size, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, null) { - } - - public OracleParameter(String parameterName, OracleType dbType, int size, - String sourceColumn) - : this (parameterName, dbType, size, ParameterDirection.Input, - false, 0, 0, sourceColumn, DataRowVersion.Current, null) { - } - - - public OracleParameter(String parameterName, - OracleType dbType, - int size, - ParameterDirection direction, - bool isNullable, - byte precision, - byte scale, - String sourceColumn, - DataRowVersion sourceVersion, - Object value) { - ParameterName = parameterName; - OracleType = dbType; - Size = size; - Direction = direction; - IsNullable = isNullable; - Precision = precision; - Scale = scale; - SourceColumn = sourceColumn; - SourceVersion = sourceVersion; - Value = value; - } - - #endregion // Constructors - - #region Properties - - public override DbType DbType { - get { return OracleConvert.OracleTypeToDbType(_oleDbType); } - set { OracleType = OracleConvert.DbTypeToOracleType(value); } - } - - public OracleType OracleType { - get { return _oleDbType; } - set { - _oleDbType = value; - IsDbTypeSet = true; - } - } - - public new Object Value { - get { return base.Value; } - set { - if (!IsDbTypeSet && (value != null) && (value != DBNull.Value)) { - _oleDbType = OracleConvert.ValueTypeToOracleType(value.GetType()); - } - base.Value = value; - } - } - -#if NET_2_0 - public new byte Precision { - get { return base.Precision; } - set { base.Precision = value; } - } - - public new byte Scale { - get { return base.Scale; } - set { base.Scale = value; } - } -#endif - - #endregion // Properties - - #region Methods - - public override String ToString() { - return ParameterName; - } - - protected override string Placeholder { - get { - if (ParameterName.Length == 0 || ParameterName[0] == ':') - return ParameterName; - - return String.Concat(":", ParameterName); - } - } - - internal string InternalPlaceholder { - get { - return Placeholder; - } - } - - protected sealed override object ConvertValue(object value) { - // can not convert null or DbNull to other types - if (value == null || value == DBNull.Value) { - return value; - } - - // TBD : some other way to do this? -// if (OracleType == OracleType.Binary) { -// return value; -// } - // .NET throws an exception to the user. - object convertedValue = value; - - // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set - if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet)) { - OracleType oleDbType = (IsDbTypeSet) ? OracleType : OracleConvert.JdbcTypeToOracleType((int)JdbcType); - Type to = OracleConvert.OracleTypeToValueType(oleDbType); - if (!(value is DateTime && to == OracleConvert.TypeOfTimespan)) //anyway will go by jdbc type - convertedValue = Convert.ChangeType(value,to); - } - return convertedValue; - } - - protected sealed override void SetParameterName(ResultSet res) { - ParameterName = res.getString("COLUMN_NAME"); - } - - protected sealed override void SetParameterDbType(ResultSet res) { - int jdbcType = res.getInt("DATA_TYPE"); - // FIXME : is that correct? - if (jdbcType == Types.OTHER) { - string typeName = res.getString("TYPE_NAME"); - if (String.Compare("REF CURSOR", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.CURSOR; - } - else if (String.Compare("BLOB",typeName,true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.BLOB; - } - else if (String.Compare("CLOB",typeName,true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.CLOB; - } - else if(String.Compare("FLOAT",typeName,true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.FLOAT; - } - else if(String.Compare("NVARCHAR2",typeName,true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.VARCHAR; - } - else if(String.Compare("NCHAR",typeName,true, CultureInfo.InvariantCulture) == 0) { - jdbcType = (int)JavaSqlTypes.VARCHAR; - } - } - OracleType = OracleConvert.JdbcTypeToOracleType(jdbcType); - JdbcType = jdbcType; - } - - protected sealed override void SetSpecialFeatures(ResultSet res) { - // do nothing - } - - protected sealed override int JdbcTypeFromProviderType() { - return OracleConvert.OracleTypeToJdbcType(OracleType); - } - - #endregion // Methods - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/GenericProvider.cs b/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/GenericProvider.cs deleted file mode 100644 index 690250c0595..00000000000 --- a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/GenericProvider.cs +++ /dev/null @@ -1,385 +0,0 @@ -// -// System.Data.OleDb.OleDbConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Data.Common; -using System.Data.Configuration; -using System.Collections; -using System.Collections.Specialized; -using System.Reflection; -using System.Text.RegularExpressions; -using Mainsoft.Data.Configuration; - -using System.Globalization; - -using java.sql; -using javax.sql; -using javax.naming; - -namespace Mainsoft.Data.Jdbc.Providers -{ - public class GenericProvider : IConnectionProvider - { - #region JdbcUrlConnector - - sealed class JdbcUrlConnector { - #region Consts - - private static readonly Regex JdbcUrlPatternRegex= new Regex (@"\$\{(?[^$\{\}]*)\}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - - #endregion // Consts - - #region Fields - - readonly IConnectionStringDictionary _keyMapper; - readonly GenericProvider _provider; - readonly ArrayList _excludedKeys = new ArrayList(); - - #endregion // Fields - - #region Constructors - - internal JdbcUrlConnector (GenericProvider provider, IConnectionStringDictionary keyMapper) { - _provider = provider; - _keyMapper = keyMapper; - } - - #endregion // Constructors - - - #region Methods - - internal java.sql.Connection Connection { - get { - java.util.Properties properties = new java.util.Properties (); - - string url = (string)_keyMapper["JdbcURL"]; - if (url == null) { - string jdbcUrlPattern = (string)_provider.ProviderInfo [ConfigurationConsts.JdbcUrlPattern]; - if (jdbcUrlPattern == null || jdbcUrlPattern.Length == 0) { - //throw ExceptionHelper.JdbcUrlPatternNotFound ((string)_provider.ProviderInfo [ConfigurationConsts.Name]); - object [] args = new object [] {_provider.ProviderInfo [ConfigurationConsts.Name]}; - throw new ArgumentException (String.Format("Provider '{0}' is not configured with valid JDBC URL pattern.",args)); - } - MatchEvaluator evaluator = new MatchEvaluator (ReplaceEvaluator); - url = JdbcUrlPatternRegex.Replace (jdbcUrlPattern, evaluator); - } - else { - // hack for backward comatibility: - // if the connection string contains 'Provider', - // the following mapping will hold: - // 'User', 'User Id' --> 'user' - // 'Password' --> 'password' - if (_keyMapper["Provider"] != null) { - - const string USER = "User"; - const string USERID = "User Id"; - const string PASSWORD = "Password"; - - string user = (string)_keyMapper[USER]; - if (user != null) { - properties.put("user", user); - _excludedKeys.Add(USER); - } - else { - user = (string)_keyMapper[USERID]; - if (user != null) { - properties.put("user", user); - _excludedKeys.Add(USERID); - } - } - - string password = (string)_keyMapper[PASSWORD]; - if (password != null) { - properties.put("password", password); - _excludedKeys.Add(PASSWORD); - } - } - } - - if (_provider._excludedKeys != null) - _excludedKeys.AddRange(_provider._excludedKeys); - - foreach(string key in _provider.KeyMapping.Keys) { - object value = _keyMapper [key]; - if (value == null) - continue; - bool contains = false; - for (int i = 0; i < _excludedKeys.Count; i++) { - if (String.Compare((string)_excludedKeys[i], key, - true, CultureInfo.InvariantCulture) == 0) { - contains = true; - break; - } - } - if (!contains) { - properties.put (key, value); - _excludedKeys.Add(key); - } - } - - for (int i = 0; i < _excludedKeys.Count; i++) { - string value = _keyMapper.GetConnectionStringKey((string)_excludedKeys[i]); - if (value != null) - _excludedKeys[i] = value; - } - - foreach(string key in _keyMapper.Keys) { - object value = _keyMapper [key]; - if (value == null) - continue; - bool contains = false; - for (int i = 0; i < _excludedKeys.Count; i++) { - if (String.Compare((string)_excludedKeys[i], key, - true, CultureInfo.InvariantCulture) == 0) { - contains = true; - break; - } - } - if (!contains) { - if (_provider._unsupportedKeys != null) - for (int i = 0; i < _provider._unsupportedKeys.Length; i++) - if (String.Compare ((string) _provider._unsupportedKeys [i], key, - true, CultureInfo.InvariantCulture) == 0) - throw new NotSupportedException ( - String.Format ("The parameter '{0}' is not supported.", key)); - - properties.put (key, value); - } - } - - Driver d = ActivateJdbcDriver (); - // TBD : add DriverManager.setLoginTimeout - if (d != null) - return d.connect (url, properties); - - return DriverManager.getConnection (url, properties); - } - } - - private string ReplaceEvaluator (Match m) { - Group g = m.Groups["VALUE"]; - - if (!g.Success) - return String.Empty; - - string usedKey = g.Value.Trim(); - - string value = (string)_keyMapper [usedKey]; - if (value == null) - throw new ArgumentException( - String.Format("Missing parameter {0}", g.Value), - "ConnectionString"); - - _excludedKeys.Add(usedKey); - return value; - } - - private Driver ActivateJdbcDriver () { - string driver = (string) _keyMapper["JdbcDriverClassName"]; - if (driver == null) - driver = (string) _provider.ProviderInfo [ConfigurationConsts.JdbcDriverClassName]; - - if (driver != null && driver.Length != 0) { - try { - java.lang.ClassLoader contextLoader = (java.lang.ClassLoader) AppDomain.CurrentDomain.GetData ("GH_ContextClassLoader"); - if (contextLoader != null) - return (Driver) contextLoader.loadClass (driver).newInstance (); - return (Driver) java.lang.Class.forName (driver).newInstance (); - } - catch (java.lang.ClassNotFoundException e) { - throw new TypeLoadException (e.Message, e); - } - catch (java.lang.InstantiationException e) { - throw new MemberAccessException (e.Message, e); - } - catch (java.lang.IllegalAccessException e) { - throw new MissingMethodException (e.Message, e); - } - } - - return null; - } - - #endregion // Methods - } - - #endregion // JdbcUrlBuilder - - #region DataSourceCache - - private sealed class DataSourceCache : AbstractDbMetaDataCache { - internal DataSource GetDataSource(string dataSourceName,string namingProviderUrl,string namingFactoryInitial) { - Hashtable cache = Cache; - - DataSource ds = cache[dataSourceName] as DataSource; - - if (ds != null) { - return ds; - } - - Context ctx = null; - - java.util.Properties properties = new java.util.Properties(); - - if ((namingProviderUrl != null) && (namingProviderUrl.Length > 0)) { - properties.put("java.naming.provider.url",namingProviderUrl); - } - - if ((namingFactoryInitial != null) && (namingFactoryInitial.Length > 0)) { - properties.put("java.naming.factory.initial",namingFactoryInitial); - } - - ctx = new InitialContext(properties); - - try { - ds = (DataSource)ctx.lookup(dataSourceName); - } - catch(javax.naming.NameNotFoundException e) { - // possible that is a Tomcat bug, - // so try to lookup for jndi datasource with "java:comp/env/" appended - ds = (DataSource)ctx.lookup("java:comp/env/" + dataSourceName); - } - - cache[dataSourceName] = ds; - return ds; - } - } - - #endregion // DatasourceCache - - #region Fields - - private static DataSourceCache _dataSourceCache = new DataSourceCache(); - - private readonly IDictionary _providerInfo; - private NameValueCollection _keyMapping; - private string[] _excludedKeys; - private string[] _unsupportedKeys; - - #endregion // Fields - - #region Constructors - - public GenericProvider(IDictionary providerInfo) - { - _providerInfo = providerInfo; - _keyMapping = null; - } - - #endregion // Constructors - - #region Properties - - protected IDictionary ProviderInfo - { - get { return _providerInfo; } - } - - private NameValueCollection KeyMapping - { - get - { - if (_keyMapping == null) - InitKeyMapping (); - - return _keyMapping; - } - } - - #endregion // Properties - - #region Methods - - public virtual java.sql.Connection GetConnection (IConnectionStringDictionary conectionStringBuilder) - { - string dataSourceJndi = (string) conectionStringBuilder.GetValue ("jndi-datasource-name"); - - if (dataSourceJndi != null && dataSourceJndi.Length > 0) { - - string namingProviderUrl = (string) conectionStringBuilder.GetValue ("naming-provider-url"); - string namingFactoryInitial = (string) conectionStringBuilder.GetValue ("naming-factory-initial"); - DataSource ds = _dataSourceCache.GetDataSource(dataSourceJndi,namingProviderUrl,namingFactoryInitial); - return ds.getConnection(); - } - - JdbcUrlConnector connector = new JdbcUrlConnector (this, conectionStringBuilder); - return connector.Connection; - } - - public virtual IConnectionStringDictionary GetConnectionStringBuilder (string connectionString) - { - return new ConnectionStringDictionary(connectionString, KeyMapping); - } - - private void InitKeyMapping () - { - lock (this) { - if (_keyMapping != null) - return; - - _keyMapping = new NameValueCollection (StringComparer.OrdinalIgnoreCase); - - // create key mappings collection - string keyMappingsStr = (string) _providerInfo [ConfigurationConsts.KeyMapping]; - if (keyMappingsStr != null) { - string [] keyMappings = keyMappingsStr.Split (ConfigurationConsts.SemicolonArr); - foreach (string keyMapping in keyMappings) { - if (keyMapping.Length == 0) - continue; - int equalsIndex = keyMapping.IndexOf ('='); - string key = keyMapping.Substring (0, equalsIndex).Trim (); - string [] mappings = keyMapping.Substring (equalsIndex + 1).Trim ().Split (ConfigurationConsts.CommaArr); - foreach (string mapping in mappings) - _keyMapping.Add (key, mapping.Trim ()); - } - } - - string keyMappingExcludesStr = (string) _providerInfo [ConfigurationConsts.KeyMappingExcludes]; - if (keyMappingExcludesStr != null) { - _excludedKeys = keyMappingExcludesStr.Split (ConfigurationConsts.CommaArr); - for (int i = 0; i < _excludedKeys.Length; i++) - _excludedKeys [i] = _excludedKeys [i].Trim (); - } - - string keyMappingUnsupportedStr = (string) _providerInfo [ConfigurationConsts.KeyMappingUnsupported]; - if (keyMappingUnsupportedStr != null) { - _unsupportedKeys = keyMappingUnsupportedStr.Split (ConfigurationConsts.CommaArr); - for (int i = 0; i < _unsupportedKeys.Length; i++) - _unsupportedKeys [i] = _unsupportedKeys [i].Trim (); - } - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/IProvider.cs b/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/IProvider.cs deleted file mode 100644 index 5c758005edb..00000000000 --- a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/IProvider.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// System.Data.OleDb.OleDbConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Collections; -using Mainsoft.Data.Configuration; - -using java.sql; - -namespace Mainsoft.Data.Jdbc.Providers -{ - sealed class ConfigurationConsts { - #region Constructors - - ConfigurationConsts() { - } - - #endregion // Constructors - - #region Consts - - public const string Name = "id"; - public const string KeyMapping = "keyMapping"; - public const string KeyMappingExcludes = "keyExclude"; - public const string KeyMappingUnsupported = "keyUnsupported"; - public const string JdbcUrlPattern = "url"; - public const string JdbcDriverClassName = "driverClassName"; - public const string ProviderType = "type"; - - public static readonly char [] SemicolonArr = new char [] { ';' }; - public static readonly char [] CommaArr = new char [] { ',' }; - - #endregion // Consts - - } - - public interface IConnectionProvider - { - java.sql.Connection GetConnection (IConnectionStringDictionary connectionStringBuilder); - IConnectionStringDictionary GetConnectionStringBuilder (string connectionString); - } - - public interface IPreparedStatement : java.sql.PreparedStatement { - void setBit(int parameterIndex, int value); - void setChar(int parameterIndex, string value); - void setNumeric(int parameterIndex, java.math.BigDecimal value); - void setReal(int parameterIndex, double value); - } -} diff --git a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/OleDbSqlServerProvider.cs b/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/OleDbSqlServerProvider.cs deleted file mode 100644 index 6995c54c4a5..00000000000 --- a/mcs/class/System.Data/Mainsoft.Data.Jdbc.Providers.jvm/OleDbSqlServerProvider.cs +++ /dev/null @@ -1,407 +0,0 @@ -// -// System.Data.OleDb.OleDbConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2006 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.Data.Common; -using System.Data.Configuration; -using System.Data.ProviderBase; -using Mainsoft.Data.Configuration; - -using java.net; -using System.Globalization; - -namespace Mainsoft.Data.Jdbc.Providers -{ - #region OleDbSqlServerProvider2000 - - public class OleDbSqlServerProvider2000 : GenericProvider - { - #region Consts - - private const string Port = "Port"; - private const string DefaultInstanceName = "MSSQLSERVER"; - private const int DefaultTimeout = 15; - - #endregion //Consts - - #region Fields - - #endregion // Fields - - #region Constructors - - public OleDbSqlServerProvider2000 (IDictionary providerInfo) : base (providerInfo) - { - } - - #endregion // Constructors - - #region Properties - - #endregion // Properties - - #region Methods - - public override IConnectionStringDictionary GetConnectionStringBuilder (string connectionString) - { - //TBD: should wrap the IConnectionStringDictionary - IConnectionStringDictionary conectionStringBuilder = base.GetConnectionStringBuilder (connectionString); - OleDbSqlHelper.InitConnectionStringBuilder (conectionStringBuilder); - - string port = (string) conectionStringBuilder [Port]; - if (port == null || port.Length == 0) { - port = GetMSSqlPort (OleDbSqlHelper.GetInstanceName (conectionStringBuilder, DefaultInstanceName), OleDbSqlHelper.GetDataSource (conectionStringBuilder), OleDbSqlHelper.GetTimeout (conectionStringBuilder, DefaultTimeout)); - conectionStringBuilder.Add (Port, port); - } - - return conectionStringBuilder; - } - - static string GetMSSqlPort(string instanceName, string dataSource, int timeout) { - string port = String.Empty; - try { - DatagramSocket socket = new DatagramSocket(); - - // send request - sbyte[] buf = new sbyte[] {2}; - InetAddress address = InetAddress.getByName(dataSource); - DatagramPacket packet = new DatagramPacket(buf, buf.Length, address, 1434); - socket.send(packet); - sbyte[] recbuf = new sbyte[1024]; - packet = new DatagramPacket(recbuf, recbuf.Length, packet.getAddress(), packet.getPort()); - - // try to receive from socket while increasing timeouts in geometric progression - int iterationTimeout = 1; - int totalTimeout = 0; - for(;;) { - socket.setSoTimeout(iterationTimeout); - try { - socket.receive(packet); - break; - } - catch (SocketTimeoutException e) { - totalTimeout += iterationTimeout; - iterationTimeout *= 2; - if (totalTimeout >= timeout*1000) { - throw new java.sql.SQLException( - String.Format ("Unable to retrieve the port number for {0} using UDP on port 1434. Please see your network administrator to solve this problem or add the port number of your SQL server instance to your connection string (i.e. port=1433).", dataSource) - ); - } - } - } - sbyte[] rcvdSbytes = packet.getData(); - char[] rcvdChars = new char[rcvdSbytes.Length]; - for(int i=0; i < rcvdSbytes.Length; i++) { - rcvdChars[i] = (char)rcvdSbytes[i]; - } - String received = new String(rcvdChars); - - java.util.StringTokenizer st = new java.util.StringTokenizer(received, ";"); - String prev = ""; - bool instanceReached = instanceName == null || instanceName.Length == 0; - while (st.hasMoreTokens()) { - if (!instanceReached) { - if (prev.Trim().Equals("InstanceName")) { - if (String.Compare(instanceName,st.nextToken().Trim(),true, CultureInfo.InvariantCulture) == 0) { - instanceReached = true; - } - } - } - else { - if (prev.Trim().Equals("tcp")) { - port = st.nextToken().Trim(); - //ensure we got a valid int - java.lang.Integer.parseInt(port); - break; - } - } - prev = st.nextToken(); - } - socket.close(); - - if (!instanceReached) - throw new java.sql.SQLException( - String.Format ("Specified SQL Server '{0}\\{1}' not found.", dataSource, instanceName) - ); - return port; - - } - catch (java.sql.SQLException) { - throw; - } - catch (Exception e) { - throw new java.sql.SQLException(e.Message); - } - } - - #endregion // Methods - } - - #endregion // OleDbSqlServerProvider2000 - - #region OleDbSqlServerProvider2005 - - public class OleDbSqlServerProvider2005 : GenericProvider - { - #region Consts - - #endregion //Consts - - #region Fields - - #endregion // Fields - - #region Constructors - - public OleDbSqlServerProvider2005 (IDictionary providerInfo) : base (providerInfo) - { - } - - #endregion // Constructors - - #region Properties - - #endregion // Properties - - #region Methods - - public override IConnectionStringDictionary GetConnectionStringBuilder (string connectionString) - { - //TBD: should wrap the IConnectionStringDictionary - IConnectionStringDictionary conectionStringBuilder = base.GetConnectionStringBuilder (connectionString); - OleDbSqlHelper.InitConnectionStringBuilder (conectionStringBuilder); - return conectionStringBuilder; - } - - public override java.sql.Connection GetConnection(IConnectionStringDictionary conectionStringBuilder) - { - return new SqlServer2005Connection (base.GetConnection (conectionStringBuilder)); - } - - #endregion // Methods - - #region SqlServer2005Connection - - sealed class SqlServer2005Connection : Connection - { - #region Constructors - - public SqlServer2005Connection(java.sql.Connection connection) : base (connection) - { - } - - #endregion - - #region Methods - - public override java.sql.DatabaseMetaData getMetaData() - { - return new SqlServer2005DatabaseMetaData (base.getMetaData ()); - } - - #endregion - } - - #endregion - - #region SqlServer2005DatabaseMetaData - - sealed class SqlServer2005DatabaseMetaData : DatabaseMetaData - { - #region Fields - - #endregion // Fields - - #region Constructors - - public SqlServer2005DatabaseMetaData (java.sql.DatabaseMetaData databaseMetaData) : base (databaseMetaData) - { - } - - #endregion // Constructors - - #region Properties - - #endregion // Properties - - #region Methods - - public override java.sql.ResultSet getProcedureColumns(string arg_0, string arg_1, string arg_2, string arg_3) - { - return new SqlServer2005DatbaseMetaDataResultSet (Wrapped.getProcedureColumns (arg_0, arg_1, arg_2, arg_3)); - } - - #endregion // Methods - } - - #endregion - - #region SqlServer2005DatbaseMetaDataResultSet - - sealed class SqlServer2005DatbaseMetaDataResultSet : ResultSet - { - #region Consts - - private const string DataType = "DATA_TYPE"; - - #endregion - - #region Fields - - #endregion // Fields - - #region Constructors - - public SqlServer2005DatbaseMetaDataResultSet (java.sql.ResultSet resultSet) : base (resultSet) - { - } - - #endregion // Constructors - - #region Properties - - #endregion // Properties - - #region Methods - - public override int getInt(int arg_0) - { - int res = base.getInt (arg_0); - if (res == -9) // sql server 2005 jdbc driver value for NVARCHAR - if (String.CompareOrdinal (getMetaData ().getColumnName (arg_0), DataType) == 0) - return java.sql.Types.VARCHAR; - if (res == -8) // sql server 2005 jdbc driver value for NVARCHAR - if (String.CompareOrdinal (getMetaData ().getColumnName (arg_0), DataType) == 0) - return java.sql.Types.CHAR; - return res; - } - - public override int getInt(string arg_0) - { - int res = base.getInt (arg_0); - - if (res == -9) // sql server 2005 jdbc driver value for NVARCHAR - if (String.CompareOrdinal (arg_0, DataType) == 0) - return java.sql.Types.VARCHAR; - - if (res == -8) // sql server 2005 jdbc driver value for NVARCHAR - if (String.CompareOrdinal (arg_0, DataType) == 0) - return java.sql.Types.CHAR; - return res; - } - - #endregion // Methods - } - - #endregion - } - - #endregion // OleDbSqlServerProvider2005 - - #region OleDbSqlHelper - - class OleDbSqlHelper - { - private const string Database = "Database"; - private const string ServerName = "ServerName"; - private const string Timeout = "Timeout"; - - internal static void InitConnectionStringBuilder (IConnectionStringDictionary conectionStringBuilder) - { - if (!conectionStringBuilder.Contains("jndi-datasource-name")) { - - string database = (string) conectionStringBuilder [Database]; - if (database == null) - conectionStringBuilder.Add (Database, String.Empty); - - string dataSource = GetDataSource (conectionStringBuilder); - string instanceName = GetInstanceName (conectionStringBuilder, null); - - if (instanceName != null) - conectionStringBuilder [ServerName] = dataSource + "\\" + instanceName; - else - conectionStringBuilder [ServerName] = dataSource; - } - } - - // TBD : refactor GetInstanceName and GetDataSource to single method - internal static string GetInstanceName (IDictionary keyMapper, string defaultInstanceName) - { - string dataSource = (string) keyMapper [ServerName]; - string instanceName = String.Empty; - int instanceIdx; - if (dataSource == null || (instanceIdx = dataSource.IndexOf ("\\")) == -1) - // no named instance specified - use a default name - return defaultInstanceName; - else - // get named instance name - return dataSource.Substring (instanceIdx + 1); - } - - internal static string GetDataSource (IDictionary keyMapper) - { - string dataSource = (string) keyMapper [ServerName]; - int instanceIdx; - if (dataSource != null && (instanceIdx = dataSource.IndexOf ("\\")) != -1) - // throw out named instance name - dataSource = dataSource.Substring (0,instanceIdx); - - if (dataSource != null && dataSource.StartsWith ("(") && dataSource.EndsWith (")")) - dataSource = dataSource.Substring (1,dataSource.Length - 2); - - if (String.Empty.Equals (dataSource) || (String.Compare ("local", dataSource, true, CultureInfo.InvariantCulture) == 0) || (String.CompareOrdinal (".", dataSource) == 0)) - dataSource = "localhost"; - - return dataSource; - } - - internal static int GetTimeout (IDictionary keyMapper, int defaultTimeout) - { - string timeoutStr = (string) keyMapper [Timeout]; - if ((timeoutStr != null) && (timeoutStr.Length != 0)) { - try { - return Convert.ToInt32(timeoutStr); - } - catch(FormatException e) { - throw ExceptionHelper.InvalidValueForKey("connect timeout"); - } - catch (OverflowException e) { - throw ExceptionHelper.InvalidValueForKey("connect timeout"); - } - } - return defaultTimeout; - } - } - - #endregion // OleDbSqlHelper - -} diff --git a/mcs/class/System.Data/System.Data.Common/DbMetaDataCache.cs b/mcs/class/System.Data/System.Data.Common/DbMetaDataCache.cs deleted file mode 100644 index ee279b1ecb0..00000000000 --- a/mcs/class/System.Data/System.Data.Common/DbMetaDataCache.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2002-2004 Mainsoft Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; -using System.Collections; - -using java.sql; - -namespace System.Data.Common -{ - #region AbstractDbMetaDataCache - - internal abstract class AbstractDbMetaDataCache - { - Hashtable _cache; - const int MINUTES_TIMEOUT = 10; - private long _timestamp; - - protected AbstractDbMetaDataCache() - { - _cache = Hashtable.Synchronized(new Hashtable()); - } - - protected Hashtable Cache - { - get - { - long now = DateTime.Now.Ticks; - if (now - _timestamp > MINUTES_TIMEOUT * TimeSpan.TicksPerMinute) - { - _timestamp = now; - _cache.Clear(); - } - - return _cache; - } - } - } - - #endregion -} diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbCommand.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbCommand.cs deleted file mode 100644 index d51327838d6..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbCommand.cs +++ /dev/null @@ -1,285 +0,0 @@ -// -// System.Data.OleDb.OleDbCommand -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; -// Cannot use this because it makes ArrayList ambiguous reference -//using java.util; - -namespace System.Data.OleDb -{ - public sealed class OleDbCommand : AbstractDbCommand - { - - #region Fields - - internal static readonly int oracleTypeRefCursor = java.sql.Types.OTHER; - private static readonly int _oracleRefCursor = -10; // oracle.jdbc.OracleTypes.CURSOR - private int _currentParameterIndex = 0; - private ResultSet _currentRefCursor; - - #endregion // Fields - - #region Constructors - - static OleDbCommand() - { - try { - java.lang.Class OracleTypesClass = java.lang.Class.forName("oracle.jdbc.OracleTypes"); - _oracleRefCursor = OracleTypesClass.getField("CURSOR").getInt(null); - } - catch(java.lang.ClassNotFoundException e) { - // oracle driver is not in classpath - just continue - } - } - - /** - * Initializes a new instance of the OleDbCommand class. - * The base constructor initializes all fields to their default values. - * The following table shows initial property values for an instance of SqlCommand. - */ - public OleDbCommand() : this(null, null, null) - { - } - - public OleDbCommand(OleDbConnection connection) : this(null, connection, null) - { - } - - /** - * Initializes a new instance of the OleDbCommand class with the text of the query. - * @param cmdText The text of the query. - */ - public OleDbCommand(String cmdText) : this(cmdText, null, null) - { - } - - /** - * Initializes a new instance of the OleDbCommand class with the text of the query and a SqlConnection. - * @param cmdText The text of the query. - * @param connection A SqlConnection that represents the connection to an instance of SQL Server. - */ - public OleDbCommand(String cmdText, OleDbConnection connection) : this(cmdText, connection, null) - { - } - - /** - * Initializes a new instance of the OleDbCommand class with the text of the query, a SqlConnection, and the Transaction. - * @param cmdText The text of the query. - * @param connection A SqlConnection that represents the connection to an instance of SQL Server. - * @param transaction The SqlTransaction in which the OleDbCommand executes. - */ - public OleDbCommand( - String cmdText, - OleDbConnection connection, - OleDbTransaction transaction) - : base(cmdText, connection, transaction) - { - } - - #endregion // Constructors - - #region Properties - - public new OleDbConnection Connection - { - get { return (OleDbConnection)base.Connection; } - set { base.Connection = (AbstractDBConnection)value; } - } - - public new OleDbParameterCollection Parameters - { - get { - return (OleDbParameterCollection)base.Parameters; - } - } - - public new OleDbTransaction Transaction - { - get { return (OleDbTransaction)base.Transaction; } - set { base.Transaction = (DbTransaction)value; } - } - - protected internal sealed override ResultSet CurrentResultSet - { - get { - try { - ResultSet resultSet = base.CurrentResultSet; - - if (resultSet != null) { - return resultSet; - } - return CurrentRefCursor; - } - catch(SQLException e) { - throw CreateException(e); - } - } - } - - private ResultSet CurrentRefCursor - { - get { - if (_currentParameterIndex < 0) { - NextRefCursor(); - } - if (_currentRefCursor == null && _currentParameterIndex < InternalParameters.Count) { - _currentRefCursor = (ResultSet)((CallableStatement)Statement).getObject(_currentParameterIndex + 1); - } - return _currentRefCursor; - } - } - - #endregion // Properties - - #region Methods - - public new OleDbDataReader ExecuteReader() - { - return (OleDbDataReader)ExecuteReader(CommandBehavior.Default); - } - - public new OleDbDataReader ExecuteReader(CommandBehavior behavior) - { - return (OleDbDataReader)base.ExecuteReader(behavior); - } - - public new OleDbParameter CreateParameter() - { - return (OleDbParameter)CreateParameterInternal(); - } - - protected sealed override void CheckParameters() - { - for(int i = 0; i < Parameters.Count; i++) { - OleDbParameter parameter = (OleDbParameter)Parameters[i]; - if ((parameter.OleDbType == OleDbType.Empty) || (parameter.OleDbType == OleDbType.Error)) { - throw ExceptionHelper.ParametersNotInitialized(i,parameter.ParameterName,parameter.OleDbType.ToString()); - } - - if (((parameter.OleDbType == OleDbType.Char) || (parameter.OleDbType == OleDbType.Binary) || - (parameter.OleDbType == OleDbType.VarWChar) || (parameter.OleDbType == OleDbType.VarBinary) || - (parameter.OleDbType == OleDbType.VarNumeric)) && (parameter.Size == 0)) { - throw ExceptionHelper.WrongParameterSize("OleDb"); - } - } - } - - protected sealed override DbParameter CreateParameterInternal() - { - return new OleDbParameter(); - } - - protected sealed override DbParameterCollection CreateParameterCollection(AbstractDbCommand parent) - { - return new OleDbParameterCollection((OleDbCommand)parent); - } - - public override object Clone() { - OleDbCommand clone = (OleDbCommand)base.Clone(); - clone._currentParameterIndex = 0; - clone._currentRefCursor = null; - return clone; - } - - protected override void PrepareInternalParameters() - { - InternalParameters.Clear(); - _currentParameterIndex = -1; - } - - protected override void BindOutputParameter(AbstractDbParameter parameter, int parameterIndex) - { - CallableStatement callableStatement = ((CallableStatement)Statement); - if (((OleDbParameter)parameter).IsOracleRefCursor) { - callableStatement.registerOutParameter(++parameterIndex, _oracleRefCursor); - } - else { - base.BindOutputParameter(parameter, parameterIndex); - } - } - - protected override bool SkipParameter(DbParameter parameter) - { - return ((OleDbParameter)parameter).IsOracleRefCursor; - } - - protected internal override bool NextResultSet() - { - try { - bool hasMoreResults = base.NextResultSet(); - - if (hasMoreResults) { - return true; - } - else { - return NextRefCursor(); - } - } - catch (SQLException e) { - throw CreateException(e); - } - } - - private bool NextRefCursor() - { - _currentRefCursor = null; - // FIXME : should we count all parameters or only out ones? - for (_currentParameterIndex++;InternalParameters.Count > _currentParameterIndex;_currentParameterIndex++) { - if (((OleDbParameter)InternalParameters[_currentParameterIndex]).IsOracleRefCursor) { - return true; - } - } - return false; - } - - protected sealed override DbDataReader CreateReader() - { - return new OleDbDataReader(this); - } - - protected internal sealed override SystemException CreateException(SQLException e) - { - return new OleDbException(e,Connection); - } - - #endregion // Methods - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConnection.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConnection.cs deleted file mode 100644 index 6c96afb556f..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConnection.cs +++ /dev/null @@ -1,221 +0,0 @@ -// -// System.Data.OleDb.OleDbConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - - -using System.Data; -using System.Data.Common; -using System.Collections; -using System.Data.ProviderBase; -using System.Globalization; - -using java.sql; - -using System.Configuration; -using Mainsoft.Data.Configuration; -using Mainsoft.Data.Jdbc.Providers; - -namespace System.Data.OleDb -{ - public sealed class OleDbConnection : AbstractDBConnection { - - #region Events - - public event OleDbInfoMessageEventHandler InfoMessage; - - #endregion // Events - - #region Constructors - - public OleDbConnection() : this(null) { - } - - public OleDbConnection(String connectionString) : base(connectionString) { - } - - #endregion // Constructors - - #region Properties - - public String Provider { - get { - IDictionary conDict = ConnectionStringBuilder; - string provider = (string)conDict["Provider"]; - if (provider == null || provider.Length == 0) - throw ExceptionHelper.OleDbNoProviderSpecified(); - - return provider; - } - } - - protected override IConnectionProvider GetConnectionProvider() { - IDictionary conProviderDict = ConnectionStringDictionary.Parse(ConnectionString); - string jdbcUrl = (string)conProviderDict["JdbcUrl"]; - if (jdbcUrl == null) { - string provider = (string)conProviderDict["Provider"]; - if (provider != null) - return GetConnectionProvider("Mainsoft.Data.Configuration/OleDbProviders", provider); - } - - return new GenericProvider (conProviderDict); - } - - #endregion // Properties - - #region Methods - - public new OleDbTransaction BeginTransaction(IsolationLevel level) - { - return new OleDbTransaction(level, this); - } - - public new OleDbTransaction BeginTransaction() - { - return BeginTransaction(IsolationLevel.ReadCommitted); - } - - public new OleDbCommand CreateCommand() - { - return new OleDbCommand(this); - } - - protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { - return BeginTransaction(); - } - - protected override DbCommand CreateDbCommand() { - return CreateCommand(); - } - - protected sealed override SystemException CreateException(SQLException e) - { - return new OleDbException(e,this); - } - - protected sealed override SystemException CreateException(string message) - { - return new OleDbException(message, null, this); - } - - [MonoTODO] - public DataTable GetOleDbSchemaTable (Guid schema, object[] restrictions) - { - if (State != ConnectionState.Open) - throw ExceptionHelper.ConnectionNotOpened("GetOleDbSchemaTable", State.ToString()); - - try { - - string[] fixedRestrictions = new string[4]; - if (restrictions != null) { - if (restrictions.Length > 4) - throw new OleDbException("The parameter is incorrect", null, this); - - for (int i = 0, count = restrictions.Length; i < count; i ++) { - if (restrictions[i] != null) { - if (!(restrictions[i] is string)) - throw new OleDbException("The parameter is incorrect", null, this); - - fixedRestrictions[i] = (string)restrictions[i]; - } - } - } - - DataTable schemaTable = new DataTable("Tables"); - schemaTable.Columns.Add("TABLE_CATALOG"); - schemaTable.Columns.Add("TABLE_SCHEMA"); - schemaTable.Columns.Add("TABLE_NAME"); - schemaTable.Columns.Add("TABLE_TYPE"); - schemaTable.Columns.Add("TABLE_GUID"); - schemaTable.Columns.Add("DESCRIPTION"); - schemaTable.Columns.Add("TABLE_PROPID"); - schemaTable.Columns.Add("DATE_CREATED"); - schemaTable.Columns.Add("DATE_MODIFIED"); - - java.sql.ResultSet tableRes = JdbcConnection.getMetaData().getTables( - fixedRestrictions[0], - fixedRestrictions[1], - fixedRestrictions[2], - new string[]{fixedRestrictions[3]}); - - try { - while(tableRes.next()) { - DataRow row = schemaTable.NewRow(); - row["TABLE_CATALOG"] = tableRes.getString("TABLE_CAT"); - row["TABLE_SCHEMA"] = tableRes.getString("TABLE_SCHEM"); - row["TABLE_NAME"] = tableRes.getString("TABLE_NAME"); - row["TABLE_TYPE"] = tableRes.getString("TABLE_TYPE"); - row["DESCRIPTION"] = tableRes.getString("REMARKS"); - - schemaTable.Rows.Add(row); - } - } - finally { - tableRes.close(); - } - - return schemaTable; - } - catch (SQLException e) { - throw CreateException(e); - } - } - - public static void ReleaseObjectPool() - { - // since we're using connection pool from app servet, this is by design - //throw new NotImplementedException(); - } - -#if NET_2_0 - [MonoLimitation ("Empty implementation since State relies on java.sql.Connection.State always returning the correct state")] - public void ResetState () - { - } - -#endif - - protected internal sealed override void OnSqlWarning(SQLWarning warning) - { - OleDbErrorCollection col = new OleDbErrorCollection(warning, this); - OnOleDbInfoMessage(new OleDbInfoMessageEventArgs(col)); - } - - private void OnOleDbInfoMessage (OleDbInfoMessageEventArgs value) - { - if (InfoMessage != null) { - InfoMessage (this, value); - } - } - - #endregion // Methods - - } -} diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConvert.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConvert.cs deleted file mode 100644 index 67de73699c6..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConvert.cs +++ /dev/null @@ -1,342 +0,0 @@ -// -// System.Data.OleDb.OleDbConvert -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Collections; -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.OleDb -{ - internal sealed class OleDbConvert : DbConvert - { - #region Fields - - private static Hashtable _typeNamesMap; - - #endregion // Fields - - #region Constructors - - static OleDbConvert() - { - _typeNamesMap = new Hashtable(30,CaseInsensitiveHashCodeProvider.DefaultInvariant, CaseInsensitiveComparer.DefaultInvariant); - - // SqlServer types mapping -// _typeNamesMap.Add("numeric(3, 0)1","DBTYPE_I1"); - _typeNamesMap.Add("smallint","DBTYPE_I2"); - _typeNamesMap.Add("Int","DBTYPE_I4"); - _typeNamesMap.Add("bigint","DBTYPE_I8"); - _typeNamesMap.Add("tinyint","DBTYPE_UI1"); -// _typeNamesMap.Add("numeric(5,0)","DBTYPE_UI2"); -// _typeNamesMap.Add("numeric(10,0)","DBTYPE_UI4"); -// _typeNamesMap.Add("numeric(20,0)","DBTYPE_UI8"); - _typeNamesMap.Add("Float","DBTYPE_R8"); - _typeNamesMap.Add("Real","DBTYPE_R4"); - _typeNamesMap.Add("numeric","DBTYPE_NUMERIC"); - _typeNamesMap.Add("decimal","DBTYPE_NUMERIC"); - _typeNamesMap.Add("money","DBTYPE_CY"); - _typeNamesMap.Add("smallmoney","DBTYPE_CY"); - _typeNamesMap.Add("ntext","DBTYPE_WLONGVARCHAR"); - _typeNamesMap.Add("nchar","DBTYPE_WCHAR"); - _typeNamesMap.Add("nvarchar","DBTYPE_WVARCHAR"); - _typeNamesMap.Add("Bit","DBTYPE_BOOL"); -// _typeNamesMap.Add("nvarchar(4000)","DBTYPE_VARIANT"); - _typeNamesMap.Add("sql_variant","DBTYPE_VARIANT"); - _typeNamesMap.Add("uniqueidentifier","DBTYPE_GUID"); - _typeNamesMap.Add("image","DBTYPE_LONGVARBINARY"); - _typeNamesMap.Add("timestamp","DBTYPE_BINARY"); - _typeNamesMap.Add("binary","DBTYPE_BINARY"); - _typeNamesMap.Add("varbinary","DBTYPE_VARBINARY"); - _typeNamesMap.Add("char","DBTYPE_CHAR"); - _typeNamesMap.Add("varchar","DBTYPE_VARCHAR"); - _typeNamesMap.Add("text","DBTYPE_LONGVARCHAR"); -// _typeNamesMap.Add("nchar","DBTYPE_WSTR"); -// _typeNamesMap.Add("nvarchar","DBTYPE_WSTR"); -// _typeNamesMap.Add("ntext","DBTYPE_WSTR"); -// _typeNamesMap.Add("datetime","DBTYPE_DATE"); - _typeNamesMap.Add("datetime","DBTYPE_DBTIMESTAMP"); - _typeNamesMap.Add("smalldatetime","DBTYPE_DBTIMESTAMP"); - _typeNamesMap.Add("Ignored","DBTYPE_BYREF"); - } - - #endregion //Constructors - - #region Methods - - internal static String JdbcTypeNameToDbTypeName(string jdbcTypeName) - { - jdbcTypeName = jdbcTypeName.Trim(); - string dbTypeName = (string)_typeNamesMap[jdbcTypeName]; - - return (dbTypeName != null) ? dbTypeName : jdbcTypeName; - } - - internal static OleDbType JdbcTypeToOleDbType(int jdbcType) - { - switch ((JavaSqlTypes)jdbcType) { - case JavaSqlTypes.ARRAY: return OleDbType.Binary; - case JavaSqlTypes.BIGINT: return OleDbType.BigInt; - case JavaSqlTypes.BINARY: return OleDbType.Binary; - case JavaSqlTypes.BIT: return OleDbType.Boolean; - case JavaSqlTypes.BLOB: return OleDbType.Binary; - case JavaSqlTypes.BOOLEAN: return OleDbType.Boolean; - case JavaSqlTypes.CHAR: return OleDbType.Char; - case JavaSqlTypes.CLOB: return OleDbType.LongVarWChar; - case JavaSqlTypes.DATALINK: return OleDbType.IUnknown; - case JavaSqlTypes.DATE: return OleDbType.DBDate; - case JavaSqlTypes.DECIMAL: return OleDbType.Decimal; - case JavaSqlTypes.DISTINCT: return OleDbType.IUnknown; - case JavaSqlTypes.DOUBLE: return OleDbType.Double; - case JavaSqlTypes.FLOAT: return OleDbType.Double; - case JavaSqlTypes.INTEGER: return OleDbType.Integer; - case JavaSqlTypes.JAVA_OBJECT: return OleDbType.IUnknown; - case JavaSqlTypes.LONGVARBINARY: return OleDbType.LongVarBinary; - case JavaSqlTypes.LONGVARCHAR: return OleDbType.LongVarWChar; - case JavaSqlTypes.NULL: return OleDbType.Empty; - case JavaSqlTypes.NUMERIC: return OleDbType.Numeric; - default: - case JavaSqlTypes.OTHER: return OleDbType.IUnknown; - case JavaSqlTypes.REAL: return OleDbType.Single; - case JavaSqlTypes.REF: return OleDbType.IUnknown; - case JavaSqlTypes.SMALLINT: return OleDbType.SmallInt; - case JavaSqlTypes.STRUCT: return OleDbType.IUnknown; - case JavaSqlTypes.TIME: return OleDbType.DBTime; - case JavaSqlTypes.TIMESTAMP: return OleDbType.DBTimeStamp; - case JavaSqlTypes.TINYINT: return OleDbType.TinyInt; - case JavaSqlTypes.VARBINARY: return OleDbType.VarBinary; - case JavaSqlTypes.VARCHAR: return OleDbType.VarChar; - } - } - - internal static OleDbType ValueTypeToOleDbType(Type type) - { - switch (Type.GetTypeCode(type)) { - case TypeCode.Boolean: return OleDbType.Boolean; - case TypeCode.Byte: return OleDbType.UnsignedTinyInt; - case TypeCode.Char: return OleDbType.Char; - case TypeCode.DateTime: return OleDbType.Date; - case TypeCode.DBNull: return OleDbType.Empty; - case TypeCode.Decimal: return OleDbType.Decimal; - case TypeCode.Double: return OleDbType.Double; - case TypeCode.Empty: return OleDbType.Empty; - case TypeCode.Int16: return OleDbType.SmallInt; - case TypeCode.Int32: return OleDbType.Integer; - case TypeCode.Int64: return OleDbType.BigInt; - default: - case TypeCode.Object: { - if (type.Equals(DbTypes.TypeOfByteArray)) return OleDbType.Binary; - if (type.Equals(DbTypes.TypeOfTimespan)) return OleDbType.DBTime; - if (type.Equals(DbTypes.TypeOfGuid)) return OleDbType.Guid; - - if (type.IsEnum) - return ValueTypeToOleDbType (Enum.GetUnderlyingType (type)); - - return OleDbType.IUnknown; - } - case TypeCode.SByte: return OleDbType.TinyInt; - case TypeCode.Single: return OleDbType.Single; - case TypeCode.String: return OleDbType.VarWChar; - case TypeCode.UInt16: return OleDbType.UnsignedSmallInt; - case TypeCode.UInt32: return OleDbType.UnsignedInt; - case TypeCode.UInt64: return OleDbType.UnsignedBigInt; - } - } - - internal static Type OleDbTypeToValueType(OleDbType oleDbType) - { - switch (oleDbType) { - case OleDbType.BigInt : return DbTypes.TypeOfInt64;// typeof(long); - case OleDbType.Binary : return DbTypes.TypeOfByteArray; - case OleDbType.Boolean : return DbTypes.TypeOfBoolean; - case OleDbType.BSTR : return DbTypes.TypeOfString; - case OleDbType.Char : return DbTypes.TypeOfString; - case OleDbType.Currency : return DbTypes.TypeOfDecimal; - case OleDbType.Date : return DbTypes.TypeOfDateTime; - case OleDbType.DBDate : return DbTypes.TypeOfDateTime; - case OleDbType.DBTime : return DbTypes.TypeOfTimespan; - case OleDbType.DBTimeStamp : return DbTypes.TypeOfDateTime; - case OleDbType.Decimal : return DbTypes.TypeOfDecimal; - case OleDbType.Double : return DbTypes.TypeOfDouble; - case OleDbType.Empty : return null; //typeof(DBNull); - case OleDbType.Error : return typeof(Exception); - case OleDbType.Filetime : return DbTypes.TypeOfDateTime; - case OleDbType.Guid : return DbTypes.TypeOfGuid; - case OleDbType.IDispatch : return DbTypes.TypeOfObject; - case OleDbType.Integer : return DbTypes.TypeOfInt32; - case OleDbType.IUnknown : return DbTypes.TypeOfObject; - case OleDbType.LongVarBinary : return DbTypes.TypeOfByteArray; - case OleDbType.LongVarChar : return DbTypes.TypeOfString; - case OleDbType.LongVarWChar : return DbTypes.TypeOfString; - case OleDbType.Numeric : return DbTypes.TypeOfDecimal; - case OleDbType.PropVariant : return DbTypes.TypeOfObject; - case OleDbType.Single : return DbTypes.TypeOfFloat; - case OleDbType.SmallInt : return DbTypes.TypeOfInt16; - case OleDbType.TinyInt : return DbTypes.TypeOfSByte; - case OleDbType.UnsignedBigInt : return DbTypes.TypeOfUInt64; - case OleDbType.UnsignedInt : return DbTypes.TypeOfUInt32; - case OleDbType.UnsignedSmallInt : return DbTypes.TypeOfUInt16; - case OleDbType.UnsignedTinyInt : return DbTypes.TypeOfByte; - case OleDbType.VarBinary : return DbTypes.TypeOfByteArray; - case OleDbType.VarChar : return DbTypes.TypeOfString; - case OleDbType.Variant : return DbTypes.TypeOfObject; - case OleDbType.VarNumeric : return DbTypes.TypeOfDecimal; - case OleDbType.VarWChar : return DbTypes.TypeOfString; - case OleDbType.WChar : return DbTypes.TypeOfString; - default : return DbTypes.TypeOfObject; - } - } - - internal static OleDbType DbTypeToOleDbType(DbType dbType) - { - switch (dbType) { - case DbType.AnsiString : return OleDbType.VarChar; - case DbType.Binary : return OleDbType.VarBinary; - case DbType.Byte : return OleDbType.UnsignedTinyInt; - case DbType.Boolean : return OleDbType.Boolean; - case DbType.Currency : return OleDbType.Currency; - case DbType.Date : return OleDbType.DBDate; - case DbType.DateTime : return OleDbType.DBTimeStamp; - case DbType.Decimal : return OleDbType.Decimal; - case DbType.Double : return OleDbType.Double; - case DbType.Guid : return OleDbType.Guid; - case DbType.Int16 : return OleDbType.SmallInt; - case DbType.Int32 : return OleDbType.Integer; - case DbType.Int64 : return OleDbType.BigInt; - case DbType.Object : return OleDbType.Variant; - case DbType.SByte : return OleDbType.TinyInt; - case DbType.Single : return OleDbType.Single; - case DbType.String : return OleDbType.VarWChar; - case DbType.Time : return OleDbType.DBTime; - case DbType.UInt16 : return OleDbType.UnsignedSmallInt; - case DbType.UInt32 : return OleDbType.UnsignedInt; - case DbType.UInt64 : return OleDbType.UnsignedBigInt; - case DbType.VarNumeric : return OleDbType.VarNumeric; - case DbType.AnsiStringFixedLength : return OleDbType.Char; - case DbType.StringFixedLength : return OleDbType.WChar; - default : throw ExceptionHelper.InvalidDbType((int)dbType); - } - } - - internal static DbType OleDbTypeToDbType(OleDbType oleDbType) - { - switch (oleDbType) { - case OleDbType.Empty : return DbType.Object; - case OleDbType.SmallInt : return DbType.Int16; - case OleDbType.Integer : return DbType.Int32; - case OleDbType.Single : return DbType.Single; - case OleDbType.Double : return DbType.Double; - case OleDbType.Currency : return DbType.Currency; - case OleDbType.Date : return DbType.DateTime; - case OleDbType.BSTR : return DbType.String; - case OleDbType.IDispatch : return DbType.Object; - case OleDbType.Error : return DbType.Object; - case OleDbType.Boolean : return DbType.Boolean; - case OleDbType.Variant : return DbType.Object; - case OleDbType.IUnknown : return DbType.Object; - case OleDbType.Decimal : return DbType.Decimal; - case OleDbType.TinyInt : return DbType.SByte; - case OleDbType.UnsignedTinyInt : return DbType.Byte; - case OleDbType.UnsignedSmallInt : return DbType.UInt16; - case OleDbType.UnsignedInt : return DbType.UInt32; - case OleDbType.BigInt : return DbType.Int64; - case OleDbType.UnsignedBigInt : return DbType.UInt64; - case OleDbType.Filetime : return DbType.DateTime; - case OleDbType.Guid : return DbType.Guid; - case OleDbType.Binary : return DbType.Binary; - case OleDbType.Char : return DbType.AnsiStringFixedLength; - case OleDbType.WChar : return DbType.StringFixedLength; - case OleDbType.Numeric : return DbType.Decimal; - case OleDbType.DBDate : return DbType.Date; - case OleDbType.DBTime : return DbType.Time; - case OleDbType.DBTimeStamp : return DbType.DateTime; - case OleDbType.PropVariant : return DbType.Object; - case OleDbType.VarNumeric : return DbType.VarNumeric; - case OleDbType.VarChar : return DbType.AnsiString; - case OleDbType.LongVarChar : return DbType.AnsiString; - case OleDbType.VarWChar : return DbType.String; - case OleDbType.LongVarWChar : return DbType.String; - case OleDbType.VarBinary : return DbType.Binary; - case OleDbType.LongVarBinary : return DbType.Binary; - default : throw ExceptionHelper.InvalidOleDbType((int)oleDbType); - } - } - - internal static int OleDbTypeToJdbcType(OleDbType oleDbType) - { - switch(oleDbType) { - case OleDbType.BigInt : return Types.BIGINT; - case OleDbType.Binary : return Types.BINARY; - case OleDbType.Boolean : return Types.BIT; - case OleDbType.BSTR : return Types.VARCHAR; - case OleDbType.Char : return Types.CHAR; - case OleDbType.Currency : return Types.DECIMAL; - case OleDbType.Date : return Types.TIMESTAMP; - case OleDbType.DBDate : return Types.DATE; - case OleDbType.DBTime : return Types.TIME; - case OleDbType.DBTimeStamp : return Types.TIMESTAMP; - case OleDbType.Decimal : return Types.DECIMAL; - case OleDbType.Double : return Types.DOUBLE; - case OleDbType.Empty : return Types.NULL; - case OleDbType.Error : return Types.OTHER; - case OleDbType.Filetime : return Types.TIMESTAMP; - case OleDbType.Guid : return Types.CHAR; - case OleDbType.IDispatch : return Types.OTHER; //throw new ArgumentException("The " + oleDbType + " OleDbType value is not supported."); - case OleDbType.Integer : return Types.INTEGER; - case OleDbType.IUnknown : return Types.OTHER; //throw new ArgumentException("The " + oleDbType + " OleDbType value is not supported."); - case OleDbType.LongVarBinary : return Types.LONGVARBINARY; - case OleDbType.LongVarChar : return Types.LONGVARCHAR; - case OleDbType.LongVarWChar : return Types.LONGVARCHAR; - case OleDbType.Numeric : return Types.NUMERIC; - case OleDbType.PropVariant : return Types.OTHER; - case OleDbType.Single : return Types.FLOAT; - case OleDbType.SmallInt : return Types.SMALLINT; - case OleDbType.TinyInt : return Types.TINYINT; - case OleDbType.UnsignedBigInt : return Types.BIGINT; - case OleDbType.UnsignedInt : return Types.INTEGER; - case OleDbType.UnsignedSmallInt : return Types.SMALLINT; - case OleDbType.UnsignedTinyInt : return Types.TINYINT; - case OleDbType.VarBinary : return Types.VARBINARY; - case OleDbType.VarChar : return Types.VARCHAR; - case OleDbType.Variant : return Types.VARCHAR; - case OleDbType.VarNumeric : return Types.DECIMAL; - case OleDbType.VarWChar : return Types.VARCHAR; - case OleDbType.WChar : return Types.VARCHAR; - default : throw ExceptionHelper.InvalidOleDbType((int)oleDbType); - } - - #endregion // Methods - } - } -} diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbDataReader.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbDataReader.cs deleted file mode 100644 index 554298c4693..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbDataReader.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -// System.Data.OleDb.OleDbDataReader -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.OleDb -{ - public sealed class OleDbDataReader : AbstractDataReader - { - #region Fields - - #endregion // Fields - - #region Constructors - - internal OleDbDataReader(OleDbCommand command) : base(command) - { - } - - #endregion // Constructors - - #region Methods - - protected sealed override SystemException CreateException(string message, SQLException e) - { - return new OleDbException(message,e, (OleDbConnection)_command.Connection); - } - - protected sealed override SystemException CreateException(java.io.IOException e) - { - return new OleDbException(e, (OleDbConnection)_command.Connection); - } - - public override String GetDataTypeName(int columnIndex) - { - try { - string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1); - - return OleDbConvert.JdbcTypeNameToDbTypeName(jdbcTypeName); - } - catch (SQLException e) { - throw CreateException(e); - } - } - - protected override int GetProviderType(int jdbcType) - { - return (int)OleDbConvert.JdbcTypeToOleDbType(jdbcType); - } - - [MonoNotSupported("")] - public OleDbDataReader GetData (int ordinal) - { - throw new NotImplementedException (); - } - - #endregion // Methods - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbError.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbError.cs deleted file mode 100644 index f46680d629a..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbError.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// System.Data.OleDb.OleDbError -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.OleDb -{ - using java.sql; - using System.Data.Common; - using System.Data.ProviderBase; - - [Serializable] - public sealed class OleDbError : AbstractDbError - { - - internal OleDbError(SQLException e, AbstractDBConnection connection) : base(e, connection) { - } - - public String Message - { - get - { - return DbMessage; - } - } - - public int NativeError - { - get - { - return DbErrorCode; - } - } - - public String Source - { - get - { - return DbSource; - } - } - - public String SQLState - { - get - { - return DbSQLState; - } - } - - public override string ToString () - { - string toStr; - - toStr = String.Format("OleDbError: {0}. {1}", Message, _e.StackTrace); - return toStr; - - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbErrorCollection.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbErrorCollection.cs deleted file mode 100644 index f1c96c20175..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbErrorCollection.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// System.Data.OleDb.OleDbErrorCollection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.OleDb -{ - - - using System.Collections; - using java.sql; - using System.Data.Common; - using System.Data.ProviderBase; - - [Serializable] - public sealed class OleDbErrorCollection : AbstractDbErrorCollection - { - internal OleDbErrorCollection(SQLException e, AbstractDBConnection connection) : base(e, connection) { - } - /** - * Gets the error at the specified index. - * - * @param index of the error - * @return Error on specified index - */ - public OleDbError this[int index] - { - get - { - return (OleDbError)GetDbItem(index); - } - } - -#if NET_2_0 - public void CopyTo (OleDbError [] array, int index) - { - base.CopyTo (array, index); - } - -#endif - - protected override AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection) { - return new OleDbError(e, connection); - } - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbException.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbException.cs deleted file mode 100644 index cf2d729b4cf..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbException.cs +++ /dev/null @@ -1,163 +0,0 @@ -// -// System.Data.OleDb.OleDbException -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - - -namespace System.Data.OleDb -{ - - using java.sql; - using System.Text; - using System.Data.Common; - using System.Data.ProviderBase; - - /* - * CURRENT LIMITATIONS - * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc) - * is not supported. - * 2. Method "void GetObjectData(...,...)" is not supported (serialization) - */ -#if NET_2_0 - public sealed class OleDbException : AbstractDbException - { - internal OleDbException (Exception cause, OleDbConnection connection) : base (cause, connection) { } - - internal OleDbException (SQLException cause, OleDbConnection connection) : base (cause, connection) { } - - internal OleDbException (string message, SQLException cause, OleDbConnection connection) : base (message, cause, connection) { } - - protected override AbstractDbErrorCollection DbErrors { - get { - return Errors; - } - } - - public OleDbErrorCollection Errors { - get { - return new OleDbErrorCollection (_cause, _connection); - } - } - - public override int ErrorCode { - get { - return DbErrorCode; - } - } - } -#else - public sealed class OleDbException : System.Runtime.InteropServices.ExternalException - { - private class OleDbExceptionImpl : AbstractDbException { - internal OleDbExceptionImpl(Exception cause, OleDbConnection connection) : base(cause, connection) {} - - internal OleDbExceptionImpl(SQLException cause, OleDbConnection connection) : base(cause, connection) {} - - internal OleDbExceptionImpl(string message, SQLException cause, OleDbConnection connection) : base(message, cause, connection) {} - - protected override AbstractDbErrorCollection DbErrors { - get { - return Errors; - } - } - - public OleDbErrorCollection Errors { - get { - return new OleDbErrorCollection(_cause, _connection); - } - } - - public int ErrorCode { - get { - return DbErrorCode; - } - } - } - - OleDbExceptionImpl _impl; - - internal OleDbException(Exception cause, OleDbConnection connection) : base(null, cause) { - _impl = new OleDbExceptionImpl(cause, connection); - } - - internal OleDbException(SQLException cause, OleDbConnection connection) : base(null, cause) { - _impl = new OleDbExceptionImpl(cause, connection); - } - - internal OleDbException(string message, SQLException cause, OleDbConnection connection) : base(null, cause) { - _impl = new OleDbExceptionImpl(message, cause, connection); - } - /** - * Gets a collection of one or more SqlError objects that give detailed - * information about exceptions generated by the SQL Server .NET Data Provider. - * @return collection of SqlError objects - */ - public OleDbErrorCollection Errors - { - get - { - return (OleDbErrorCollection)_impl.Errors; - } - } - - /** - * Gets the error code of the error. - * @return The error code of the error. - */ - public override int ErrorCode - { - get - { - return base.HResult; - } - } - - - /** - * Gets the name of the OLE DB provider that generated the error. - * @return the name of the OLE DB provider that generated the error. - */ - public override String Source - { - get - { - return _impl.Source; - } - } - - public override string Message { - get { - return _impl.Message; - } - } - - } -#endif -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbParameter.cs b/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbParameter.cs deleted file mode 100644 index 71c7403501a..00000000000 --- a/mcs/class/System.Data/System.Data.OleDb.jvm/OleDbParameter.cs +++ /dev/null @@ -1,256 +0,0 @@ -// -// System.Data.OleDb.OleDbParameter -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Text; -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; -using java.lang; -using System.Globalization; - -namespace System.Data.OleDb -{ - public sealed class OleDbParameter : AbstractDbParameter - { - - #region Fields - - private OleDbType _oleDbType = OleDbType.VarWChar; - private bool _isOracleRefCursor = false; - - #endregion // Fields - - #region Constructors - - public OleDbParameter() - { - } - - public OleDbParameter(String parameterName, Object value) - : this (parameterName, OleDbType.VarWChar, 0, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, value) - { - IsDbTypeSet = false; - } - - public OleDbParameter(String parameterName, OleDbType dbType) - : this (parameterName, dbType, 0, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, null) - { - } - - public OleDbParameter(String parameterName, OleDbType dbType, int size) - : this (parameterName, dbType, size, ParameterDirection.Input, - false, 0, 0, String.Empty, DataRowVersion.Current, null) - { - } - - public OleDbParameter(String parameterName, OleDbType dbType, int size, - String sourceColumn) - : this (parameterName, dbType, size, ParameterDirection.Input, - false, 0, 0, sourceColumn, DataRowVersion.Current, null) - { - } - - - public OleDbParameter(String parameterName, - OleDbType dbType, - int size, - ParameterDirection direction, - bool isNullable, - byte precision, - byte scale, - String sourceColumn, - DataRowVersion sourceVersion, - Object value) - { - ParameterName = parameterName; - OleDbType = dbType; - Size = size; - Direction = direction; - IsNullable = isNullable; - Precision = precision; - Scale = scale; - SourceColumn = sourceColumn; - SourceVersion = sourceVersion; - Value = value; - } - - #endregion // Constructors - - #region Properties - - public override DbType DbType - { - get { return OleDbConvert.OleDbTypeToDbType(_oleDbType); } - set { OleDbType = OleDbConvert.DbTypeToOleDbType(value); } - } - - public OleDbType OleDbType - { - get { return _oleDbType; } - set { - _oleDbType = value; - IsDbTypeSet = true; - } - } - -#if NET_2_0 - public new byte Precision - { - get { return base.Precision; } - set { base.Precision = value; } - } - - public new byte Scale - { - get { return base.Scale; } - set { base.Scale = value; } - } -#endif - - public new Object Value - { - get { return base.Value; } - set { - if (!IsDbTypeSet && (value != null) && (value != DBNull.Value)) { - _oleDbType = OleDbConvert.ValueTypeToOleDbType(value.GetType()); - } - base.Value = value; - } - } - - protected internal sealed override bool IsSpecial { - get { - return (Direction == ParameterDirection.Output) && IsOracleRefCursor; - } - } - - - internal bool IsOracleRefCursor - { - get { return _isOracleRefCursor; } - set { _isOracleRefCursor = value; } - } - - #endregion // Properties - - #region Methods - - protected internal sealed override object ConvertValue(object value) - { - // can not convert null or DbNull to other types - if (value == null || value == DBNull.Value) { - return value; - } - - // FIXME : some other way to do this? - if (OleDbType == OleDbType.Binary) { - return value; - } - // .NET throws an exception to the user. - object convertedValue = value; - - // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set - if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet)) { - OleDbType oleDbType = (IsDbTypeSet) ? OleDbType : OleDbConvert.JdbcTypeToOleDbType((int)JdbcType); - Type to = OleDbConvert.OleDbTypeToValueType(oleDbType); - if (!(value is DateTime && to == DbTypes.TypeOfTimespan)) //anyway will go by jdbc type - convertedValue = Convert.ChangeType(value,to); - } - return convertedValue; - } - - protected internal sealed override void SetParameterName(ResultSet res) - { - ParameterName = res.getString("COLUMN_NAME"); - - if (ParameterName.StartsWith("@")) { - ParameterName = ParameterName.Remove(0,1); - } - } - - protected internal sealed override void SetParameterDbType(ResultSet res) - { - int jdbcType = res.getInt("DATA_TYPE"); - // FIXME : is that correct? - if (jdbcType == Types.OTHER) { - string typeName = res.getString("TYPE_NAME"); - if (String.Compare ("BLOB", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = Types.BLOB; - } - else if (String.Compare ("CLOB", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = Types.CLOB; - } - else if (String.Compare ("FLOAT", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = Types.FLOAT; - } - else if (String.Compare ("NVARCHAR2", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = Types.VARCHAR; - } - else if (String.Compare ("NCHAR", typeName, true, CultureInfo.InvariantCulture) == 0) { - jdbcType = Types.VARCHAR; - } - } - OleDbType = OleDbConvert.JdbcTypeToOleDbType(jdbcType); - JdbcType = jdbcType; - } - -#if NET_2_0 - public void ResetOleDbType () - { - IsDbTypeSet = false; - } - - public override void ResetDbType () - { - ResetOleDbType (); - } -#endif - - protected internal sealed override void SetSpecialFeatures(ResultSet res) - { - IsOracleRefCursor = (res.getString("TYPE_NAME") == "REF CURSOR"); - } - - protected internal sealed override int JdbcTypeFromProviderType() - { - return OleDbConvert.OleDbTypeToJdbcType(OleDbType); - } - - #endregion // Methods - - } -} diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBCommand.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBCommand.cs deleted file mode 100644 index 855d9d2ff6d..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBCommand.cs +++ /dev/null @@ -1,1273 +0,0 @@ -// -// System.Data.ProviderBase.AbstractDbCommand -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Text; -using System.Text.RegularExpressions; -using System.Collections; -using System.Data; -using System.Data.Common; - -using java.sql; -using java.io; - -#if !USE_DOTNET_REGEXP -using java.util.regex; -#endif - -namespace System.Data.ProviderBase -{ - public abstract class AbstractDbCommand : DbCommand, ICloneable - { - #region ProcedureColumnCache - - internal sealed class ProcedureColumnCache : AbstractDbMetaDataCache - { - internal ArrayList GetProcedureColumns(AbstractDBConnection connection, String commandText,AbstractDbCommand command) - { - string connectionCatalog = connection.JdbcConnection.getCatalog(); - string key = String.Concat(connection.ConnectionString, connectionCatalog, commandText); - System.Collections.Hashtable cache = Cache; - - ArrayList col = cache[key] as ArrayList; - - if (null != col) { - return col; - } - - col = connection.GetProcedureColumns(commandText,command); - if (col != null) - cache[key] = col; - return col; - } - } - - #endregion - - #region SqlStatementsHelper - - internal sealed class SqlStatementsHelper - { - #region Fields -#if USE_DOTNET_REGEXP - internal static readonly Regex NamedParameterStoredProcedureRegExp = new Regex(@"^\s*{?\s*((?@\w+)\s*=\s*)?call\s+(?(((\[[^\]]*\])|([^\.\(])*)\s*\.\s*){0,2}(\[[^\]]*\]|((\s*[^\.\(\)\{\}\s])+)))\s*(\(\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)?\s*(,\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)\s*)*\))?\s*}?\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - internal static readonly Regex SimpleParameterStoredProcedureRegExp = new Regex(@"^\s*{?\s*((?\?)\s*=\s*)?call\s+(?(((\[[^\]]*\])|([^\.\(])*)\s*\.\s*){0,2}(\[[^\]]*\]|((\s*[^\.\(\)\{\}\s])+)))\s*(\(\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)?\s*(,\s*(?((""([^""]|(""""))*"")|('([^']|(''))*')|[^,])*)\s*)*\))?\s*}?\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - internal static readonly Regex ForBrowseStatementReqExp = new Regex(@"\s+FOR\s+BROWSE\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); -#else - internal static readonly Pattern NamedParameterStoredProcedureRegExp = Pattern.compile(@"^\s*\{?\s*(?:(@\w+)\s*=\s*)?call\s+((?:(?:(?:\[[^\]]*\])|(?:[^\.\(\)\{\}\[\]])*)\s*\.\s*){0,2}(?:\[[^\]]*\]|(?:(?:\s*[^\.\(\)\{\}\[\]])+)))\s*(?:\((.*)\))?\s*\}?\s*$", Pattern.CASE_INSENSITIVE); - internal static readonly Pattern SimpleParameterStoredProcedureRegExp = Pattern.compile(@"^\s*\{?\s*(?:(\?)\s*=\s*)?call\s+((?:(?:(?:\[[^\]]*\])|(?:[^\.\(\)\{\}\[\]])*)\s*\.\s*){0,2}(?:\[[^\]]*\]|(?:(?:\s*[^\.\(\)\{\}\[\]])+)))\s*(?:\((.*)\))?\s*\}?\s*$", Pattern.CASE_INSENSITIVE); - internal static readonly Pattern ForBrowseStatementReqExp = Pattern.compile(@"\s+FOR\s+BROWSE\s*$", Pattern.CASE_INSENSITIVE); -#endif - - internal static readonly SimpleRegex NamedParameterRegExp = new SqlParamsRegex(); - internal static readonly SimpleRegex SimpleParameterRegExp = new OleDbParamsRegex(); - - internal static readonly SimpleRegex CompoundStatementSplitterReqExp = new CharacterSplitterRegex(';'); - internal static readonly SimpleRegex ProcedureParameterSplitterReqExp = new CharacterSplitterRegex(','); - - #endregion // Fields - } - - #endregion // SqlStatementsHelper - - #region Fields - - string _commandText; - int _commandTimeout; - CommandType _commandType; - bool _designTimeVisible; - UpdateRowSource _updatedRowSource; - - private DbParameterCollection _parameters; - private java.sql.Statement _statement; - private AbstractDBConnection _connection; - private AbstractTransaction _transaction; - private bool _isCommandPrepared; - private CommandBehavior _behavior; - private ArrayList _internalParameters; - string _javaCommandText; - private int _recordsAffected; - private ResultSet _currentResultSet; - private DbDataReader _currentReader; - private bool _nullParametersInPrepare; - private bool _hasResultSet; - private bool _explicitPrepare; - - static ProcedureColumnCache _procedureColumnCache = new ProcedureColumnCache(); - - #endregion // Fields - - #region Constructors - - public AbstractDbCommand( - String cmdText, - AbstractDBConnection connection, - AbstractTransaction transaction) - { - _connection = connection; - _commandText = cmdText; - _transaction = transaction; - - _commandTimeout = 30; - _commandType = CommandType.Text; - _designTimeVisible = true; - _updatedRowSource = UpdateRowSource.Both; - - _isCommandPrepared = false; - _explicitPrepare = false; - _recordsAffected = -1; - if (connection != null) { - connection.AddReference(this); - } - } - - #endregion // Constructors - - #region Properties - - public override int CommandTimeout { - get { return _commandTimeout; } - set { _commandTimeout = value; } - } - - public override CommandType CommandType { - get { return _commandType; } - set { _commandType = value; } - } - - public override bool DesignTimeVisible { - get { return _designTimeVisible; } - set { _designTimeVisible = value; } - } - - public override UpdateRowSource UpdatedRowSource { - get { return _updatedRowSource; } - set { _updatedRowSource = value; } - } - - protected override DbParameterCollection DbParameterCollection - { - get { - if (_parameters == null) { - _parameters = CreateParameterCollection(this); - } - return _parameters; - } - } - - protected override DbConnection DbConnection - { - get { return (DbConnection)_connection; } - set { - if (value == _connection) { - return; - } - - if (_currentReader != null && !_currentReader.IsClosed) { - throw ExceptionHelper.ConnectionIsBusy(this.GetType().Name,((AbstractDBConnection)_connection).InternalState); - } - if (_connection != null) { - _connection.RemoveReference(this); - } - _connection = (AbstractDBConnection) value; - if (_connection != null) { - _connection.AddReference(this); - } - } - } - - protected override DbTransaction DbTransaction - { - get { return _transaction != null ? _transaction.ActiveTransaction : null; } - set { _transaction = (AbstractTransaction)value; } - } - - public override string CommandText - { - get { return _commandText; } - set { - if (CommandText == null || String.Compare(CommandText, value, true) != 0) { - _commandText = value; - _isCommandPrepared = false; - _explicitPrepare = false; - } - } - } - - protected virtual string InternalCommandText { - get { return CommandText; } - //set { CommandText = value; } - } - - internal CommandBehavior Behavior - { - get { return _behavior; } - set { _behavior = value; } - } - - bool IsCommandPrepared - { - get { return _isCommandPrepared; } - set { _isCommandPrepared = value; } - } - - bool NullParametersInPrepare - { - get { return _nullParametersInPrepare; } - set { _nullParametersInPrepare = value; } - } - - protected ArrayList InternalParameters - { - get { - if (_internalParameters == null) { - _internalParameters = new ArrayList(); - } - return _internalParameters; - } - } - - // Number of records affected by execution of batch statement - // -1 for SELECT statements. - internal int RecordsAffected - { - get { - return _recordsAffected; - } - } - - // AbstractDbCommand acts as IEnumerator over JDBC statement - // AbstractDbCommand.CurrentResultSet corresponds to IEnumerator.Current - protected internal virtual ResultSet CurrentResultSet - { - get { - try { - if (_currentResultSet == null && _hasResultSet) { - _currentResultSet = _statement.getResultSet(); - } - return _currentResultSet; - } - catch(SQLException e) { - throw new Exception(e.Message, e); - } - } - } - - protected internal java.sql.Statement Statement - { - get { return _statement; } - } -#if USE_DOTNET_REGEX - protected virtual Regex StoredProcedureRegExp -#else - protected virtual Pattern StoredProcedureRegExp -#endif - { - get { return SqlStatementsHelper.SimpleParameterStoredProcedureRegExp; } - } - - protected virtual SimpleRegex ParameterRegExp - { - get { return SqlStatementsHelper.SimpleParameterRegExp; } - } - - #endregion // Properties - - #region Methods - - protected abstract DbParameter CreateParameterInternal(); - - protected abstract void CheckParameters(); - - protected abstract DbDataReader CreateReader(); - - protected abstract DbParameterCollection CreateParameterCollection(AbstractDbCommand parent); - - protected internal abstract SystemException CreateException(SQLException e); - - public override int ExecuteNonQuery () - { - IDataReader reader = null; - try { - reader = ExecuteReader (); - } - finally { - if (reader != null) - reader.Close (); - } - return reader.RecordsAffected; - } - - public override object ExecuteScalar () - { - IDataReader reader = ExecuteReader(CommandBehavior.SequentialAccess); - - try { - do { - if (reader.FieldCount > 0 && reader.Read ()) - return reader.GetValue (0); - } - while (reader.NextResult ()); - return null; - } finally { - reader.Close(); - } - } - - public virtual void ResetCommandTimeout () - { - _commandTimeout = 30; - } - - public override void Cancel() - { - try { - if (_statement != null) - _statement.cancel(); - } - catch { - // MSDN says : "If there is nothing to cancel, nothing happens. - // However, if there is a command in process, and the attempt to cancel fails, - // no exception is generated." - } - } - - protected virtual bool SkipParameter(DbParameter parameter) - { - return false; - } - - protected sealed override DbParameter CreateDbParameter() - { - return CreateParameterInternal(); - } - - internal ArrayList DeriveParameters(string procedureName, bool throwIfNotExist) - { - try { - ArrayList col = _procedureColumnCache.GetProcedureColumns((AbstractDBConnection)Connection, procedureName, this); - if (col == null) { - if (throwIfNotExist) - throw ExceptionHelper.NoStoredProcedureExists(procedureName); - col = new ArrayList(); - } - - return col; - } - catch(SQLException e) { - throw CreateException(e); - } - } - - string CreateTableDirectCommandText(string tableNames) { - string forBrowse = String.Empty; - if ((Behavior & CommandBehavior.KeyInfo) != 0) { - AbstractDBConnection connection = (AbstractDBConnection)Connection; - if (connection != null) { - string dbname = connection.JdbcConnection.getMetaData().getDatabaseProductName(); - if (dbname == "Microsoft SQL Server") //must add "FOR BROWSE" for selects - forBrowse = " FOR BROWSE"; - } - } - - string[] names = tableNames.Split(','); - StringBuilder sb = new StringBuilder(); - - for(int i = 0; i < names.Length; i++) { - sb.Append("SELECT * FROM "); - sb.Append(names[i]); - sb.Append(forBrowse); - sb.Append(';'); - } - - if(names.Length <= 1) { - sb.Remove(sb.Length - 1,1); - } - return sb.ToString(); - } - - private string PrepareCommandTextAndParameters() - { - NullParametersInPrepare = false; - switch (CommandType) { - case CommandType.TableDirect : - return CreateTableDirectCommandText(CommandText); - case CommandType.StoredProcedure : - return CreateStoredProcedureCommandTextSimple (InternalCommandText, Parameters, DeriveParameters (InternalCommandText, false)); - case CommandType.Text : - - int userParametersPosition = 0; - int charsConsumed = 0; - StringBuilder sb = new StringBuilder(CommandText.Length); - - for (SimpleMatch match = SqlStatementsHelper.CompoundStatementSplitterReqExp.Match(CommandText); - match.Success; - match = match.NextMatch()) { - - int length = match.Length; - - if (length == 0) - continue; - - int start = match.Index; - string value = match.Value; - - sb.Append(CommandText, charsConsumed, start-charsConsumed); - charsConsumed = start + length; - -#if USE_DOTNET_REGEX - Match storedProcMatch = StoredProcedureRegExp.Match(value); - // count parameters for all kinds of simple statements - userParametersPosition += - (storedProcMatch.Success) ? - // statement is stored procedure call - CreateStoredProcedureCommandText(sb, value, storedProcMatch, Parameters, userParametersPosition) : - // statement is a simple SQL query - PrepareSimpleQuery(sb, value, Parameters, userParametersPosition); -#else - Matcher storedProcMatch = StoredProcedureRegExp.matcher((java.lang.CharSequence)(object)value); - userParametersPosition += - (storedProcMatch.find()) ? - // statement is stored procedure call - CreateStoredProcedureCommandText(sb, value, storedProcMatch, Parameters, userParametersPosition) : - // statement is a simple SQL query - PrepareSimpleQuery(sb, value, Parameters, userParametersPosition); -#endif - } - - sb.Append(CommandText, charsConsumed, CommandText.Length-charsConsumed); - - return sb.ToString(); - } - return null; - } - - string CreateStoredProcedureCommandTextSimple(string procedureName, IDataParameterCollection userParams, IList derivedParams) { - StringBuilder sb = new StringBuilder(); - - int curUserPos = 0; - int curDerivedPos = 0; - bool addParas = true; - string trimedProcedureName = (procedureName != null) ? procedureName.TrimEnd() : String.Empty; - if (trimedProcedureName.Length > 0 && trimedProcedureName[trimedProcedureName.Length-1] == ')') - addParas = false; - - AbstractDbParameter derivedParam = (derivedParams.Count > 0) ? (AbstractDbParameter)derivedParams[curDerivedPos] : null; - if (derivedParam != null) { - if (derivedParam.Direction == ParameterDirection.ReturnValue) - curDerivedPos++; - else - derivedParam = null; //play as if there is no retval parameter - } - AbstractDbParameter returnValueParameter = GetReturnParameter (userParams); - if (returnValueParameter != null) { - curUserPos++; - InternalParameters.Add(returnValueParameter); - sb.Append("{? = call "); - - if (derivedParam != null && !returnValueParameter.IsDbTypeSet) { - returnValueParameter.JdbcType = derivedParam.JdbcType; - } - } - else { - sb.Append("{call "); - } - - sb.Append(procedureName); - if (addParas) - sb.Append('('); - - bool needComma = false; - for (int i = curDerivedPos; i < derivedParams.Count; i++) { - AbstractDbParameter derivedParameter = (AbstractDbParameter)derivedParams[curDerivedPos++]; - - bool addParam = false; - - if (derivedParameter.IsSpecial) { - // derived parameter is special - never appears in user parameters or user values - InternalParameters.Add((AbstractDbParameter)derivedParameter.Clone()); - addParam = true; - } - else { - AbstractDbParameter userParameter = GetUserParameter(derivedParameter.Placeholder, userParams, curUserPos); - if (userParameter != null) { - curUserPos++; - InternalParameters.Add(userParameter); - addParam = true; - - if (derivedParameter != null && !userParameter.IsDbTypeSet) { - userParameter.JdbcType = derivedParameter.JdbcType; - } - } - } - - if (addParam) { - if (needComma) - sb.Append(','); - else - needComma = true; - - sb.Append('?'); - } - } - - for (int i = curUserPos; i < userParams.Count; i++) { - if (needComma) - sb.Append(','); - else - needComma = true; - - AbstractDbParameter userParameter = (AbstractDbParameter)userParams[curUserPos++]; - InternalParameters.Add(userParameter); - - sb.Append('?'); - } - - if (addParas) - sb.Append(')'); - sb.Append('}'); - return sb.ToString(); - } - - /// - /// We suppose that user parameters are in the same order as devived parameters except the special cases - /// (return value, oracle ref cursors etc.) - /// - //protected virtual string CreateStoredProcedureCommandText(string procedureName, IList userParametersList, int userParametersListStart/*, int userParametersListCount*/, string[] userValuesList, ArrayList derivedParametersList) -#if USE_DOTNET_REGEX - int CreateStoredProcedureCommandText(StringBuilder sb, string sql, Match match, IDataParameterCollection userParams, int userParamsStartPosition) -#else - int CreateStoredProcedureCommandText(StringBuilder sb, string sql, Matcher match, IDataParameterCollection userParams, int userParamsStartPosition) -#endif - { - int curUserPos = userParamsStartPosition; -#if USE_DOTNET_REGEX - Group procNameGroup = null; - - for (Match procNameMatch = match; procNameMatch.Success; procNameMatch = procNameMatch.NextMatch()){ - procNameGroup = match.Groups["PROCNAME"]; - if (!procNameGroup.Success) { - continue; - } - } - - if (procNameGroup == null || !procNameGroup.Success) - throw new ArgumentException("Not a stored procedure call: '{0}'", sql); - - ArrayList derivedParameters = DeriveParameters(procNameGroup.Value, false); -#else - ArrayList derivedParameters = DeriveParameters(match.group(2).Trim(), false); -#endif - int curDerivedPos = 0; - - AbstractDbParameter retValderivedParameter = curDerivedPos < derivedParameters.Count ? - (AbstractDbParameter)derivedParameters[curDerivedPos] : null; - if (retValderivedParameter != null && retValderivedParameter.Direction == ParameterDirection.ReturnValue) - curDerivedPos++; - - int queryCurrentPosition = 0; - -#if USE_DOTNET_REGEX - for (Match retValMatch = match; retValMatch.Success; retValMatch = retValMatch.NextMatch()){ - Group retval = retValMatch.Groups["RETVAL"]; - if (!retval.Success) { - continue; - } - - int retvalIndex = retval.Index; - string retvalValue = retval.Value; - int retvalLength = retval.Length; -#else - int retvalIndex = match.start(1); - for (;retvalIndex >= 0;) { - string retvalValue = match.group(1); - int retvalLength = retvalValue.Length; -#endif - - sb.Append(sql, queryCurrentPosition, retvalIndex); - AbstractDbParameter userParameter = GetUserParameter(retvalValue, userParams, curUserPos); - if (userParameter != null) { - sb.Append('?'); - InternalParameters.Add(userParameter); - - if (retValderivedParameter != null && !userParameter.IsDbTypeSet) { - userParameter.JdbcType = retValderivedParameter.JdbcType; - } - - curUserPos++; - } - else { - sb.Append(retvalValue); - } - - queryCurrentPosition = (retvalIndex + retvalLength); - - break; - } - -#if USE_DOTNET_REGEX - sb.Append(sql, queryCurrentPosition, procNameGroup.Index + procNameGroup.Length - queryCurrentPosition); - queryCurrentPosition = procNameGroup.Index + procNameGroup.Length; -#else - sb.Append(sql, queryCurrentPosition, match.end(2) - queryCurrentPosition); - queryCurrentPosition = match.end(2); -#endif - - bool hasUserParams = false; - -#if USE_DOTNET_REGEX - must rewrite the regex to not parse params to have single code with java regex -#else - int paramsStart = match.start(3); - if (paramsStart >= 0) { -#endif - - hasUserParams = true; - sb.Append(sql,queryCurrentPosition,paramsStart - queryCurrentPosition); - queryCurrentPosition = paramsStart; - - for (SimpleMatch m = SqlStatementsHelper.ProcedureParameterSplitterReqExp.Match(match.group(3)); - m.Success;m = m.NextMatch()) { - - SimpleCapture parameterCapture = m; - sb.Append(sql,queryCurrentPosition,paramsStart + parameterCapture.Index - queryCurrentPosition); - - // advance in query - queryCurrentPosition = paramsStart + parameterCapture.Index + parameterCapture.Length; - - AbstractDbParameter derivedParameter = curDerivedPos < derivedParameters.Count ? - (AbstractDbParameter)derivedParameters[curDerivedPos++] : null; - - //check for special params - while (derivedParameter != null && derivedParameter.IsSpecial) { - // derived parameter is special - never appears in user parameters or user values - InternalParameters.Add((AbstractDbParameter)derivedParameter.Clone()); - sb.Append('?'); - sb.Append(','); - - derivedParameter = curDerivedPos < derivedParameters.Count ? - (AbstractDbParameter)derivedParameters[curDerivedPos++] : null; - } - - AbstractDbParameter userParameter = GetUserParameter(parameterCapture.Value.Trim(), userParams, curUserPos); - - if (userParameter != null) { - sb.Append('?'); - InternalParameters.Add(userParameter); - if (derivedParameter != null && !userParameter.IsDbTypeSet) { - userParameter.JdbcType = derivedParameter.JdbcType; - } - // advance in user parameters - curUserPos++; - } - else { - sb.Append(parameterCapture.Value); - } - } - } - - bool addedSpecialParams = false; - - for (int i = curDerivedPos; i < derivedParameters.Count;) { - AbstractDbParameter derivedParameter = (AbstractDbParameter)derivedParameters[i++]; - if (derivedParameter.IsSpecial) { - // derived parameter is special - never appears in user parameters or user values - if (!hasUserParams && !addedSpecialParams) { - addedSpecialParams = true; - curDerivedPos++; - sb.Append('('); - } - - for (;curDerivedPos < i;curDerivedPos++) - sb.Append(','); - - InternalParameters.Add((AbstractDbParameter)derivedParameter.Clone()); - sb.Append('?'); - } - } - - if (!hasUserParams && addedSpecialParams) - sb.Append(')'); - - sb.Append(sql,queryCurrentPosition,sql.Length - queryCurrentPosition); - return curUserPos - userParamsStartPosition; - } - - protected virtual AbstractDbParameter GetUserParameter(string parameterName, IList userParametersList, int userParametersListPosition) - { - if (userParametersListPosition < userParametersList.Count) { - AbstractDbParameter param = (AbstractDbParameter)userParametersList[userParametersListPosition]; - if (param.Placeholder == parameterName) - return param; - } - return null; - } - - protected virtual AbstractDbParameter GetReturnParameter (IList userParametersList) - { - AbstractDbParameter param = GetUserParameter ("?", userParametersList, 0); - - if (param != null && param.Direction == ParameterDirection.ReturnValue) - return param; - - return null; - } - - int PrepareSimpleQuery(StringBuilder sb, string query, IList userParametersList, int userParametersListStart) - { - int queryCurrentPosition = 0; - int userParametersListPosition = userParametersListStart; - - if (userParametersList.Count > 0) { - for (SimpleMatch m = ParameterRegExp.Match(query); - m.Success;m = m.NextMatch()) { - - SimpleCapture parameterCapture = m; - sb.Append(query,queryCurrentPosition,parameterCapture.Index - queryCurrentPosition); - - // advance in query - queryCurrentPosition = parameterCapture.Index + parameterCapture.Length; - - AbstractDbParameter userParameter = GetUserParameter(parameterCapture.Value, userParametersList, userParametersListPosition); - - if (userParameter != null) { - if (IsNullParameter(userParameter)) { - sb.Append("null"); - NullParametersInPrepare = true; - } - else { - sb.Append('?'); - InternalParameters.Add(userParameter); - } - // advance in user parameters - userParametersListPosition++; - } - else { - sb.Append(parameterCapture.Value); - } - } - } - - sb.Append(query,queryCurrentPosition,query.Length - queryCurrentPosition); - int userParamsConsumed = userParametersListPosition - userParametersListStart; - - if ((Behavior & CommandBehavior.KeyInfo) == 0) - return userParamsConsumed; - - AbstractDBConnection connection = (AbstractDBConnection)Connection; - if (connection == null) - return userParamsConsumed; - - string dbname = connection.JdbcConnection.getMetaData().getDatabaseProductName(); - if (dbname == "Microsoft SQL Server") { //must add "FOR BROWSE" for selects -#if USE_DOTNET_REGEX - if (!SqlStatementsHelper.ForBrowseStatementReqExp.IsMatch(query)) - sb.Append(" FOR BROWSE"); -#else - if (!SqlStatementsHelper.ForBrowseStatementReqExp.matcher ((java.lang.CharSequence)(object)query).find ()) - sb.Append (" FOR BROWSE"); -#endif - } - - return userParamsConsumed; - } - - protected virtual bool IsNullParameter(AbstractDbParameter parameter) - { - return ((parameter.Value == null || parameter.Value == DBNull.Value) && !parameter.IsDbTypeSet); - } - - protected virtual void PrepareInternalParameters() - { - InternalParameters.Clear(); - } - - protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) - { - AbstractDBConnection connection = (AbstractDBConnection)Connection; - if (connection == null) { - throw ExceptionHelper.ConnectionNotInitialized("ExecuteReader"); - } - - connection.IsExecuting = true; - - try { - IDbTransaction transaction = Transaction; - if ((transaction != null && transaction.Connection != connection) || - (transaction == null && !connection.JdbcConnection.getAutoCommit ())) { - throw ExceptionHelper.TransactionNotInitialized (); - } - - Behavior = behavior; - - PrepareInternalParameters(); - PrepareInternal(); - - // For SchemaOnly there is no need for statement execution - if (Behavior != CommandBehavior.SchemaOnly) { - _recordsAffected = -1; - - // FIXME: this causes SP in MS Sql Server to create no mor than one row. - if ((Behavior & CommandBehavior.SingleRow) != 0) { - _statement.setMaxRows (1); - } - - if(_statement is PreparedStatement) { - BindParameters(InternalParameters); - _hasResultSet = ((PreparedStatement)_statement).execute(); - } - else { - _hasResultSet =_statement.execute(_javaCommandText); - } - - if (!_hasResultSet) { - int updateCount = _statement.getUpdateCount(); - if (updateCount >= 0) { - AccumulateRecordsAffected(updateCount); - _hasResultSet = true; //play as if we have resultset - NextResultSet(); - } - } - } - connection.IsFetching = true; - try { - _currentReader = CreateReader(); - } - catch(Exception e) { - connection.IsFetching = false; - throw e; - } - return _currentReader; - } - catch(SQLException e) { - throw CreateException(e); - } - finally { - connection.IsExecuting = false; - NullParametersInPrepare = false; - } - } - - public override void Prepare() - { - ((AbstractDBConnection)Connection).IsExecuting = true; - try { - CheckParameters(); - _explicitPrepare = true; - } - finally { - ((AbstractDBConnection)Connection).IsExecuting = false; - } - } - - private void PrepareInternal() - { - if ((Connection == null) || (Connection.State != ConnectionState.Open)) { - throw ExceptionHelper.ConnectionNotOpened("Prepare",(Connection != null) ? Connection.State.ToString() : ""); - } - - if (IsCommandPrepared) { - // maybe we have to prepare the command again - bool hasNullParameters = false; - for(int i = 0; (i < Parameters.Count) && !hasNullParameters; i++) { - AbstractDbParameter parameter = (AbstractDbParameter)Parameters[i]; - if (IsNullParameter(parameter)) { - // if we still have null parameters - have to prepare agail - IsCommandPrepared = false; - hasNullParameters = true; - } - } - - if (!NullParametersInPrepare && hasNullParameters) { - // if we prepeared using null parameters and now there is no null parameters - need to prepare again - IsCommandPrepared = false; - } - } - - if (!IsCommandPrepared) { - - _javaCommandText = PrepareCommandTextAndParameters(); - - java.sql.Connection jdbcCon = _connection.JdbcConnection; - - // For SchemaOnly we just prepare statement (for future use in GetSchemaTable) - if (Behavior == CommandBehavior.SchemaOnly) { - if (CommandType == CommandType.StoredProcedure) - _statement = jdbcCon.prepareCall(_javaCommandText); - else - _statement = jdbcCon.prepareStatement(_javaCommandText); - return; - } - - if (CommandType == CommandType.StoredProcedure) - _statement = jdbcCon.prepareCall(_javaCommandText); - else { - int internalParametersCount = InternalParameters.Count; - if ( internalParametersCount > 0) { - bool hasOnlyInputParameters = true; - for(int i=0; i < internalParametersCount; i++) { - AbstractDbParameter internalParameter = (AbstractDbParameter)InternalParameters[i]; - if (IsNullParameter(internalParameter)) { - NullParametersInPrepare = true; - } - - if ((internalParameter.Direction & ParameterDirection.Output) != 0){ - hasOnlyInputParameters = false; - } - } - - if (hasOnlyInputParameters) { - _statement = jdbcCon.prepareStatement(_javaCommandText); - } - else { - _statement = jdbcCon.prepareCall(_javaCommandText); - } - } - else { - if (_explicitPrepare) { - _statement = jdbcCon.prepareStatement(_javaCommandText); - } - else { - _statement = jdbcCon.createStatement(); - } - } - } - IsCommandPrepared = true; - } - } - - protected void BindParameters(ArrayList parameters) - { - for(int parameterIndex = 0; parameterIndex < parameters.Count; parameterIndex++) { - AbstractDbParameter parameter = (AbstractDbParameter)parameters[parameterIndex]; - switch (parameter.Direction) { - case ParameterDirection.Input : - BindInputParameter(parameter,parameterIndex); - break; - case ParameterDirection.InputOutput: - BindInputParameter(parameter,parameterIndex); - BindOutputParameter(parameter,parameterIndex); - break; - case ParameterDirection.Output : - BindOutputParameter(parameter,parameterIndex); - break; - case ParameterDirection.ReturnValue : - BindOutputParameter(parameter,parameterIndex); - break; - } - } - } - - protected virtual void BindInputParameter(AbstractDbParameter parameter, int parameterIndex) - { - object value = parameter.ConvertedValue; - // java parameters are 1 based, while .net are 0 based - parameterIndex++; - PreparedStatement preparedStatement = ((PreparedStatement)_statement); - - switch ((DbConvert.JavaSqlTypes)parameter.JdbcType) { - case DbConvert.JavaSqlTypes.DATALINK: - case DbConvert.JavaSqlTypes.DISTINCT: - case DbConvert.JavaSqlTypes.JAVA_OBJECT: - case DbConvert.JavaSqlTypes.OTHER: - case DbConvert.JavaSqlTypes.REF: - case DbConvert.JavaSqlTypes.STRUCT: { - preparedStatement.setObject(parameterIndex, value, (int)parameter.JdbcType); - return; - } - } - - if ((value is DBNull) || (value == null)) { - preparedStatement.setNull(parameterIndex, (int)((AbstractDbParameter)parameter).JdbcType); - } - else if (value is long) { - preparedStatement.setLong(parameterIndex, (long)value); - } - else if (value is byte[]) { - if (((byte[])value).Length <= 4000) { - preparedStatement.setBytes(parameterIndex, vmw.common.TypeUtils.ToSByteArray((byte[]) value)); - } - else { - InputStream iStream=new ByteArrayInputStream(vmw.common.TypeUtils.ToSByteArray((byte[]) value)); - preparedStatement.setBinaryStream(parameterIndex,iStream,((byte[])value).Length); - } - } - else if (value is byte) { - preparedStatement.setByte(parameterIndex, (sbyte)(byte)value); - } - else if (value is char[]) { - Reader reader = new CharArrayReader((char[])value); - preparedStatement.setCharacterStream(parameterIndex,reader,((char[])value).Length); - } - else if (value is bool) { - preparedStatement.setBoolean(parameterIndex, (bool) value); - } - else if (value is char) { - preparedStatement.setString(parameterIndex, ((char)value).ToString()); - } - else if (value is DateTime) { - switch ((DbConvert.JavaSqlTypes)parameter.JdbcType) { - default: - case DbConvert.JavaSqlTypes.TIMESTAMP: - preparedStatement.setTimestamp(parameterIndex,DbConvert.ClrTicksToJavaTimestamp(((DateTime)value).Ticks)); - break; - case DbConvert.JavaSqlTypes.TIME: - preparedStatement.setTime(parameterIndex,DbConvert.ClrTicksToJavaTime(((DateTime)value).Ticks)); - break; - case DbConvert.JavaSqlTypes.DATE: - preparedStatement.setDate(parameterIndex,DbConvert.ClrTicksToJavaDate(((DateTime)value).Ticks)); - break; - } - } - else if (value is TimeSpan) { - if (parameter.JdbcType == (int)DbConvert.JavaSqlTypes.TIMESTAMP) - preparedStatement.setTimestamp(parameterIndex,DbConvert.ClrTicksToJavaTimestamp(((TimeSpan)value).Ticks)); - else - preparedStatement.setTime(parameterIndex,DbConvert.ClrTicksToJavaTime(((TimeSpan)value).Ticks)); - } - else if (value is Decimal) { - preparedStatement.setBigDecimal(parameterIndex, vmw.common.PrimitiveTypeUtils.DecimalToBigDecimal((Decimal) value)); - } - else if (value is double) { - preparedStatement.setDouble(parameterIndex, (double)value); - } - else if (value is float) { - preparedStatement.setFloat(parameterIndex, (float)value); - } - else if (value is int) { - preparedStatement.setInt(parameterIndex, (int)value); - } - else if (value is string) { - //can not be done for inout params, due to Oracle problem with FIXED_CHAR out param fetching - if (parameter.Direction == ParameterDirection.Input && - preparedStatement is Mainsoft.Data.Jdbc.Providers.IPreparedStatement && - (DbConvert.JavaSqlTypes)parameter.JdbcType == DbConvert.JavaSqlTypes.CHAR) { - ((Mainsoft.Data.Jdbc.Providers.IPreparedStatement)preparedStatement) - .setChar(parameterIndex, (string)value); - } - else - preparedStatement.setString(parameterIndex, (string)value); - } - else if (value is Guid) { - preparedStatement.setString(parameterIndex, value.ToString()); - } - else if (value is short) { - preparedStatement.setShort(parameterIndex, (short)value); - } - else if (value is sbyte) { - preparedStatement.setByte(parameterIndex, (sbyte)value); - } - else { - preparedStatement.setObject(parameterIndex, value); - } - } - - protected virtual void BindOutputParameter(AbstractDbParameter parameter, int parameterIndex) - { - parameter.Validate(); - int jdbcType = (int)parameter.JdbcType; - // java parameters are 1 based, while .net are 0 based - parameterIndex++; - - CallableStatement callableStatement = ((CallableStatement)_statement); - - // the scale has a meening only in DECIMAL and NUMERIC parameters - if (jdbcType == Types.DECIMAL || jdbcType == Types.NUMERIC) { - if(parameter.DbType == DbType.Currency) { - callableStatement.registerOutParameter(parameterIndex, jdbcType, 4); - } - else { - callableStatement.registerOutParameter(parameterIndex, jdbcType, parameter.Scale); - } - } - else { - callableStatement.registerOutParameter(parameterIndex, jdbcType); - } - } - - private void FillOutputParameters() - { - if (!(_statement is CallableStatement)) { - return; - } - for(int i = 0; i < InternalParameters.Count; i++) { - AbstractDbParameter parameter = (AbstractDbParameter)InternalParameters[i]; - ParameterDirection direction = parameter.Direction; - if (((direction & ParameterDirection.Output) != 0) && !SkipParameter(parameter)) { - FillOutputParameter(parameter, i); - } - // drop jdbc type of out parameter, since it possibly was updated in ExecuteReader - parameter.IsJdbcTypeSet = false; - } - } - - protected virtual void FillOutputParameter(DbParameter parameter, int index) - { - CallableStatement callableStatement = (CallableStatement)_statement; - ParameterMetadataWrapper parameterMetadataWrapper = null; - // FIXME wait for other drivers to implement -// try { -// parameterMetadataWrapper = new ParameterMetadataWrapper(callableStatement.getParameterMetaData()); -// } -// catch { -// // suppress error : ms driver for sql server does not implement getParameterMetaData -// // suppress exception : ms driver for sql server does not implement getParameterMetaData -// } - DbConvert.JavaSqlTypes javaSqlType = (DbConvert.JavaSqlTypes)((AbstractDbParameter)parameter).JdbcType; - try { - parameter.Value = DbConvert.JavaResultSetToClrWrapper(callableStatement,index,javaSqlType,parameter.Size,parameterMetadataWrapper); - } - catch(java.sql.SQLException e) { - throw CreateException(e); - } - } - - // AbstractDbCommand acts as IEnumerator over JDBC statement - // AbstractDbCommand.NextResultSet corresponds to IEnumerator.MoveNext - protected internal virtual bool NextResultSet() - { - if (!_hasResultSet) - return false; - - try { - for(;;) { - _hasResultSet = _statement.getMoreResults(); - if (_hasResultSet) - return true; - int updateCount = _statement.getUpdateCount(); - if (updateCount < 0) - return false; - - AccumulateRecordsAffected(updateCount); - } - } - catch (SQLException e) { - throw CreateException(e); - } - finally { - _currentResultSet = null; - } - } - - private void AccumulateRecordsAffected(int updateCount) - { - if (_recordsAffected < 0) { - _recordsAffected = updateCount; - } - else { - _recordsAffected += updateCount; - } - } - - internal void OnReaderClosed(object reader) - { - CloseInternal(); - if (Connection != null) { - ((AbstractDBConnection)Connection).RemoveReference(reader); - ((AbstractDBConnection)Connection).IsFetching = false; - if ((Behavior & CommandBehavior.CloseConnection) != 0) { - Connection.Close(); - } - } - } - - internal void CloseInternal() - { - if (Behavior != CommandBehavior.SchemaOnly) { - if (_statement != null) { - while (NextResultSet()) { - } - FillOutputParameters(); - } - } - _currentReader = null; - CleanUp(); - } - - protected override void Dispose(bool disposing) - { - if (disposing) { - CleanUp(); - } - base.Dispose(disposing); - } - - private void CleanUp() - { - if (_currentReader != null) { - // we must preserve statement object until we have an associated reader object that might access it. - return; - } - if (Connection != null) { - ((AbstractDBConnection)Connection).RemoveReference(this); - } - if (_statement != null) { - _statement.close(); - _statement = null; - } - IsCommandPrepared = false; - _internalParameters = null; - _currentResultSet = null; - } - - internal void OnSchemaChanging() - { - } - - #endregion // Methods - - #region ICloneable Members - - public virtual object Clone() { - AbstractDbCommand target = (AbstractDbCommand)MemberwiseClone(); - target._statement = null; - target._isCommandPrepared = false; - target._internalParameters = null; - target._javaCommandText = null; - target._recordsAffected = -1; - target._currentResultSet = null; - target._currentReader = null; - target._nullParametersInPrepare = false; - target._hasResultSet = false; - target._explicitPrepare = false; - if (Parameters != null && Parameters.Count > 0) { - target._parameters = CreateParameterCollection(target); - for(int i=0 ; i < Parameters.Count; i++) { - target.Parameters.Add(((AbstractDbParameter)Parameters[i]).Clone()); - } - } - return target; - } - - #endregion - } -} diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBConnection.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBConnection.cs deleted file mode 100644 index c5b422296d5..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBConnection.cs +++ /dev/null @@ -1,737 +0,0 @@ -// -// System.Data.Common.AbstractDBConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Globalization; -using System.Data; -using System.Data.ProviderBase; -using System.Data.Configuration; -using System.Configuration; -using System.Collections; -using System.Collections.Specialized; -using System.Text; -using System.Text.RegularExpressions; -using Mainsoft.Data.Jdbc.Providers; -using System.Data.Common; - -using java.sql; -using javax.sql; -using javax.naming; - -using Mainsoft.Data.Configuration; - -namespace System.Data.ProviderBase -{ - public abstract class AbstractDBConnection : DbConnection, ICloneable - { - #region ObjectNamesHelper - - private sealed class ObjectNamesHelper - { - //static readonly Regex NameOrder = new Regex(@"^\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)+(\s*(\w|!|\#|\$)+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - static readonly Regex NameOrder = new Regex(@"^((\[(?[^\]]+)\])|(?[^\.\[\]]+))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - - //static readonly Regex SchemaNameOrder = new Regex(@"^\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)+(\s*(\w|!|\#|\$)+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - static readonly Regex SchemaNameOrder = new Regex(@"^((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - //static readonly Regex CatalogSchemaNameOrder = new Regex(@"^\s*((\[\s*(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)+(\s*(\w|!|\#|\$)+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - //static readonly Regex CatalogSchemaNameOrder = new Regex(@"^\s*((\[\s*(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])*(\s*([^\.\s])+)*))\s*\.\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])*(\s*([^\.\s])+)*))\s*\.\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])+(\s*([^\.\s])+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - static readonly Regex CatalogSchemaNameOrder = new Regex(@"^((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - - //static readonly Regex CatalogNameOrder = new Regex(@"^\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)+(\s*(\w|!|\#|\$)+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - //static readonly Regex CatalogNameOrder = new Regex(@"^\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])*(\s*([^\.\s])+)*))\s*\.\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])+(\s*([^\.\s])+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - static readonly Regex CatalogNameOrder = new Regex(@"^((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - //static readonly Regex SchemaCatalogNameOrder = new Regex(@"^\s*((\[\s*(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)*(\s*(\w|!|\#|\$)+)*))\s*\.\s*((\[(?(\s*[^\[\]\s])+)\s*\])|(?(\w|!|\#|\$)+(\s*(\w|!|\#|\$)+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - //static readonly Regex SchemaCatalogNameOrder = new Regex(@"^\s*((\[\s*(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])*(\s*([^\.\s])+)*))\s*\.\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])*(\s*([^\.\s])+)*))\s*\.\s*((\[(?(\s*[^\]\s])+)\s*\])|(?([^\.\s])+(\s*([^\.\s])+)*))\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - static readonly Regex SchemaCatalogNameOrder = new Regex(@"^((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))\s*\.\s*((\[(?[^\]]+)\])|(?[^\.\[\]]+))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); - - internal static ObjectNameResolver[] GetSyntaxPatterns(AbstractDBConnection connection) - { - ArrayList collection = new ArrayList(); - collection.Add(new ObjectNameResolver(NameOrder)); - - ObjectNameResolversCollection basic = (ObjectNameResolversCollection) ConfigurationSettings.GetConfig ("Mainsoft.Data.Configuration/objectnameresolution"); - - java.sql.DatabaseMetaData metaData = connection.JdbcConnection.getMetaData(); - string productName = metaData.getDatabaseProductName(); - - foreach(ObjectNameResolver nameResolver in basic) { - if (productName.IndexOf(nameResolver.DbName) != -1) { - collection.Add(nameResolver); - } - } - - //defaults - if (metaData.isCatalogAtStart()) { - collection.Add(new ObjectNameResolver(SchemaNameOrder)); - collection.Add(new ObjectNameResolver(CatalogNameOrder)); - collection.Add(new ObjectNameResolver(CatalogSchemaNameOrder)); - collection.Add(new ObjectNameResolver(SchemaCatalogNameOrder)); - } - else { - collection.Add(new ObjectNameResolver(CatalogNameOrder)); - collection.Add(new ObjectNameResolver(SchemaNameOrder)); - collection.Add(new ObjectNameResolver(SchemaCatalogNameOrder)); - collection.Add(new ObjectNameResolver(CatalogSchemaNameOrder)); - } - - return (ObjectNameResolver[])collection.ToArray(typeof(ObjectNameResolver)); - } - } - - #endregion // ObjectNamesHelper - - #region Fields - - private const int DEFAULT_TIMEOUT = 15; - - private java.sql.Connection _jdbcConnnection; - private ConnectionState _internalState; - private object _internalStateSync = new object(); - - private string _connectionString = String.Empty; - IConnectionStringDictionary _connectionStringBuilder; - IConnectionProvider _connectionProvider; - - private ArrayList _referencedObjects = new ArrayList(); - private ObjectNameResolver[] _syntaxPatterns; - - #endregion // Fields - - #region Constructors - - public AbstractDBConnection(string connectionString) - { - _connectionString = connectionString; - } - - #endregion // Constructors - - #region Properties - - public override String ConnectionString - { - get { return _connectionString; } - set { - if (IsOpened) { - throw ExceptionHelper.NotAllowedWhileConnectionOpen("ConnectionString",_internalState); - } - _connectionString = value; - _connectionProvider = null; - _connectionStringBuilder = null; - } - } - - public override int ConnectionTimeout - { - get { - string timeoutStr = (string)ConnectionStringBuilder["loginTimeout"]; - if (timeoutStr != null && timeoutStr.Length > 0) { - try { - return Convert.ToInt32(timeoutStr); - } - catch(FormatException) { - throw ExceptionHelper.InvalidValueForKey("connect timeout"); - } - catch (OverflowException) { - throw ExceptionHelper.InvalidValueForKey("connect timeout"); - } - } - return DEFAULT_TIMEOUT; - } - } - - public override String Database - { - get { - if ((State & ConnectionState.Open) != 0) - return JdbcConnection.getCatalog(); - - return (string)ConnectionStringBuilder["DATABASE"]; - } - } - - public override ConnectionState State - { - get { - try { - if ((JdbcConnection == null) || JdbcConnection.isClosed()) { - // jdbc connection not initialized or closed - if (_internalState == ConnectionState.Closed ) { - return ConnectionState.Closed; - } - } - else { - // jdbc connection is opened - if ((_internalState & ConnectionState.Open) != 0) { - return ConnectionState.Open; - } - } - return ConnectionState.Broken; - } - catch (SQLException) { - return ConnectionState.Broken; - } - } - } - - internal bool IsExecuting - { - get { - return ((_internalState & ConnectionState.Executing) != 0); - } - - set { - lock(_internalStateSync) { - // to switch to executing, the connection must be in opened - if (value) { - if (_internalState != ConnectionState.Open) { - if (IsFetching) { - throw ExceptionHelper.OpenedReaderExists(); - } - throw ExceptionHelper.OpenConnectionRequired("",_internalState); - } - _internalState |= ConnectionState.Executing; - } - else { - if (!IsExecuting) { - throw new InvalidOperationException("Connection : Impossible to tear down from state " + ConnectionState.Executing.ToString() + " while in state " + _internalState.ToString()); - } - _internalState &= ~ConnectionState.Executing; - } - } - } - } - - internal bool IsFetching - { - get { - return ((_internalState & ConnectionState.Fetching) != 0); - } - - set { - lock(_internalStateSync) { - if (value) { - // to switch to fetching connection must be in opened, executing - if (((_internalState & ConnectionState.Open) == 0) || ((_internalState & ConnectionState.Executing) == 0)) { - throw ExceptionHelper.OpenConnectionRequired("",_internalState); - } - _internalState |= ConnectionState.Fetching; - } - else { - if (!IsFetching) { - throw new InvalidOperationException("Connection : Impossible to tear down from state " + ConnectionState.Fetching.ToString() + " while in state " + _internalState.ToString()); - } - _internalState &= ~ConnectionState.Fetching; - } - } - } - } - - internal bool IsOpened - { - get { - return ((_internalState & ConnectionState.Open) != 0); - } - - set { - lock(_internalStateSync) { - if (value) { - // only connecting connection can be opened - if ((_internalState != ConnectionState.Connecting)) { - throw ExceptionHelper.ConnectionAlreadyOpen(_internalState); - } - _internalState |= ConnectionState.Open; - } - else { - if (!IsOpened) { - throw new InvalidOperationException("Connection : Impossible to tear down from state " + ConnectionState.Open.ToString() + " while in state " + _internalState.ToString()); - } - _internalState &= ~ConnectionState.Open; - } - } - } - } - - internal bool IsConnecting - { - get { - return ((_internalState & ConnectionState.Connecting) != 0); - } - - set { - lock(_internalStateSync) { - if (value) { - // to switch to connecting conection must be in closed or in opened - if ((_internalState != ConnectionState.Closed) && (_internalState != ConnectionState.Open)) { - throw ExceptionHelper.ConnectionAlreadyOpen(_internalState); - } - _internalState |= ConnectionState.Connecting; - } - else { - if (!IsConnecting) { - throw new InvalidOperationException("Connection : Impossible to tear down from state " + ConnectionState.Connecting.ToString() + " while in state " + _internalState.ToString()); - } - _internalState &= ~ConnectionState.Connecting; - } - } - } - } - - public override string DataSource - { - get { - return (string)ConnectionStringBuilder["SERVERNAME"]; - } - } - - internal ConnectionState InternalState - { - get { return _internalState; } - } - - - protected internal java.sql.Connection JdbcConnection - { - get { return _jdbcConnnection; } - set { _jdbcConnnection = value; } - } - - internal ObjectNameResolver[] SyntaxPatterns - { - get { - if (_syntaxPatterns == null) { - _syntaxPatterns = ObjectNamesHelper.GetSyntaxPatterns(this); - } - return _syntaxPatterns; - } - } - - protected internal IConnectionProvider ConnectionProvider { - get { - try { - if (_connectionProvider == null) - _connectionProvider = GetConnectionProvider(); - - return _connectionProvider; - } - catch(SQLException exp) { - throw CreateException(exp); - } - } - } - protected internal IConnectionStringDictionary ConnectionStringBuilder { - get { - try { - if (_connectionStringBuilder == null) - _connectionStringBuilder = ConnectionProvider.GetConnectionStringBuilder(ConnectionString); - - return _connectionStringBuilder; - } - catch(SQLException exp) { - throw CreateException(exp); - } - } - } - protected abstract IConnectionProvider GetConnectionProvider(); - - static protected IConnectionProvider GetConnectionProvider(string sectionMame, string provider) { - if (provider == null) - throw new ArgumentNullException("provider"); - - IList providers = (IList) ConfigurationSettings.GetConfig(sectionMame); - if (providers.Count == 0) - throw new ArgumentException("Configuration section is empty.", "sectionName"); - - for (int i = 0; i < providers.Count; i++) { - IDictionary providerInfo = (IDictionary) providers[i]; - - string curProvider = (string)providerInfo[ConfigurationConsts.Name]; - if (String.Compare(provider, 0, curProvider, 0, provider.Length, StringComparison.OrdinalIgnoreCase) == 0) { - string providerType = (string) providerInfo [ConfigurationConsts.ProviderType]; - if (providerType == null || providerType.Length == 0) - return new GenericProvider (providerInfo); - else { - Type t = Type.GetType (providerType); - return (IConnectionProvider) Activator.CreateInstance (t , new object[] {providerInfo}); - } - } - } - - throw new ArgumentException( - String.Format("Unknown provider name '{0}'", provider), "ConnectionString"); - } - - #endregion // Properties - - #region Methods - // since WS also does not permits dynamically change of login timeout and tomcat does no implements - do not do it at all - //ds.setLoginTimeout(ConnectionTimeout); - - protected internal abstract void OnSqlWarning(SQLWarning warning); - - protected abstract SystemException CreateException(SQLException e); - - protected abstract SystemException CreateException(string message); - - public override void Close() - { - ConnectionState orig = State; - try { - ClearReferences(); - if (JdbcConnection != null && !JdbcConnection.isClosed()) { - if (!JdbcConnection.getAutoCommit()) - JdbcConnection.rollback(); - JdbcConnection.close(); - } - } - catch (Exception e) { - // suppress exception -#if DEBUG - Console.WriteLine("Exception catched at Conection.Close() : {0}\n{1}\n{2}",e.GetType().FullName,e.Message,e.StackTrace); -#endif - } - finally { - JdbcConnection = null; - lock(_internalStateSync) { - _internalState = ConnectionState.Closed; - } - } - - ConnectionState current = State; - if (current != orig) - OnStateChange (new StateChangeEventArgs (orig, current)); - } - - internal protected virtual void OnSqlException(SQLException exp) - { - throw CreateException(exp); - } - - internal void AddReference(object referencedObject) - { lock(_referencedObjects.SyncRoot) { - _referencedObjects.Add(new WeakReference(referencedObject)); - } - } - - internal void RemoveReference(object referencedObject) - { - lock(_referencedObjects.SyncRoot) { - for(int i = 0; i < _referencedObjects.Count; i++) { - WeakReference wr = (WeakReference) _referencedObjects[i]; - if (wr.IsAlive && (wr.Target == referencedObject)) { - _referencedObjects.RemoveAt(i); - } - } - } - } - - private void ClearReferences() - { - ArrayList oldList = _referencedObjects; - _referencedObjects = new ArrayList(); - - for(int i = 0; i < oldList.Count; i++) { - WeakReference wr = (WeakReference) oldList[i]; - if (wr.IsAlive) { - ClearReference(wr.Target); - } - } - } - - private void ClearReference(object referencedObject) - { - try { - if (referencedObject is AbstractDbCommand) { - ((AbstractDbCommand)referencedObject).CloseInternal(); - } - else if (referencedObject is AbstractDataReader) { - ((AbstractDataReader)referencedObject).CloseInternal(); - } - } - catch (SQLException) { - // suppress exception since it's possible that command or reader are in inconsistent state - } - } - - public override void Open() - { - if (_connectionString == null || _connectionString.Length == 0) { - throw ExceptionHelper.ConnectionStringNotInitialized(); - } - - IsConnecting = true; - try { - if (JdbcConnection != null && !JdbcConnection.isClosed()) { - throw ExceptionHelper.ConnectionAlreadyOpen(_internalState); - } - - JdbcConnection = ConnectionProvider.GetConnection (ConnectionStringBuilder); - - IsOpened = true; - - OnStateChange (new StateChangeEventArgs (ConnectionState.Closed, ConnectionState.Open)); - } - catch (SQLWarning warning) { - OnSqlWarning(warning); - } - catch (SQLException exp) { - OnSqlException(exp); - } - finally { - IsConnecting = false; - } - } - - public override void ChangeDatabase(String database) - { - IsConnecting = true; - try { - ClearReferences(); - java.sql.Connection con = JdbcConnection; - con.setCatalog(database); -// ConnectionStringHelper.UpdateValue(UserParameters,StringManager.GetStringArray("CON_DATABASE"),database); - } - catch (SQLWarning warning) { - OnSqlWarning(warning); - } - catch (SQLException exp) { - throw CreateException(exp); - } - finally { - IsConnecting = false; - } - } - - public override string ServerVersion { - get { - // only if the driver support this methods - try { - if (JdbcConnection == null) - return String.Empty; - - java.sql.DatabaseMetaData metaData = JdbcConnection.getMetaData(); - return metaData.getDatabaseProductVersion(); - } - catch (SQLException exp) { - throw CreateException(exp); - } - } - } - - internal string JdbcProvider { - get { - // only if the driver support this methods - try { - if (JdbcConnection == null) - return String.Empty; - - java.sql.DatabaseMetaData metaData = JdbcConnection.getMetaData(); - return metaData.getDriverName() + " " + metaData.getDriverVersion(); - } - catch (SQLException exp) { - return String.Empty; //suppress - } - } - } - - protected override void Dispose(bool disposing) - { - if (disposing) { - try { - if (JdbcConnection != null && !JdbcConnection.isClosed()) { - JdbcConnection.close(); - } - JdbcConnection = null; - } - catch (java.sql.SQLException exp) { - throw CreateException(exp); - } - } - base.Dispose(disposing); - } - - internal void ValidateBeginTransaction() - { - if (State != ConnectionState.Open) { - throw new InvalidOperationException(String.Format("{0} requires an open and available Connection. The connection's current state is {1}.", new object[] {"BeginTransaction", State})); - } - - if (!JdbcConnection.getAutoCommit()) { - throw new System.InvalidOperationException("Parallel transactions are not supported."); - } - } - - internal ArrayList GetProcedureColumns(String procedureString, AbstractDbCommand command) - { - ArrayList col = new ArrayList(); - try { - ObjectNameResolver[] nameResolvers = SyntaxPatterns; - java.sql.ResultSet res = null; - string catalog = null; - string schema = null; - string spname = null; - - java.sql.DatabaseMetaData metadata = JdbcConnection.getMetaData(); - bool storesUpperCaseIdentifiers = false; - bool storesLowerCaseIdentifiers = false; - try { - storesUpperCaseIdentifiers = metadata.storesUpperCaseIdentifiers(); - storesLowerCaseIdentifiers = metadata.storesLowerCaseIdentifiers(); - } - catch (SQLException e) { - // suppress - } - - for(int i=0; i < nameResolvers.Length; i++) { - ObjectNameResolver nameResolver = nameResolvers[i]; - Match match = nameResolver.Match(procedureString); - - if (match.Success) { - spname = ObjectNameResolver.GetName(match); - schema = ObjectNameResolver.GetSchema(match); - catalog = ObjectNameResolver.GetCatalog(match); - - // make all identifiers uppercase or lowercase according to database metadata - if (storesUpperCaseIdentifiers) { - spname = (spname.Length > 0) ? spname.ToUpper() : null; - schema = (schema.Length > 0) ? schema.ToUpper() : null; - catalog = (catalog.Length > 0) ? catalog.ToUpper() : null; - } - else if (storesLowerCaseIdentifiers) { - spname = (spname.Length > 0) ? spname.ToLower() : null; - schema = (schema.Length > 0) ? schema.ToLower() : null; - catalog = (catalog.Length > 0) ? catalog.ToLower() : null; - } - else { - spname = (spname.Length > 0) ? spname : null; - schema = (schema.Length > 0) ? schema : null; - catalog = (catalog.Length > 0) ? catalog : null; - } - - // catalog from db is always in correct caps - if (catalog == null) { - catalog = JdbcConnection.getCatalog(); - } - - try { - // always get the first procedure that db returns - res = metadata.getProcedures(catalog, schema, spname); - if (res.next()) { - catalog = res.getString(1); - schema = res.getString(2); - spname = res.getString(3); - break; - } - - spname = null; - } - catch { // suppress exception - return null; - } - finally { - if (res != null) { - res.close(); - } - } - } - } - - if (spname == null || spname.Length == 0) { - return null; - } - - try { - // get procedure columns based o procedure metadata - res = metadata.getProcedureColumns(catalog, schema, spname, null); - while (res.next()) { - // since there is still a possibility that some of the parameters to getProcedureColumn were nulls, - // we need to filter the results with strict matching - if ((res.getString(1) != catalog ) || (res.getString(2) != schema) || (res.getString(3) != spname)) { - continue; - } - - AbstractDbParameter parameter = (AbstractDbParameter)command.CreateParameter(); - - parameter.SetParameterName(res); - parameter.SetParameterDbType(res); - parameter.SetSpecialFeatures(res); - - //get parameter direction - short direction = res.getShort("COLUMN_TYPE"); - if(direction == 1) //DatabaseMetaData.procedureColumnIn - parameter.Direction = ParameterDirection.Input; - else if(direction == 2) //DatabaseMetaData.procedureColumnInOut - parameter.Direction = ParameterDirection.InputOutput; - else if(direction == 4) //DatabaseMetaData.procedureColumnOut - parameter.Direction = ParameterDirection.Output; - else if(direction == 5) //DatabaseMetaData.procedureColumnReturn - parameter.Direction = ParameterDirection.ReturnValue; - - //get parameter precision and scale - parameter.SetParameterPrecisionAndScale(res); - - parameter.SetParameterSize(res); - parameter.SetParameterIsNullable(res); - - col.Add(parameter); - } - } - finally { - if (res != null) { - res.close(); - } - } - } - catch(Exception e) { - //supress -#if DEBUG - Console.WriteLine("Exception catched at AbstractDBConnection.GetProcedureColumns() : {0}\n{1}\n{2}",e.GetType().FullName,e.Message,e.StackTrace); -#endif - } - return col; - } - - #endregion // Methods - - #region ICloneable Members - - public virtual object Clone() { - AbstractDBConnection con = (AbstractDBConnection)MemberwiseClone(); - con._internalState = ConnectionState.Closed; - con._internalStateSync = new object(); - con._jdbcConnnection = null; - con._referencedObjects = new ArrayList(); - con._syntaxPatterns = null; - return con; - } - - #endregion - } -} diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBParameter.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBParameter.cs deleted file mode 100644 index 17a4601268b..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDBParameter.cs +++ /dev/null @@ -1,311 +0,0 @@ -// -// System.Data.ProviderBase.AbstractDbParameter -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Data; -using System.Data.Common; - -using java.sql; - -namespace System.Data.ProviderBase -{ - public abstract class AbstractDbParameter : DbParameter, IDbDataParameter, ICloneable - { - #region Fields - - byte _precision; - byte _scale; - protected DataRowVersion _sourceVersion; - private int _jdbcType; - bool _isDbTypeSet; - bool _isJdbcTypeSet; - object _convertedValue; - - string _parameterName; - ParameterDirection _direction = ParameterDirection.Input; - int _size; - object _value; - bool _isNullable; - int _offset; - string _sourceColumn; - DbParameterCollection _parent = null; - - #endregion // Fields - - #region Constructors - - [MonoTODO] - protected AbstractDbParameter () - { - } - - #endregion // Constructors - - #region Properties - - public override ParameterDirection Direction { - get { return _direction; } - set { - if (_direction != value) { - switch (value) { - case ParameterDirection.Input: - case ParameterDirection.Output: - case ParameterDirection.InputOutput: - case ParameterDirection.ReturnValue: - { - _direction = value; - return; - } - } - throw ExceptionHelper.InvalidParameterDirection (value); - } - } - } - - public override bool IsNullable { - get { return _isNullable; } - set { _isNullable = value; } - } - - - public virtual int Offset { - get { return _offset; } - set { _offset = value; } - } - - public override string ParameterName { - get { - if (_parameterName == null) - return String.Empty; - - return _parameterName; - } - set { - if (_parameterName != value) { - _parameterName = value; - } - } - } - - public override int Size { - get { return _size; } - - set { - if (_size != value) { - if (value < -1) - throw ExceptionHelper.InvalidSizeValue (value); - - _size = value; - } - } - } - - - public override string SourceColumn { - get { - if (_sourceColumn == null) - return String.Empty; - - return _sourceColumn; - } - - set { _sourceColumn = value; } - } - - internal DbParameterCollection Parent - { - get { return _parent; } - set { _parent = value; } - } - - public byte Precision - { - get { return _precision; } - set { _precision = value; } - } - - public byte Scale - { - get { return _scale; } - set { _scale = value; } - } - - public override DataRowVersion SourceVersion - { - get { return _sourceVersion; } - set { _sourceVersion = value; } - } - - protected internal int JdbcType - { - get { - if (!IsJdbcTypeSet) { - return JdbcTypeFromProviderType(); - } - return _jdbcType; - } - set { - _jdbcType = value; - IsJdbcTypeSet = true; - } - } - - protected internal bool IsJdbcTypeSet - { - get { - return _isJdbcTypeSet; - } - - set { - _isJdbcTypeSet = value; - } - } - - protected internal bool IsDbTypeSet - { - get { return _isDbTypeSet; } - set { _isDbTypeSet = value; } - } - - protected internal virtual bool IsSpecial { - get { - return false; - } - } - - private bool IsFixedLength - { - get { - return ((DbType != DbType.AnsiString) && (DbType != DbType.Binary) && - (DbType != DbType.String) && (DbType != DbType.VarNumeric)); - } - } - - protected internal virtual string Placeholder { - get { - return "?"; - } - } - - internal object ConvertedValue - { - get { - if (_convertedValue == null) { - object value = Value; - _convertedValue = ((value != null) && (value != DBNull.Value)) ? ConvertValue(value) : value; - } - return _convertedValue; - } - } - - public override object Value { - get { return _value; } - set { - _convertedValue = null; - _value = value; - } - } - - //DbParameter overrides - - public override bool SourceColumnNullMapping { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - - #endregion // Properties - - #region Methods - - public override String ToString() - { - return ParameterName; - } - - protected internal abstract void SetParameterName(ResultSet res); - - protected internal abstract void SetParameterDbType(ResultSet res); - - protected internal abstract void SetSpecialFeatures(ResultSet res); - - public virtual object Clone() - { - AbstractDbParameter other = (AbstractDbParameter) MemberwiseClone (); - other._parent = null; - return other; - } - - protected internal abstract int JdbcTypeFromProviderType(); - - protected internal abstract object ConvertValue(object value); - - internal void SetParameterPrecisionAndScale(ResultSet res) - { - int jdbcType = res.getInt("DATA_TYPE"); - if(jdbcType == java.sql.Types.DECIMAL || jdbcType == java.sql.Types.NUMERIC) { - Precision = (byte)res.getInt("PRECISION"); - Scale = (byte)res.getInt("SCALE"); - } - } - - internal void SetParameterSize(ResultSet res) - { - Size = res.getInt("LENGTH"); - } - - internal void SetParameterIsNullable(ResultSet res) - { - IsNullable = (res.getInt("NULLABLE") == 1); - } - - internal void Validate() - { - if (!IsFixedLength && ((Direction & ParameterDirection.Output) != 0) && (Size == 0)) { - throw ExceptionHelper.ParameterSizeNotInitialized(Offset,ParameterName,DbType.ToString(),Size); - } - } - - //DbParameter overrides - - public override void ResetDbType() { - throw new NotImplementedException(); - } - - #endregion // Methods - } -} - diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDataReader.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDataReader.cs deleted file mode 100644 index 6b6978280a8..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDataReader.cs +++ /dev/null @@ -1,1335 +0,0 @@ -// -// System.Data.Common.AbstractDataReader -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -using System; -using System.Data; -using System.Collections; -using System.Data.Common; - -using java.io; -using java.sql; - -namespace System.Data.ProviderBase -{ - public abstract class AbstractDataReader : DbDataReader, ISafeDataRecord { - - #region Fields - - private ResultSetMetaData _resultsMetaData; - protected AbstractDbCommand _command; - private DataTable _schemaTable; - private ReaderState _readerState = ReaderState.Uninitialized; - - private IReaderCacheContainer[] _readerCache; - private int _currentCacheFilledPosition; - private Stack _resultSetStack = new Stack(); - private bool _isClosed = false; - - [Flags] - private enum ReaderState { Uninitialized = 0, Empty = 1, HasRows = 2, FirstRed = 4, Eof = 8, Fetching = 16 }; - - protected internal enum SCHEMA_TABLE { ColumnName, - ColumnOrdinal, - ColumnSize, - NumericPrecision, - NumericScale, - IsUnique, - IsKey, - BaseServerName, - BaseCatalogName, - BaseColumnName, - BaseSchemaName, - BaseTableName, - DataType, - AllowDBNull, - ProviderType, - IsAliased, - IsExpression, - IsIdentity, - IsAutoIncrement, - IsRowVersion, - IsHidden, - IsLong, - IsReadOnly}; - - #endregion // Fields - - #region Constructors - - protected AbstractDataReader(AbstractDbCommand command) { - _command = command; - if (_command.Connection != null) { - ((AbstractDBConnection)_command.Connection).AddReference(this); - } - } - - #endregion // Constructors - - #region Properties - - public override int Depth { - get { return 0; } - } - - public override bool HasRows { - get { - if (IsClosed) { - throw new InvalidOperationException("Invalid attempt to HasRows when reader is closed."); - } - - try { - if(null == Results) - return false; - } - catch(SystemException) { - //suppress - return false; - } - - return (_readerState & ReaderState.HasRows) != 0; - } - } - - public override int RecordsAffected - { - // MSDN : The RecordsAffected property is not set - // until all rows are read and you close the reader. - get { - return _command.RecordsAffected; - } - } - - public override int FieldCount - { - get { - if (ResultsMetaData == null) - return 0; - - try { - return ResultsMetaData.getColumnCount(); - } - catch (SQLException exp) { - throw CreateException(exp); - } - - } - } - - protected internal CommandBehavior Behavior - { - get { - return _command.Behavior; - } - } - - public override Object this[String columnName] - { - get { - try { - int columnIndex = Results.findColumn(columnName) - 1; - return this[columnIndex]; - } - catch (SQLException exp) { - throw new IndexOutOfRangeException(exp.Message, exp); - } - } - } - - public override Object this[int columnIndex] - { - get { return GetValue(columnIndex); } - } - - protected ResultSet Results - { - get { - if (_readerState == ReaderState.Uninitialized) { - - if (_resultSetStack.Count == 0) { - ResultSet resultSet = _command.CurrentResultSet; - if (resultSet == null) - return null; - - _resultSetStack.Push(resultSet); - } - - _readerState = ReaderState.Fetching; - for (;;) { - try { - Configuration.BooleanSetting prefetchSchema = Configuration.Switches.PrefetchSchema; - - if (prefetchSchema == Configuration.BooleanSetting.NotSet) { - AbstractDBConnection conn = (AbstractDBConnection)((ICloneable)_command.Connection); - string driverName = conn.JdbcConnection.getMetaData().getDriverName(); - if (driverName.IndexOf("DB2", StringComparison.Ordinal) >= 0) - prefetchSchema = Configuration.BooleanSetting.True; - } - - if (prefetchSchema == Configuration.BooleanSetting.True) - GetSchemaTable(); - - ResultSet resultSet = (ResultSet)_resultSetStack.Peek(); - if (resultSet.next()) { - _readerState = (ReaderState.HasRows | ReaderState.FirstRed); - ResultSetMetaData rsMetaData = ResultsMetaData; - DbConvert.JavaSqlTypes javaSqlType = (DbConvert.JavaSqlTypes)rsMetaData.getColumnType(1); - if (javaSqlType == DbConvert.JavaSqlTypes.OTHER) { - object value = GetValue(0); - if (value != null && value is ResultSet) { - _resultsMetaData = null; - _readerCache = null; - SchemaTable = null; - _readerState = ReaderState.Fetching; - _resultSetStack.Push(value); - continue; - } - } - } - else - _readerState = ReaderState.Empty; - - break; - } - catch(SQLException e) { - throw CreateException(e); - } - } - } - - return (_resultSetStack.Count > 0) ? (ResultSet)_resultSetStack.Peek() : null; - } - } - - protected ResultSetMetaData ResultsMetaData - { - get { - ResultSet results = Results; - if (results == null) { - return null; - } - if(_resultsMetaData == null) { - _resultsMetaData = results.getMetaData(); - } - return _resultsMetaData; - } - } - - protected DataTable SchemaTable - { - get { - if (_schemaTable == null) { - _schemaTable = ConstructSchemaTable(); - } - return _schemaTable; - } - - set {_schemaTable = value; } - } - - internal protected IReaderCacheContainer[] ReaderCache - { - get { - if (_readerCache == null) { - _readerCache = CreateReaderCache(); - _currentCacheFilledPosition = -1; - } - return _readerCache; - } - } - - public override bool IsClosed { - get { return _isClosed; } - } - - #endregion // Properties - - #region Methods - - protected abstract int GetProviderType(int jdbcType); - - protected abstract SystemException CreateException(string message, SQLException e); - - protected abstract SystemException CreateException(IOException e); - - protected SystemException CreateException(SQLException e) - { - return CreateException(e.Message,e); - } - - private bool CloseCurrentResultSet() { - if (_resultSetStack.Count > 0) { - try{ - _resultsMetaData = null; - _readerCache = null; - _readerState = ReaderState.Uninitialized; - ResultSet rs = (ResultSet)_resultSetStack.Pop(); - rs.close(); - return true; - } - catch (SQLException exp) { - throw CreateException(exp); - } - } - - return false; - } - - // FIXME : add Close(bool readAllRecords) and pass this bool to skip looping over NextResult(), override AbstractDbCommand.ExecuteScalar - public override void Close() - { - if (IsClosed) - return; - - try { - CloseCurrentResultSet(); - _command.OnReaderClosed(this); - } - finally { - CloseInternal(); - } - } - - internal void CloseInternal() - { - _resultsMetaData = null; - _readerCache = null; - _isClosed = true; - } - - public override IEnumerator GetEnumerator () - { - bool closeReader = (Behavior & CommandBehavior.CloseConnection) != 0; - return new DbEnumerator (this , closeReader); - } - - public override bool NextResult() - { - CloseCurrentResultSet(); - - if ((_command.Behavior & CommandBehavior.SingleResult) != 0) { - while (CloseCurrentResultSet()); - while (_command.NextResultSet()); - return false; - } - - try { - while (_resultSetStack.Count > 0) { - ResultSet rs = (ResultSet)_resultSetStack.Peek(); - - if(!rs.next()) { - CloseCurrentResultSet(); - continue; - } - - // must be a ResultSet - object childRs = rs.getObject(1); - if (childRs != null) { - SchemaTable = null; - _resultSetStack.Push(childRs); - return true; - } - } - } - catch (SQLException exp) { - throw CreateException(exp); - } - - if (_command.NextResultSet()) { - SchemaTable = null; - return true; - } - return false; - } - - public override bool Read() - { - if(null == Results || - (_readerState & (ReaderState.HasRows | ReaderState.Eof)) != ReaderState.HasRows) - return false; - - bool firstRead = false; - - try { - if ((_readerState & ReaderState.FirstRed) != 0) { - firstRead = true; - _readerState &= ~ReaderState.FirstRed; - return true; - } - else { - bool next = Results.next(); - - if (!next) - _readerState |= ReaderState.Eof; - - return next; - } - } - catch (SQLException exp) { - // suppress exception as .Net does - return false; - } - finally { - // in case of first read we could sampled the first value - // to see whether there is a resultset, so _currentCacheFilledPosition - // might be already inited - if (!firstRead) - _currentCacheFilledPosition = -1; - } - } - - public override bool GetBoolean(int columnIndex) - { - FillReaderCache(columnIndex); - return ((BooleanReaderCacheContainer)ReaderCache[columnIndex]).GetBoolean(); - } - - public bool GetBooleanSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is BooleanReaderCacheContainer) { - return GetBoolean(columnIndex); - } - else { - return Convert.ToBoolean(GetValue(columnIndex)); - } - } - - public override byte GetByte(int columnIndex) - { - FillReaderCache(columnIndex); - return ((ByteReaderCacheContainer)ReaderCache[columnIndex]).GetByte(); - } - - public byte GetByteSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is ByteReaderCacheContainer) { - return GetByte(columnIndex); - } - else { - return Convert.ToByte(GetValue(columnIndex)); - } - } - - public override long GetBytes( - int columnIndex, - long dataIndex, - byte[] buffer, - int bufferIndex, - int length) - { - FillReaderCache(columnIndex); - return ((BytesReaderCacheContainer)ReaderCache[columnIndex]) - .GetBytes(dataIndex, buffer, bufferIndex, length); - } - - public virtual byte[] GetBytes(int columnIndex) - { - FillReaderCache(columnIndex); - return ((BytesReaderCacheContainer)ReaderCache[columnIndex]).GetBytes(); - } - - public override char GetChar(int columnIndex) - { - FillReaderCache(columnIndex); - string s = ((StringReaderCacheContainer)ReaderCache[columnIndex]).GetString(); - if(s == null) { - return '\0'; - } - return s[0]; - } - - public char GetCharSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is StringReaderCacheContainer) { - return GetChar(columnIndex); - } - else { - return Convert.ToChar(GetValue(columnIndex)); - } - } - - public override long GetChars( - int columnIndex, - long dataIndex, - char[] buffer, - int bufferIndex, - int length) - { - FillReaderCache(columnIndex); - return ((CharsReaderCacheContainer)ReaderCache[columnIndex]) - .GetChars(dataIndex, buffer, bufferIndex, length); - } - - public override string GetDataTypeName(int columnIndex) - { - try { - if (ResultsMetaData == null) { - return String.Empty; - } - return ResultsMetaData.getColumnTypeName(columnIndex + 1); - } - catch (SQLException exp) { - throw CreateException(exp); - } - } - - public override DateTime GetDateTime(int columnIndex) - { - return GetDateTimeUnsafe(columnIndex); - } - - DateTime GetDateTimeUnsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((DateTimeReaderCacheContainer)ReaderCache[columnIndex]).GetDateTime(); - } - - public DateTime GetDateTimeSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is DateTimeReaderCacheContainer) { - return GetDateTimeUnsafe(columnIndex); - } - else { - return Convert.ToDateTime(GetValue(columnIndex)); - } - } - - public virtual TimeSpan GetTimeSpan(int columnIndex) - { - FillReaderCache(columnIndex); - return ((TimeSpanReaderCacheContainer)ReaderCache[columnIndex]).GetTimeSpan(); - } - - public override Guid GetGuid(int columnIndex) - { - FillReaderCache(columnIndex); - return ((GuidReaderCacheContainer)ReaderCache[columnIndex]).GetGuid(); - } - - public override decimal GetDecimal(int columnIndex) - { - return GetDecimalUnsafe(columnIndex); - } - - decimal GetDecimalUnsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((DecimalReaderCacheContainer)ReaderCache[columnIndex]).GetDecimal(); - } - - public decimal GetDecimalSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is DecimalReaderCacheContainer) { - return GetDecimalUnsafe(columnIndex); - } - else { - return Convert.ToDecimal(GetValue(columnIndex)); - } - } - - public override double GetDouble(int columnIndex) - { - return GetDoubleUnsafe(columnIndex); - } - - double GetDoubleUnsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((DoubleReaderCacheContainer)ReaderCache[columnIndex]).GetDouble(); - } - - public double GetDoubleSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is DoubleReaderCacheContainer) { - return GetDoubleUnsafe(columnIndex); - } - else { - return Convert.ToDouble(GetValue(columnIndex)); - } - } - - public override float GetFloat(int columnIndex) - { - return GetFloatUnsafe(columnIndex); - } - - float GetFloatUnsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((FloatReaderCacheContainer)ReaderCache[columnIndex]).GetFloat(); - } - - public float GetFloatSafe(int columnIndex) - { - if (ReaderCache[columnIndex] is FloatReaderCacheContainer) { - return GetFloatUnsafe(columnIndex); - } - else { - return Convert.ToSingle(GetValue(columnIndex)); - } - } - - public override short GetInt16(int columnIndex) - { - return GetInt16Unsafe(columnIndex); - } - - short GetInt16Unsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((Int16ReaderCacheContainer)ReaderCache[columnIndex]).GetInt16(); - } - - public short GetInt16Safe(int columnIndex) - { - if (ReaderCache[columnIndex] is Int16ReaderCacheContainer) { - return GetInt16Unsafe(columnIndex); - } - else { - return Convert.ToInt16(GetValue(columnIndex)); - } - } - - public override int GetInt32(int columnIndex) - { - return GetInt32Unsafe(columnIndex); - } - - int GetInt32Unsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((Int32ReaderCacheContainer)ReaderCache[columnIndex]).GetInt32(); - } - - public int GetInt32Safe(int columnIndex) - { - if (ReaderCache[columnIndex] is Int32ReaderCacheContainer) { - return GetInt32Unsafe(columnIndex); - } - else { - return Convert.ToInt32(GetValue(columnIndex)); - } - } - - public override long GetInt64(int columnIndex) - { - return GetInt64Unsafe(columnIndex); - } - - long GetInt64Unsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((Int64ReaderCacheContainer)ReaderCache[columnIndex]).GetInt64(); - } - - public long GetInt64Safe(int columnIndex) - { - if (ReaderCache[columnIndex] is Int64ReaderCacheContainer) { - return GetInt64Unsafe(columnIndex); - } - else { - return Convert.ToInt64(GetValue(columnIndex)); - } - } - - public override string GetName(int columnIndex) - { - try { - if (ResultsMetaData == null) { - return String.Empty; - } - return ResultsMetaData.getColumnName(columnIndex + 1); - } - catch (SQLException exp) { - throw new IndexOutOfRangeException(exp.Message, exp); - } - } - - public override int GetOrdinal(String columnName) - { - try { - int retVal = Results.findColumn(columnName); - if(retVal != -1) { - retVal -= 1; - } - return retVal; - } - catch (SQLException exp) { - throw new IndexOutOfRangeException(exp.Message, exp); - } - } - - public override string GetString(int columnIndex) - { - return GetStringUnsafe(columnIndex); - } - - string GetStringUnsafe(int columnIndex) - { - FillReaderCache(columnIndex); - return ((StringReaderCacheContainer)ReaderCache[columnIndex]).GetString(); - } - - public string GetStringSafe(int columnIndex) { - if (ReaderCache[columnIndex] is StringReaderCacheContainer) { - return GetStringUnsafe(columnIndex); - } - else { - return Convert.ToString(GetValue(columnIndex)); - } - } - - public override object GetValue(int columnIndex) - { - FillReaderCache(columnIndex); - if (ReaderCache[columnIndex].IsNull()) { - return DBNull.Value; - } - return ReaderCache[columnIndex].GetValue(); - } - - public override int GetValues(Object[] values) - { - int columnCount = FieldCount; - int i = 0; - for (; i < values.Length && i < columnCount; i++) { - values[i] = GetValue(i); - } - return i; - } - - private void FillReaderCache(int columnIndex) - { - try { - IReaderCacheContainer[] readerCache = ReaderCache; - if ((Behavior & CommandBehavior.SequentialAccess) == 0) { - while (_currentCacheFilledPosition < columnIndex) { - _currentCacheFilledPosition++; - readerCache[_currentCacheFilledPosition].Fetch(Results,_currentCacheFilledPosition, false); - } - } - else { - readerCache[columnIndex].Fetch(Results,columnIndex, true); - } - } - catch(SQLException e) { - _currentCacheFilledPosition = -1; - throw CreateException(e); - } - catch (IOException e) { - _currentCacheFilledPosition = -1; - throw CreateException(e); - } - } - - protected virtual IReaderCacheContainer CreateReaderCacheContainer(int jdbcType, int columnIndex) { - switch ((DbConvert.JavaSqlTypes)jdbcType) { - case DbConvert.JavaSqlTypes.ARRAY : - return new ArrayReaderCacheContainer(); - case DbConvert.JavaSqlTypes.BIGINT : - return new Int64ReaderCacheContainer(); - case DbConvert.JavaSqlTypes.BINARY : - case DbConvert.JavaSqlTypes.VARBINARY : - case DbConvert.JavaSqlTypes.LONGVARBINARY : - return new BytesReaderCacheContainer(); - case DbConvert.JavaSqlTypes.BIT : - return new BooleanReaderCacheContainer(); - case DbConvert.JavaSqlTypes.BLOB : - return new BlobReaderCacheContainer(); - case DbConvert.JavaSqlTypes.VARCHAR: - case DbConvert.JavaSqlTypes.CHAR : - if (String.CompareOrdinal("uniqueidentifier", ResultsMetaData.getColumnTypeName(columnIndex)) == 0) { - return new GuidReaderCacheContainer(); - } - else { - return new StringReaderCacheContainer(); - } - case DbConvert.JavaSqlTypes.CLOB : - return new ClobReaderCacheContainer(); - case DbConvert.JavaSqlTypes.TIME : - return new TimeSpanReaderCacheContainer(); - case DbConvert.JavaSqlTypes.DATE : - AbstractDBConnection conn = (AbstractDBConnection)((ICloneable)_command.Connection); - string driverName = conn.JdbcConnection.getMetaData().getDriverName(); - - if (driverName.StartsWith("PostgreSQL")) { - return new DateTimeReaderCacheContainer(); - } - else - goto case DbConvert.JavaSqlTypes.TIMESTAMP; - case DbConvert.JavaSqlTypes.TIMESTAMP : - return new TimestampReaderCacheContainer(); - case DbConvert.JavaSqlTypes.DECIMAL : - case DbConvert.JavaSqlTypes.NUMERIC : - // jdbc driver for oracle identitfies both FLOAT and NUMBEr columns as - // java.sql.Types.NUMERIC (2), columnTypeName NUMBER, columnClassName java.math.BigDecimal - // therefore we relay on scale - int scale = ResultsMetaData.getScale(columnIndex); - if (scale == -127) { - // Oracle db type FLOAT - return new DoubleReaderCacheContainer(); - } - else { - return new DecimalReaderCacheContainer(); - } - case DbConvert.JavaSqlTypes.DOUBLE : - case DbConvert.JavaSqlTypes.FLOAT : - return new DoubleReaderCacheContainer(); - case DbConvert.JavaSqlTypes.INTEGER : - return new Int32ReaderCacheContainer(); - case DbConvert.JavaSqlTypes.LONGVARCHAR : - return new StringReaderCacheContainer(); - case DbConvert.JavaSqlTypes.NULL : - return new NullReaderCacheContainer(); - case DbConvert.JavaSqlTypes.REAL : - return new FloatReaderCacheContainer(); - case DbConvert.JavaSqlTypes.REF : - return new RefReaderCacheContainer(); - case DbConvert.JavaSqlTypes.SMALLINT : - return new Int16ReaderCacheContainer(); - case DbConvert.JavaSqlTypes.TINYINT : - return new ByteReaderCacheContainer(); - case DbConvert.JavaSqlTypes.DISTINCT : - case DbConvert.JavaSqlTypes.JAVA_OBJECT : - case DbConvert.JavaSqlTypes.OTHER : - case DbConvert.JavaSqlTypes.STRUCT : - default : - return new ObjectReaderCacheContainer(); - } - } - - private IReaderCacheContainer[] CreateReaderCache() - { - try { - IReaderCacheContainer[] readerCache = new IReaderCacheContainer[FieldCount]; - for(int i=1; i <= readerCache.Length; i++) - readerCache[i-1] = CreateReaderCacheContainer(ResultsMetaData.getColumnType(i), i); - - return readerCache; - } - catch(SQLException e) { - throw CreateException(e); - } - } - - protected bool IsNumeric(int columnIndex) - { - return ReaderCache[columnIndex].IsNumeric(); - } - - public override bool IsDBNull(int columnIndex) - { - FillReaderCache(columnIndex); - return ReaderCache[columnIndex].IsNull(); - } - - public override Type GetFieldType(int i) - { - try { - int javaSqlType = ResultsMetaData.getColumnType(i + 1); - return DbConvert.JavaSqlTypeToClrType(javaSqlType); - } - catch (SQLException exp) { - throw new IndexOutOfRangeException(exp.Message, exp); - } - } - - public IDataReader GetData(int i) - { - throw new NotSupportedException(); - } - - protected virtual void SetSchemaType(DataRow schemaRow, ResultSetMetaData metaData, int columnIndex) { - DbConvert.JavaSqlTypes columnType = (DbConvert.JavaSqlTypes)metaData.getColumnType(columnIndex); - - switch (columnType) { - case DbConvert.JavaSqlTypes.ARRAY: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = typeof (java.sql.Array); - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.BIGINT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfInt64; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.BINARY: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfByteArray; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.BIT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfBoolean; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.BLOB: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfByteArray; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.VARCHAR: - case DbConvert.JavaSqlTypes.CHAR: { - // FIXME : specific for Microsoft SQl Server driver - if (String.CompareOrdinal(metaData.getColumnTypeName(columnIndex), "uniqueidentifier") == 0) { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = DbType.Guid; - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfGuid; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - } - else - if (String.CompareOrdinal(metaData.getColumnTypeName(columnIndex), "sql_variant") == 0) { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = DbType.Object; - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfObject; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - } - else { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfString; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - } - break; - } - case DbConvert.JavaSqlTypes.CLOB: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfString; // instead og .java.sql.Clob - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.DATE: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDateTime; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - // else if(DbConvert.JavaSqlTypes.DISTINCT) - // { - // schemaRow ["ProviderType = (int)GetProviderType((int)columnType); - // schemaRow ["DataType = typeof (?); - // schemaRow ["IsLong = false; - // } - case DbConvert.JavaSqlTypes.DOUBLE: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDouble; // was typeof(float) - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.FLOAT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDouble; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.REAL: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfFloat; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.INTEGER: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfInt32; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.JAVA_OBJECT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfObject; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.LONGVARBINARY: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfByteArray; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.LONGVARCHAR: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfString; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.DECIMAL: - case DbConvert.JavaSqlTypes.NUMERIC: { - int scale = ResultsMetaData.getScale(columnIndex); - if (scale == -127) { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDouble; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - } - else { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDecimal; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - } - break; - } - case DbConvert.JavaSqlTypes.REF: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = typeof (java.sql.Ref); - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - case DbConvert.JavaSqlTypes.SMALLINT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfInt16; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.STRUCT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = typeof (java.sql.Struct); - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.TIME: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfTimespan; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.TIMESTAMP: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfDateTime; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.TINYINT: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfByte; - schemaRow [(int)SCHEMA_TABLE.IsLong] = false; - break; - } - case DbConvert.JavaSqlTypes.VARBINARY: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = GetProviderType((int)columnType); - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfByteArray; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - default: { - schemaRow [(int)SCHEMA_TABLE.ProviderType] = DbType.Object; - schemaRow [(int)SCHEMA_TABLE.DataType] = DbTypes.TypeOfObject; - schemaRow [(int)SCHEMA_TABLE.IsLong] = true; - break; - } - } - } - - public override DataTable GetSchemaTable() - { - if (SchemaTable.Rows != null && SchemaTable.Rows.Count > 0) { - return SchemaTable; - } - - ResultSetMetaData metaData; - if (Behavior == CommandBehavior.SchemaOnly) { - try { - metaData = ((PreparedStatement)_command.Statement).getMetaData(); - } - catch(SQLException e) { - throw CreateException("CommandBehaviour.SchemaOnly is not supported by the JDBC driver.",e); - } - } - else { - metaData = ResultsMetaData; - } - - if (metaData == null) { - return SchemaTable; - } - - DatabaseMetaData dbMetaData = null; - AbstractDBConnection clonedConnection = null; - if ((_command.Behavior & CommandBehavior.KeyInfo) != 0) { - clonedConnection = (AbstractDBConnection)((ICloneable)_command.Connection).Clone(); - - try { - clonedConnection.Open(); - dbMetaData = clonedConnection.JdbcConnection.getMetaData(); - } - catch { - //suppress - if (clonedConnection != null) { - clonedConnection.Close(); - } - } - } - - try { - int tmp; - for(int i = 1; i <= metaData.getColumnCount(); i++) { - DataRow row = SchemaTable.NewRow (); - string columnName = metaData.getColumnLabel(i); - string baseColumnName = metaData.getColumnName(i); - - row [(int)SCHEMA_TABLE.ColumnName] = columnName; // maybe we should use metaData.getColumnLabel(i); - row [(int)SCHEMA_TABLE.ColumnSize] = metaData.getColumnDisplaySize(i); - row [(int)SCHEMA_TABLE.ColumnOrdinal] = i - 1; - try { - // FIXME : workaround for Oracle JDBC driver bug - // getPrecision on BLOB, CLOB, NCLOB throws NumberFormatException - tmp = metaData.getPrecision(i); - } - catch(java.lang.NumberFormatException e) { - // supress exception - tmp = 255; - } - row [(int)SCHEMA_TABLE.NumericPrecision] = Convert.ToInt16(tmp > 255 ? 255 : tmp); - tmp = metaData.getScale(i); - row [(int)SCHEMA_TABLE.NumericScale] = Convert.ToInt16(tmp > 255 ? 255 : tmp); - - row [(int)SCHEMA_TABLE.BaseServerName] = DBNull.Value; - - string catalog = null; - try { - catalog = metaData.getCatalogName(i); - } - catch (Exception e) { - // supress exception - } - if (catalog != null && catalog.Length == 0) - catalog = ((AbstractDBConnection)_command.Connection).JdbcConnection.getCatalog(); - row [(int)SCHEMA_TABLE.BaseCatalogName] = catalog; - row [(int)SCHEMA_TABLE.BaseColumnName] = baseColumnName; - - string schemaName; - string tableName; - - try { - tableName = metaData.getTableName(i); - } - catch { - tableName = null; - } - - try { - schemaName = metaData.getSchemaName(i); - } - catch { - schemaName = null; - } - - if (tableName != null && tableName.Length == 0) - tableName = null; - if (schemaName != null && schemaName.Length == 0) - schemaName = null; - - row [(int)SCHEMA_TABLE.BaseSchemaName] = schemaName; - row [(int)SCHEMA_TABLE.BaseTableName] = tableName; - - - row [(int)SCHEMA_TABLE.AllowDBNull] = Convert.ToBoolean(metaData.isNullable(i)); - - InitKeyInfo(row, dbMetaData, catalog, schemaName, tableName); - - row [(int)SCHEMA_TABLE.IsAliased] = columnName != baseColumnName; - row [(int)SCHEMA_TABLE.IsExpression] = false; - - row [(int)SCHEMA_TABLE.IsAutoIncrement] = metaData.isAutoIncrement(i); - - row [(int)SCHEMA_TABLE.IsHidden] = false; - row [(int)SCHEMA_TABLE.IsReadOnly] = metaData.isReadOnly(i); - - SetSchemaType(row, metaData, i); - - SchemaTable.Rows.Add (row); - } - } - catch (SQLException e) { - throw CreateException(e); - } - finally { - if (clonedConnection != null) { - clonedConnection.Close(); - } - } - return SchemaTable; - } - - private void InitKeyInfo(DataRow row, DatabaseMetaData dbMetaData, String catalog, String schema, String table) { - string column = (string)row [(int)SCHEMA_TABLE.BaseColumnName]; - - row [(int)SCHEMA_TABLE.IsUnique] = false; - row [(int)SCHEMA_TABLE.IsKey] = false; - row [(int)SCHEMA_TABLE.IsIdentity] = false; - row [(int)SCHEMA_TABLE.IsRowVersion] = false; - - if ((_command.Behavior & CommandBehavior.KeyInfo) == 0) - return; - - if(table == null || column == null || dbMetaData == null) - return; - - ResultSet versionCol = dbMetaData.getVersionColumns(catalog, schema, table); - try { - while(versionCol.next()) { - if(versionCol.getString("COLUMN_NAME") == column) { - if (DatabaseMetaData__Finals.versionColumnPseudo == versionCol.getShort("PSEUDO_COLUMN")) { - row [(int)SCHEMA_TABLE.IsIdentity] = true; - row [(int)SCHEMA_TABLE.IsRowVersion] = true; - } - } - } - } - finally { - versionCol.close(); - } - - ResultSet primaryKeys = dbMetaData.getPrimaryKeys(catalog,schema,table); - bool primaryKeyExists = false; - int columnCount = 0; - try { - while(primaryKeys.next()) { - columnCount++; - if(primaryKeys.getString("COLUMN_NAME") == column) { - row [(int)SCHEMA_TABLE.IsKey] = true; - primaryKeyExists = true; - } - } - // column constitutes a key by itself, so it should be marked as unique - if ((columnCount == 1) && (((bool)row [(int)SCHEMA_TABLE.IsKey]) == true)) { - row [(int)SCHEMA_TABLE.IsUnique] = true; - } - } - finally { - primaryKeys.close(); - } - - ResultSet indexInfoRes = dbMetaData.getIndexInfo(catalog,schema,table,true,false); - string currentIndexName = null; - columnCount = 0; - bool belongsToCurrentIndex = false; - bool atFirstIndex = true; - bool uniqueKeyExists = false; - try { - while(indexInfoRes.next()) { - if (indexInfoRes.getShort("TYPE") == DatabaseMetaData__Finals.tableIndexStatistic) { - // index of type tableIndexStatistic identifies table statistics - ignore it - continue; - } - - uniqueKeyExists = true; - string iname = indexInfoRes.getString("INDEX_NAME"); - if (currentIndexName == iname) { - // we're within the rows of the same index - columnCount++; - } - else { - // we jump to row of new index - if (belongsToCurrentIndex && columnCount == 1) { - // there is a constraint of type UNIQUE that applies only to this column - row [(int)SCHEMA_TABLE.IsUnique] = true; - } - - if (currentIndexName != null) { - atFirstIndex = false; - } - currentIndexName = iname; - columnCount = 1; - belongsToCurrentIndex = false; - } - - if(indexInfoRes.getString("COLUMN_NAME") == column) { - // FIXME : this will cause "spare" columns marked as IsKey. Needs future investigation. - // only the first index we met should be marked as a key - //if (atFirstIndex) { - row [(int)SCHEMA_TABLE.IsKey] = true; - //} - belongsToCurrentIndex = true; - } - } - // the column appears in the last index, which is single-column - if (belongsToCurrentIndex && columnCount == 1) { - // there is a constraint of type UNIQUE that applies only to this column - row [(int)SCHEMA_TABLE.IsUnique] = true; - } - } - finally { - indexInfoRes.close(); - } - - if(!primaryKeyExists && !uniqueKeyExists) { - ResultSet bestRowId = dbMetaData.getBestRowIdentifier(catalog, schema, table, DatabaseMetaData__Finals.bestRowTemporary, false); - try { - while(bestRowId.next()) { - if(bestRowId.getString("COLUMN_NAME") == column) - row [(int)SCHEMA_TABLE.IsKey] = true; - } - } - finally { - bestRowId.close(); - } - } - } - - protected static DataTable ConstructSchemaTable () - { - Type booleanType = DbTypes.TypeOfBoolean; - Type stringType = DbTypes.TypeOfString; - Type intType = DbTypes.TypeOfInt32; - Type typeType = DbTypes.TypeOfType; - Type shortType = DbTypes.TypeOfInt16; - - DataTable schemaTable = new DataTable ("SchemaTable"); - schemaTable.Columns.Add ("ColumnName", stringType); - schemaTable.Columns.Add ("ColumnOrdinal", intType); - schemaTable.Columns.Add ("ColumnSize", intType); - schemaTable.Columns.Add ("NumericPrecision", shortType); - schemaTable.Columns.Add ("NumericScale", shortType); - schemaTable.Columns.Add ("IsUnique", booleanType); - schemaTable.Columns.Add ("IsKey", booleanType); - schemaTable.Columns.Add ("BaseServerName", stringType); - schemaTable.Columns.Add ("BaseCatalogName", stringType); - schemaTable.Columns.Add ("BaseColumnName", stringType); - schemaTable.Columns.Add ("BaseSchemaName", stringType); - schemaTable.Columns.Add ("BaseTableName", stringType); - schemaTable.Columns.Add ("DataType", typeType); - schemaTable.Columns.Add ("AllowDBNull", booleanType); - schemaTable.Columns.Add ("ProviderType", intType); - schemaTable.Columns.Add ("IsAliased", booleanType); - schemaTable.Columns.Add ("IsExpression", booleanType); - schemaTable.Columns.Add ("IsIdentity", booleanType); - schemaTable.Columns.Add ("IsAutoIncrement", booleanType); - schemaTable.Columns.Add ("IsRowVersion", booleanType); - schemaTable.Columns.Add ("IsHidden", booleanType); - schemaTable.Columns.Add ("IsLong", booleanType); - schemaTable.Columns.Add ("IsReadOnly", booleanType); - return schemaTable; - } - - #endregion // Methods - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbError.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbError.cs deleted file mode 100644 index aeeb3521a61..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbError.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// System.Data.ProviderBase.AbstractDbError -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.ProviderBase { - using java.sql; - using System.Data.Common; - - [Serializable] - public abstract class AbstractDbError { - protected SQLException _e; - string _jdbcProvider; - - protected AbstractDbError(SQLException e, AbstractDBConnection connection) { - _e = e; - if (connection != null) - _jdbcProvider = connection.JdbcProvider; - } - - protected internal String DbMessage { - get { - return _e.Message; - } - } - - protected int DbErrorCode { - get { - return _e.getErrorCode(); - } - } - - protected String DbSource { - get { - return _jdbcProvider; - } - } - - protected String DbSQLState { - get { - return _e.getSQLState(); - } - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbErrorCollection.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbErrorCollection.cs deleted file mode 100644 index 5e7fc681f47..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbErrorCollection.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -// System.Data.ProviderBase.AbstractDbErrorCollection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.ProviderBase { - - - using System.Collections; - using java.sql; - using System.Data.Common; - - [Serializable] - public abstract class AbstractDbErrorCollection : ICollection, IEnumerable { - private ArrayList _list; - - protected AbstractDbErrorCollection(SQLException e, AbstractDBConnection connection) { - _list = new ArrayList(); - - while(e != null) { - _list.Add(CreateDbError(e, connection)); - e = e.getNextException(); - } - } - - protected abstract AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection); - /** - * Gets the error at the specified index. - * - * @param index of the error - * @return Error on specified index - */ - protected AbstractDbError GetDbItem(int index) { - return (AbstractDbError)_list[index]; - } - - /** - * Adds new Error to the collection - * - * @param value new OleDbError - */ - public void Add(object value) { - _list.Add(value); - } - - public int Count { - get { - return _list.Count; - } - } - - public IEnumerator GetEnumerator() { - return _list.GetEnumerator(); - } - - public void CopyTo(System.Array arr, int index) { - _list.CopyTo(arr, index); - } - - bool ICollection.IsSynchronized { - get { - return _list.IsSynchronized; - } - } - - Object ICollection.SyncRoot { - get { - return _list.SyncRoot; - } - } - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbException.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbException.cs deleted file mode 100644 index 848f05cecf8..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractDbException.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// System.Data.ProviderBase.AbstractDbException -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - - -namespace System.Data.ProviderBase { - - using java.sql; - using System.Text; - using System.Data.Common; - - /* - * CURRENT LIMITATIONS - * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc) - * is not supported. - * 2. Method "void GetObjectData(...,...)" is not supported (serialization) - */ - - public abstract class AbstractDbException : -#if NET_2_0 - DbException -#else - System.SystemException -#endif - { - protected SQLException _cause; - protected AbstractDBConnection _connection; - - protected AbstractDbException(Exception cause, AbstractDBConnection connection) : base(cause.Message, cause) { - _connection = connection; - } - - protected AbstractDbException(SQLException cause, AbstractDBConnection connection) : this(String.Empty, cause, connection) {} - - protected AbstractDbException(string message, SQLException cause, AbstractDBConnection connection) : base(message, cause) { - _connection = connection; - _cause = cause; - } - - abstract protected AbstractDbErrorCollection DbErrors { get; } - - /** - * Gets the error code of the error. - * @return The error code of the error. - */ - protected int DbErrorCode { - get { - return _cause != null ? _cause.getErrorCode() : 0; - } - } - - - /** - * Gets the name of the OLE DB provider that generated the error. - * @return the name of the OLE DB provider that generated the error. - */ - public override String Source { - get { - return _connection != null ? _connection.JdbcProvider : null; - } - } - - public override string Message { - get { - StringBuilder sb = new StringBuilder(); - string message = base.Message; - bool addNewLine = false; - if (message != null && message.Length > 0) { - sb.Append(message); - addNewLine = true; - } - - foreach (AbstractDbError err in DbErrors) { - if (addNewLine) - sb.Append(Environment.NewLine); - - addNewLine = true; - sb.Append(err.DbMessage); - } - return sb.ToString(); - } - } - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractTransaction.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractTransaction.cs deleted file mode 100644 index 2c2f25f550a..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/AbstractTransaction.cs +++ /dev/null @@ -1,157 +0,0 @@ -// -// System.Data.ProviderBase.AbstractTransaction -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Data.Common; - -namespace System.Data.ProviderBase -{ - - using java.sql; - - using System.Data; - - public abstract class AbstractTransaction : DbTransaction - { - - protected String _transactionName; - protected AbstractDBConnection _connection; - - protected IsolationLevel _isolationLevel; - - public AbstractTransaction( - IsolationLevel isolationLevel, - AbstractDBConnection connection, - String transactionName) - { - connection.ValidateBeginTransaction(); - _transactionName = transactionName; - _connection = connection; - _isolationLevel = isolationLevel; - try - { - _connection.JdbcConnection.setAutoCommit(false); - _connection.JdbcConnection.setTransactionIsolation( - convertIsolationLevel(isolationLevel)); - } - catch (SQLException exp) - { - throw new System.InvalidOperationException(exp.Message, exp); - } - } - - - /** - * @see System.Data.IDbTransaction#Connection - */ - protected override DbConnection DbConnection - { - get - { - return _connection; - } - } - - /** - * @see System.Data.IDbTransaction#IsolationLevel - */ - public override IsolationLevel IsolationLevel - { - get - { - return _isolationLevel; - } - } - - /** - * @see System.Data.IDbTransaction#Commit() - */ - public override void Commit() - { - if (_connection == null) - return; - - try - { - _connection.JdbcConnection.commit(); - _connection.JdbcConnection.setAutoCommit(true); - _connection = null; - } - catch (SQLException exp) - { - throw new SystemException(exp.Message, exp); - } - } - - /** - * @see System.Data.IDbTransaction#Rollback() - */ - public override void Rollback() - { - if (_connection == null) - return; - - try - { - _connection.JdbcConnection.rollback(); - _connection.JdbcConnection.setAutoCommit(true); - _connection = null; - } - catch (SQLException exp) - { - throw new SystemException(exp.Message, exp); - } - } - - internal AbstractTransaction ActiveTransaction { - get { - // recoursively return parent transaction when nesting will - // be implemented - return _connection != null ? this : null; - } - } - - private int convertIsolationLevel(IsolationLevel isolationLevel) - { - if (isolationLevel == IsolationLevel.Unspecified) - return vmw.@internal.sql.ConnectionUtils__Finals.TRANSACTION_NONE; - if (isolationLevel == IsolationLevel.ReadCommitted) - return vmw.@internal.sql.ConnectionUtils__Finals.TRANSACTION_READ_COMMITTED; - if (isolationLevel == IsolationLevel.ReadUncommitted) - return vmw.@internal.sql.ConnectionUtils__Finals.TRANSACTION_READ_UNCOMMITTED; - if (isolationLevel == IsolationLevel.RepeatableRead) - return vmw.@internal.sql.ConnectionUtils__Finals.TRANSACTION_REPEATABLE_READ; - if (isolationLevel == IsolationLevel.Serializable) - return vmw.@internal.sql.ConnectionUtils__Finals.TRANSACTION_SERIALIZABLE; - - throw new NotSupportedException("The Isolation level '" + isolationLevel + "' is not supported"); - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/DbConvert.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/DbConvert.cs deleted file mode 100644 index 7b62cbe9295..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/DbConvert.cs +++ /dev/null @@ -1,370 +0,0 @@ -// -// System.Data.Common.DbConvert -// -// Author: -// Boris Kirzner (borisk@mainsoft.com) -// - -using System; -using System.Data.Common; - -using java.io; -using java.sql; - -namespace System.Data.ProviderBase -{ - public abstract class DbConvert - { - #region Fields - - const long JAVA_MIN_MILLIS_UTC = -62135769600000L; // java.sql.Timestamp.valueOf("0001-01-01 00:00:00.000000000").getTime() at Greenwich time zone. - static readonly long TIMEZONE_RAW_OFFSET; - // .NET milliseconds value of DateTime(1582,1,1,0,0,0,0).Ticks/TimeSpan.TicksPerMillisecond - const long CLR_MILLIS_1582 = 49891507200000L; - const long MILLIS_PER_TWO_DAYS = 2 * TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond; // 172800000L; - internal static readonly java.util.TimeZone DEFAULT_TIME_ZONE; - - #endregion // Fields - - #region java.sql.Types constants - - internal enum JavaSqlTypes { - ARRAY = 2003 , - BIGINT = -5, - BINARY = -2 , - BIT = -7 , - BLOB = 2004, - BOOLEAN = 16, - CHAR = 1, - CLOB = 2005, - DATALINK = 70, - DATE = 91, - DECIMAL = 3, - DISTINCT = 2001, - DOUBLE = 8, - FLOAT = 6, - INTEGER = 4, - JAVA_OBJECT = 2000, - LONGVARBINARY = -4, - LONGVARCHAR = -1, - NULL = 0, - NUMERIC = 2 , - OTHER = 1111 , - REAL = 7 , - REF = 2006 , - SMALLINT = 5, - STRUCT = 2002, - TIME = 92, - TIMESTAMP = 93, - TINYINT = -6, - VARBINARY = -3, - VARCHAR = 12, - // NOTSET = int.MinValue - } - - - #endregion // java.sql.Types constants - - #region Methods - - static DbConvert() - { - DEFAULT_TIME_ZONE = java.util.SimpleTimeZone.getDefault(); - TIMEZONE_RAW_OFFSET = (long)DEFAULT_TIME_ZONE.getRawOffset(); - } - - // The diff between .Net and Java goes as the following: - // * at 1582: java has 10 days less than .net - // * below 1500 (exept 1200,800,400) : each 100'th year java adds 1 day over .net. - // Current implementation compatible with .net in 1-99 and since 1582. In 100-1582 we're not compatible with .Ner nor with Java - - internal static long JavaMillisToClrMillis(long javaMillis) - { - return JavaMillisToClrMillisUTC(javaMillis) + TIMEZONE_RAW_OFFSET; - } - - internal static long JavaMillisToClrMillisUTC(long javaMillis) { - long clrMillis = javaMillis - JAVA_MIN_MILLIS_UTC; - if (clrMillis > CLR_MILLIS_1582) { - clrMillis -= MILLIS_PER_TWO_DAYS; - } - return clrMillis; - } - - internal static long ClrMillisToJavaMillis(long clrMillis) - { - return ClrMillisToJavaMillisUTC(clrMillis) - TIMEZONE_RAW_OFFSET; - } - - internal static long ClrMillisToJavaMillisUTC(long clrMillis) { - long javaMillis = clrMillis + JAVA_MIN_MILLIS_UTC; - if (clrMillis > CLR_MILLIS_1582) { - javaMillis += MILLIS_PER_TWO_DAYS; - } - return javaMillis; - } - - internal static java.sql.Time ClrTicksToJavaTime(long ticks) { - return new Time((ticks / TimeSpan.TicksPerMillisecond) - - DEFAULT_TIME_ZONE.getRawOffset()); - } - - internal static java.sql.Date ClrTicksToJavaDate(long ticks) { - java.sql.Date d = new java.sql.Date(0); - ClrTicksToJavaDate(d, ticks); - return d; - } - - internal static java.sql.Timestamp ClrTicksToJavaTimestamp(long ticks) - { - java.sql.Timestamp ts = new java.sql.Timestamp(0); - ClrTicksToJavaDate(ts, ticks); - -// int nanos = (int)(ticks % TimeSpan.TicksPerMillisecond) * 100; -// ts.setNanos(javaTimestamp.getNanos() + nanos); - - return ts; - } - - internal static void ClrTicksToJavaDate(java.util.Date d, long ticks) { - long millis = ClrMillisToJavaMillis(ticks / TimeSpan.TicksPerMillisecond); - - d.setTime(millis); - if (DEFAULT_TIME_ZONE.inDaylightTime(d)) { - millis -= DEFAULT_TIME_ZONE.getDSTSavings(); - d.setTime(millis); - } - } - - internal static long JavaTimestampToClrTicks(java.sql.Timestamp ts) - { - long ticks = JavaDateToClrTicks(ts); - // Extra ticks, for dbs that can save them. - // We do not use it, since .net does not saves ticks for fractial milliseconds - // long ticksLessThanMilliseconds = (ts.getNanos()*100) % TimeSpan.TicksPerMillisecond; - // ticks += ticksLessThanMilliseconds; - - return ticks; - } - - internal static long JavaDateToClrTicks(java.util.Date d) { - long millis = JavaMillisToClrMillis(d.getTime()); - if (DEFAULT_TIME_ZONE.inDaylightTime(d)) { - millis += DEFAULT_TIME_ZONE.getDSTSavings(); - } - return millis * TimeSpan.TicksPerMillisecond; - } - - internal static long JavaTimeToClrTicks(java.sql.Time t) { - return (t.getTime() + DEFAULT_TIME_ZONE.getRawOffset()) - * TimeSpan.TicksPerMillisecond; - } - - internal static Type JavaSqlTypeToClrType(int sqlTypeValue) - { - JavaSqlTypes sqlType = (JavaSqlTypes)sqlTypeValue; - - switch (sqlType) { - case JavaSqlTypes.ARRAY : return typeof (java.sql.Array); - case JavaSqlTypes.BIGINT : return DbTypes.TypeOfInt64; - case JavaSqlTypes.BINARY : return DbTypes.TypeOfByteArray; - case JavaSqlTypes.BIT : return DbTypes.TypeOfBoolean; - case JavaSqlTypes.BLOB : return DbTypes.TypeOfByteArray; - case JavaSqlTypes.BOOLEAN : return DbTypes.TypeOfBoolean; - case JavaSqlTypes.CHAR : return DbTypes.TypeOfString; - case JavaSqlTypes.CLOB : return DbTypes.TypeOfString; -// case JavaSqlTypes.DATALINK : - case JavaSqlTypes.DATE : return DbTypes.TypeOfDateTime; - case JavaSqlTypes.DECIMAL : return DbTypes.TypeOfDecimal; -// case JavaSqlTypes.DISTINCT : - case JavaSqlTypes.DOUBLE : return DbTypes.TypeOfDouble; - case JavaSqlTypes.FLOAT : return DbTypes.TypeOfDouble; - case JavaSqlTypes.INTEGER : return DbTypes.TypeOfInt32; -// case JavaSqlTypes.JAVA_OBJECT : - case JavaSqlTypes.LONGVARBINARY : return DbTypes.TypeOfByteArray; - case JavaSqlTypes.LONGVARCHAR : return DbTypes.TypeOfString; - case JavaSqlTypes.NULL : return null; - case JavaSqlTypes.NUMERIC : return DbTypes.TypeOfDecimal; -// case JavaSqlTypes.OTHER : - case JavaSqlTypes.REAL : return DbTypes.TypeOfSingle; - case JavaSqlTypes.REF : return typeof (java.sql.Ref); - case JavaSqlTypes.SMALLINT : return DbTypes.TypeOfInt16; - case JavaSqlTypes.STRUCT : return typeof (java.sql.Struct); - case JavaSqlTypes.TIME : return DbTypes.TypeOfTimespan; - case JavaSqlTypes.TIMESTAMP : return DbTypes.TypeOfDateTime; - case JavaSqlTypes.TINYINT : return DbTypes.TypeOfByte; - case JavaSqlTypes.VARBINARY : return DbTypes.TypeOfByteArray; - case JavaSqlTypes.VARCHAR : return DbTypes.TypeOfString; - default : return DbTypes.TypeOfObject; - } - - } - - - internal static object JavaResultSetToClrWrapper(CallableStatement results,int columnIndex,JavaSqlTypes javaSqlType,int maxLength ,ResultSetMetaData resultsMetaData) - { - object returnValue = null; - sbyte[] sbyteArray; - long milliseconds; - long ticks; - string s; - columnIndex++; //jdbc style - switch (javaSqlType) { - case JavaSqlTypes.ARRAY : - returnValue = results.getArray(columnIndex); - break; - case JavaSqlTypes.BIGINT : - returnValue = results.getLong(columnIndex); - break; - case JavaSqlTypes.BINARY : - case JavaSqlTypes.VARBINARY : - case JavaSqlTypes.LONGVARBINARY : - // FIXME : comsider using maxLength - sbyteArray = results.getBytes(columnIndex); - if (sbyteArray != null) { - returnValue = vmw.common.TypeUtils.ToByteArray(sbyteArray); - } - break; - case JavaSqlTypes.BIT : - returnValue = results.getBoolean(columnIndex); - break; - case JavaSqlTypes.BLOB : - // FIXME : comsider using maxLength - java.sql.Blob blob = results.getBlob(columnIndex); - if (blob != null) { - InputStream input = blob.getBinaryStream(); - if (input == null) { - returnValue = new byte[0]; - } - else { - long length = blob.length(); - byte[] byteValue = new byte[length]; - sbyte[] sbyteValue = vmw.common.TypeUtils.ToSByteArray(byteValue); - input.read(sbyteValue); - returnValue = byteValue; - } - } - break; - case JavaSqlTypes.CHAR : - if (resultsMetaData != null && "uniqueidentifier".Equals(resultsMetaData.getColumnTypeName(columnIndex))) { - returnValue = new Guid(results.getString(columnIndex)); - } - else { - // Oracle Jdbc driver returns extra trailing 0 chars for NCHAR columns, so we threat this at parameter.Size level - s = results.getString(columnIndex); - if ((s != null) && (maxLength < s.Length)) { - s = s.Substring(0,maxLength); - } - returnValue = s; - } - break; - case JavaSqlTypes.CLOB : - // FIXME : comsider using maxLength - java.sql.Clob clob = results.getClob(columnIndex); - if (clob != null) { - java.io.Reader reader = clob.getCharacterStream(); - if (reader == null) { - returnValue = String.Empty; - } - else { - long length = clob.length(); - char[] charValue = new char[length]; - reader.read(charValue); - returnValue = new string(charValue); - } - } - break; - case JavaSqlTypes.TIME : - Time t = results.getTime(columnIndex); - if (t != null) { - returnValue = new TimeSpan(JavaTimeToClrTicks(t)); - } - break; - case JavaSqlTypes.DATE : - Date d = results.getDate(columnIndex); - if (d != null) { - returnValue = new DateTime(JavaDateToClrTicks(d)); - } - break; - case JavaSqlTypes.TIMESTAMP : - Timestamp ts = results.getTimestamp(columnIndex); - if (ts != null) { - returnValue = new DateTime(JavaTimestampToClrTicks(ts)); - } - break; - case JavaSqlTypes.DECIMAL : - case JavaSqlTypes.NUMERIC : - // java.sql.Types.NUMERIC (2), columnTypeName NUMBER, columnClassName java.math.BigDecimal - // therefore we rely on scale - if (resultsMetaData != null && resultsMetaData.getScale(columnIndex) == -127) { - // Oracle db type FLOAT - returnValue = results.getDouble(columnIndex); - } - else { - java.math.BigDecimal bigDecimal = results.getBigDecimal(columnIndex); - if (bigDecimal != null) { - returnValue = vmw.common.PrimitiveTypeUtils.BigDecimalToDecimal(bigDecimal); - } - } - break; - case JavaSqlTypes.DISTINCT : - returnValue = results.getObject(columnIndex); - break; - case JavaSqlTypes.DOUBLE : - returnValue = results.getDouble(columnIndex); - break; - case JavaSqlTypes.FLOAT : - //float f = results.getFloat(columnIndex); - returnValue = results.getDouble(columnIndex); - break; - case JavaSqlTypes.INTEGER : - returnValue = results.getInt(columnIndex); - break; - case JavaSqlTypes.JAVA_OBJECT : - returnValue = results.getObject(columnIndex); - break; - case JavaSqlTypes.LONGVARCHAR : - returnValue = results.getString(columnIndex); - break; - case JavaSqlTypes.NULL : - returnValue = DBNull.Value; - break; - case JavaSqlTypes.OTHER : - returnValue = results.getObject(columnIndex); - break; - case JavaSqlTypes.REAL : - returnValue = results.getFloat(columnIndex); - break; - case JavaSqlTypes.REF : - returnValue = results.getRef(columnIndex); - break; - case JavaSqlTypes.SMALLINT : - returnValue = results.getShort(columnIndex); - break; - case JavaSqlTypes.STRUCT : - returnValue = results.getObject(columnIndex); - break; - case JavaSqlTypes.TINYINT : - returnValue = Convert.ToByte(results.getByte(columnIndex)); - break; - case JavaSqlTypes.VARCHAR : - s = results.getString(columnIndex); - if ((s != null) && (maxLength < s.Length)) { - s = s.Substring(0,maxLength); - } - returnValue = s; - break; - default : - returnValue = results.getObject(columnIndex); - break; - } - - if (results.wasNull() || results == null) { - return DBNull.Value; - } - return returnValue; - } - - #endregion // Methods - } -} diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/ParameterMetadataWrapper.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/ParameterMetadataWrapper.cs deleted file mode 100644 index 45ee1b084c6..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/ParameterMetadataWrapper.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -// System.Data.ProviderBase.ParameterMetaDataWrapper -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; - -using java.sql; - -namespace System.Data.ProviderBase -{ - public class ParameterMetadataWrapper : java.sql.ResultSetMetaData - { - #region Fields - - ParameterMetaData _parameterMetaData; - - #endregion // Fields - - #region Constructors - - public ParameterMetadataWrapper(ParameterMetaData parameterMetaData) - { - _parameterMetaData = parameterMetaData; - } - - #endregion // Constructors - - #region Methods - - public int getColumnCount() { throw new NotImplementedException(); } - - public int getColumnDisplaySize(int i) { throw new NotImplementedException(); } - - public int getColumnType(int i) { throw new NotImplementedException(); } - - public int getPrecision(int i) { throw new NotImplementedException(); } - - public int getScale(int i) { throw new NotImplementedException(); } - - public int isNullable(int i) { throw new NotImplementedException(); } - - public bool isAutoIncrement(int i) { throw new NotImplementedException(); } - - public bool isCaseSensitive(int i) { throw new NotImplementedException(); } - - public bool isCurrency(int i) { throw new NotImplementedException(); } - - public bool isDefinitelyWritable(int i) { throw new NotImplementedException(); } - - public bool isReadOnly(int i) { throw new NotImplementedException(); } - - public bool isSearchable(int i) { throw new NotImplementedException(); } - - public bool isSigned(int i) { throw new NotImplementedException(); } - - public bool isWritable(int i) { throw new NotImplementedException(); } - - public String getCatalogName(int i) { throw new NotImplementedException(); } - - public String getColumnClassName(int i) { throw new NotImplementedException(); } - - public String getColumnLabel(int i) { throw new NotImplementedException(); } - - public String getColumnName(int i) { throw new NotImplementedException(); } - - public String getColumnTypeName(int i) { return _parameterMetaData.getParameterTypeName(i); } - - public String getSchemaName(int i) { throw new NotImplementedException(); } - - public String getTableName(int i) { throw new NotImplementedException(); } - - #endregion // Methods - } -} diff --git a/mcs/class/System.Data/System.Data.ProviderBase.jvm/ReaderCache.cs b/mcs/class/System.Data/System.Data.ProviderBase.jvm/ReaderCache.cs deleted file mode 100644 index 7a9d1ff7d5f..00000000000 --- a/mcs/class/System.Data/System.Data.ProviderBase.jvm/ReaderCache.cs +++ /dev/null @@ -1,795 +0,0 @@ -// -// System.Data.ProviderBase.ReaderCache.cs -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using java.sql; - -namespace System.Data.ProviderBase -{ - public interface IReaderCacheContainer - { - void Fetch(ResultSet rs, int columnIndex, bool isSequential); - bool IsNull(); - bool IsNumeric(); - object GetValue(); - } - - public abstract class ReaderCacheContainerBase : IReaderCacheContainer - { - #region Fields - - bool _isNull; - - #endregion // Fields - - #region Methods - - protected abstract void FetchInternal(ResultSet rs, int columnIndex); - protected virtual void FetchInternal(ResultSet rs, int columnIndex, bool isSequential) { - FetchInternal(rs, columnIndex); - } - - public virtual bool IsNumeric() { - return false; - } - - public abstract object GetValue(); - - public void Fetch(ResultSet rs, int columnIndex, bool isSequential) - { - FetchInternal(rs, columnIndex + 1, isSequential); - _isNull = rs.wasNull(); - } - - public bool IsNull() - { - return _isNull; - } - - #endregion // Methods - } - - - internal sealed class ArrayReaderCacheContainer : ReaderCacheContainerBase // Types.ARRAY - { - #region Fields - - object _a; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _a = rs.getArray(columnIndex).getArray(); - } - - public override object GetValue() - { - return _a; - } - - #endregion // Methods - } - - - internal sealed class Int64ReaderCacheContainer : ReaderCacheContainerBase // Types.BIGINT - { - #region Fields - - long _l; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _l = rs.getLong(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - - public override object GetValue() - { - return _l; - } - - internal long GetInt64() - { - return _l; - } - - #endregion // Methods - } - - - internal class BytesReaderCacheContainer : ReaderCacheContainerBase // Types.BINARY, Types.VARBINARY, Types.LONGVARBINARY - { - #region Fields - - protected byte[] _b; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - sbyte[] sbyteArray = rs.getBytes(columnIndex); - if (sbyteArray != null) { - _b = (byte[])vmw.common.TypeUtils.ToByteArray(sbyteArray); - } - } - - public override object GetValue() - { - return _b; - } - - internal byte[] GetBytes() - { - return (byte[])GetValue(); - } - - internal virtual long GetBytes( - long dataIndex, - byte[] buffer, - int bufferIndex, - int length) { - if (_b == null) - return 0; - if (buffer == null) - return _b.LongLength; - long actualLength = ((dataIndex + length) >= _b.LongLength) ? (_b.LongLength - dataIndex) : length; - Array.Copy(_b,dataIndex,buffer,bufferIndex,actualLength); - return actualLength; - } - - #endregion // Methods - } - - - internal sealed class BooleanReaderCacheContainer : ReaderCacheContainerBase // Types.BIT - { - #region Fields - - bool _b; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _b = rs.getBoolean(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _b; - } - - internal bool GetBoolean() - { - return _b; - } - - #endregion // Methods - } - - - internal sealed class BlobReaderCacheContainer : BytesReaderCacheContainer // Types.BLOB - { - #region Fields - - static readonly byte[] _emptyByteArr = new byte[0]; - java.sql.Blob _blob; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) { - throw new NotImplementedException("Should not be called"); - } - - - protected override void FetchInternal(ResultSet rs, int columnIndex, bool isSequential) - { - _blob = rs.getBlob(columnIndex); - if (!isSequential) - ReadAll(); - - } - - void ReadAll() { - if (_blob != null) { - long length = _blob.length(); - if (length == 0) { - _b = _emptyByteArr; - } - else { - java.io.InputStream input = _blob.getBinaryStream(); - byte[] byteValue = new byte[length]; - sbyte[] sbyteValue = vmw.common.TypeUtils.ToSByteArray(byteValue); - input.read(sbyteValue); - _b = byteValue; - } - } - } - - public override object GetValue() - { - if (_b == null) - ReadAll(); - return base.GetValue(); - } - - internal override long GetBytes(long dataIndex, byte[] buffer, int bufferIndex, int length) { - if (_b != null) - return base.GetBytes (dataIndex, buffer, bufferIndex, length); - - if (_blob == null) - return 0; - - if (buffer == null) - return _blob.length(); - - java.io.InputStream input = _blob.getBinaryStream(); - input.skip(dataIndex); - return input.read(vmw.common.TypeUtils.ToSByteArray(buffer), bufferIndex, length); - } - - - #endregion // Methods - } - - - internal abstract class CharsReaderCacheContainer : ReaderCacheContainerBase // - { - #region Fields - - #endregion // Fields - - #region Methods - - internal abstract long GetChars( - long dataIndex, - char[] buffer, - int bufferIndex, - int length); - - #endregion // Methods - } - - - internal sealed class GuidReaderCacheContainer : ReaderCacheContainerBase // Types.CHAR - { - #region Fields - - Guid _g; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - string s = rs.getString(columnIndex); - if (s != null) - _g = new Guid(s); - } - - public override object GetValue() - { - return _g; - } - - internal Guid GetGuid() - { - return _g; - } - - #endregion // Methods - } - - - internal sealed class ClobReaderCacheContainer : StringReaderCacheContainer // Types.CLOB - { - #region Fields - - java.sql.Clob _clob; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex, bool isSequential) - { - _clob = rs.getClob(columnIndex); - if (!isSequential) - ReadAll(); - - } - - void ReadAll() { - if (_clob != null) { - long length = _clob.length(); - if (length == 0) { - _s = String.Empty; - } - else { - java.io.Reader reader = _clob.getCharacterStream(); - char[] charValue = new char[length]; - reader.read(charValue); - if (charValue != null) - _s = new String(charValue); - } - } - } - - public override object GetValue() - { - if (_s == null) - ReadAll(); - return base.GetValue(); - } - - internal override long GetChars(long dataIndex, char[] buffer, int bufferIndex, int length) { - if (_s != null) - return base.GetChars (dataIndex, buffer, bufferIndex, length); - - if (_clob == null) - return 0; - - if (buffer == null) - return _clob.length(); - - java.io.Reader reader = _clob.getCharacterStream(); - reader.skip(dataIndex); - return reader.read(buffer, bufferIndex, length); - } - - - #endregion // Methods - } - - - internal sealed class TimeSpanReaderCacheContainer : ReaderCacheContainerBase // Types.TIME - { - #region Fields - - TimeSpan _t; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - Time t = rs.getTime(columnIndex); - if (t != null) { - _t = new TimeSpan(DbConvert.JavaTimeToClrTicks(t)); - } - } - - public override object GetValue() - { - return _t; - } - - internal TimeSpan GetTimeSpan() - { - return _t; - } - - #endregion // Methods - } - - - internal class DateTimeReaderCacheContainer : ReaderCacheContainerBase // Types.TIMESTAMP - { - #region Fields - - protected DateTime _d; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - Date d = rs.getDate(columnIndex); - if (d != null) { - _d = new DateTime(DbConvert.JavaDateToClrTicks(d)); - } - } - - public override object GetValue() - { - return _d; - } - - internal DateTime GetDateTime() - { - return _d; - } - - #endregion // Methods - } - - internal sealed class TimestampReaderCacheContainer : DateTimeReaderCacheContainer // Types.DATE - { - protected override void FetchInternal(ResultSet rs, int columnIndex) { - Timestamp ts = rs.getTimestamp(columnIndex); - if (ts != null) { - _d = new DateTime(DbConvert.JavaTimestampToClrTicks(ts)); - } - } - } - - - internal sealed class DecimalReaderCacheContainer : ReaderCacheContainerBase // Types.DECIMAL, Types.NUMERIC - { - #region Fields - - decimal _d; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - java.math.BigDecimal bigDecimal = rs.getBigDecimal(columnIndex); - if (bigDecimal != null) { - _d = (decimal)vmw.common.PrimitiveTypeUtils.BigDecimalToDecimal(bigDecimal); - } - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _d; - } - - internal decimal GetDecimal() - { - return _d; - } - - #endregion // Methods - } - - - internal sealed class DoubleReaderCacheContainer : ReaderCacheContainerBase // Types.DOUBLE, Types.Float, Types.NUMERIC for Oracle with scale = -127 - { - #region Fields - - double _d; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _d = rs.getDouble(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _d; - } - - internal double GetDouble() - { - return _d; - } - - #endregion // Methods - } - - - internal sealed class Int32ReaderCacheContainer : ReaderCacheContainerBase // Types.INTEGER - { - #region Fields - - int _i; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _i = rs.getInt(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _i; - } - - internal int GetInt32() - { - return _i; - } - - #endregion // Methods - } - - - internal class StringReaderCacheContainer : CharsReaderCacheContainer // Types.LONGVARCHAR, Types.VARCHAR, Types.CHAR - { - #region Fields - - protected string _s; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _s = rs.getString(columnIndex); - // Oracle Jdbc driver returns extra trailing 0 chars for NCHAR columns -// if ((_s != null) && (_jdbcType == 1)) { -// Console.WriteLine(_jdbcType); -// int zeroIndex = ((string)_s).IndexOf((char)0); -// if (zeroIndex > 0) { -// Console.WriteLine("zero-padded"); -// _s = ((string)_s).Substring(0,zeroIndex); -// } -// else { -// // Oracle sometimes pads with blanks (32) -// int blankIndex = ((string)_s).IndexOf((char)32); -// if (blankIndex > 0) { -// Console.WriteLine("blank-padded"); -// _s = ((string)_s).Substring(0,blankIndex); -// } -// } -// } - } - - public override object GetValue() - { - return _s; - } - - internal string GetString() - { - return _s; - } - - internal override long GetChars(long dataIndex, char[] buffer, int bufferIndex, int length) { - if (_s == null) - return 0; - if (buffer == null) - return _s.Length; - int actualLength = ((dataIndex + length) >= _s.Length) ? (_s.Length - (int)dataIndex) : length; - _s.CopyTo((int)dataIndex, buffer, bufferIndex, actualLength); - return actualLength; - } - - - #endregion // Methods - } - - - internal sealed class NullReaderCacheContainer : ReaderCacheContainerBase // Types.NULL - { - #region Fields - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - } - - public override object GetValue() - { - return DBNull.Value; - } - - #endregion // Methods - } - - - internal sealed class FloatReaderCacheContainer : ReaderCacheContainerBase // Types.REAL - { - #region Fields - - float _f; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _f = rs.getFloat(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _f; - } - - internal float GetFloat() - { - return _f; - } - - #endregion // Methods - } - - - internal sealed class RefReaderCacheContainer : ReaderCacheContainerBase // Types.REF - { - #region Fields - - java.sql.Ref _r; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _r = rs.getRef(columnIndex); - } - - public override object GetValue() - { - return _r; - } - - #endregion // Methods - } - - - internal sealed class Int16ReaderCacheContainer : ReaderCacheContainerBase // Types.SMALLINT - { - #region Fields - - short _s; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _s = rs.getShort(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _s; - } - - internal short GetInt16() - { - return _s; - } - - #endregion // Methods - } - - - internal sealed class ByteReaderCacheContainer : ReaderCacheContainerBase // Types.TINYINT - { - #region Fields - - byte _b; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - _b = (byte)rs.getByte(columnIndex); - } - - public override bool IsNumeric() { - return true; - } - - public override object GetValue() - { - return _b; - } - - internal byte GetByte() - { - return _b; - } - - #endregion // Methods - } - - - internal sealed class ObjectReaderCacheContainer : ReaderCacheContainerBase // Types.Distinct, Types.JAVA_OBJECT, Types.OTHER, Types.STRUCT - { - #region Fields - - object o; - - #endregion // Fields - - #region Methods - - protected override void FetchInternal(ResultSet rs, int columnIndex) - { - o = rs.getObject(columnIndex); - } - - public override object GetValue() - { - return o; - } - - #endregion // Methods - } - -} diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlCommand.cs deleted file mode 100644 index 4333ae8f3c5..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlCommand.cs +++ /dev/null @@ -1,284 +0,0 @@ -// -// System.Data.SqlClient.SqlCommand -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; -using System.Data; -using System.Data.Common; -using System.Data.ProviderBase; -using System.Xml; - -using java.sql; - -namespace System.Data.SqlClient -{ - public sealed class SqlCommand : AbstractDbCommand - { - #region Fields - - #endregion // Fields - - #region Constructors - - // Initializes a new instance of the SqlCommand class. - // The base constructor initializes all fields to their default values. - // The following table shows initial property values for an instance of SqlCommand. - public SqlCommand() : this(null, null, null) - { - } - - public SqlCommand(SqlConnection connection) : this(null, connection, null) - { - } - - // Initializes a new instance of the SqlCommand class with the text of the query. - public SqlCommand(String cmdText) : this(cmdText, null, null) - { - } - - // Initializes a new instance of the SqlCommand class with the text of the query and a SqlConnection. - public SqlCommand(String cmdText, SqlConnection connection) : this(cmdText, connection, null) - { - } - - // Initializes a new instance of the SqlCommand class with the text of the query, a SqlConnection, and the Transaction. - public SqlCommand( - String cmdText, - SqlConnection connection, - SqlTransaction transaction) - : base(cmdText, connection, transaction) - { - } - - #endregion // Constructors - - #region Properties - - protected override string InternalCommandText { - get { - string commandText = CommandText; - if (CommandType != CommandType.StoredProcedure || - string.IsNullOrEmpty (commandText) || - commandText [0] == '[' || - commandText.IndexOf ('.') >= 0) - return commandText; - - string trimmedCommandText = commandText.TrimEnd (); - if (trimmedCommandText.Length > 0 && trimmedCommandText [trimmedCommandText.Length - 1] != ')') - commandText = String.Concat ("[", commandText, "]"); - - return commandText; - } - } - - public new SqlConnection Connection - { - get { return (SqlConnection)base.Connection; } - set { base.Connection = value; } - } - - public new SqlParameterCollection Parameters - { - get { - return (SqlParameterCollection)base.Parameters; - } - } - - public new SqlTransaction Transaction - { - get { return (SqlTransaction)base.Transaction; } - set { base.Transaction = value; } - } - -#if USE_DOTNET_REGEX - protected override Regex StoredProcedureRegExp -#else - protected override java.util.regex.Pattern StoredProcedureRegExp { -#endif - get { return SqlStatementsHelper.NamedParameterStoredProcedureRegExp; } - } - - protected override SimpleRegex ParameterRegExp - { - get { return SqlStatementsHelper.NamedParameterRegExp; } - } - - #endregion // Properties - - #region Methods - - public XmlReader ExecuteXmlReader() { - return SqlXmlTextReader.Create(ExecuteReader(CommandBehavior.SequentialAccess)); - } - - public new SqlDataReader ExecuteReader() - { - return (SqlDataReader)ExecuteReader(CommandBehavior.Default); - } - - public new SqlDataReader ExecuteReader(CommandBehavior behavior) - { - return (SqlDataReader)base.ExecuteReader(behavior); - } - - public new SqlParameter CreateParameter() - { - return (SqlParameter)CreateParameterInternal(); - } - - protected sealed override void CheckParameters() - { - // do nothing - } - - protected override AbstractDbParameter GetUserParameter(string parameterName, IList userParametersList, int userParametersListPosition/*,int userParametersListStart,int userParameterListCount*/) - { -// Match match = SqlStatementsHelper.NamedParameterRegExp.Match(parameterName); -// parameterName = match.Result("${USERPARAM}"); -// if (parameterName.Length == 0) -// return null; - - for(int i=0; i < userParametersList.Count; i++) { - AbstractDbParameter userParameter = (AbstractDbParameter)userParametersList[i]; - if (String.Compare(parameterName, userParameter.Placeholder.Trim(), true, System.Globalization.CultureInfo.InvariantCulture) == 0) { - return userParameter; - } - } - - return null; - } - - protected override AbstractDbParameter GetReturnParameter (IList userParametersList) - { - for(int i=0; i < userParametersList.Count; i++) { - AbstractDbParameter userParameter = (AbstractDbParameter)userParametersList[i]; - if (userParameter.Direction == ParameterDirection.ReturnValue) { - return userParameter; - } - } - - return null; - } - - protected sealed override DbParameter CreateParameterInternal() - { - return new SqlParameter(); - } - - protected sealed override DbDataReader CreateReader() - { - return new SqlDataReader(this); - } - - protected sealed override DbParameterCollection CreateParameterCollection(AbstractDbCommand parent) - { - return new SqlParameterCollection((SqlCommand)parent); - } - - protected internal sealed override SystemException CreateException(SQLException e) - { - return new SqlException(e, Connection); - } - - #region Asynchronous behavior -#if NET_2_0 - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteReader () - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteReader (CommandBehavior behavior) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteReader (AsyncCallback callback, Object stateObject) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteReader (AsyncCallback callback, Object stateObject, CommandBehavior behavior) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public SqlDataReader EndExecuteReader (IAsyncResult asyncResult) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteXmlReader () - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteXmlReader (AsyncCallback callback, Object stateObject) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public XmlReader EndExecuteXmlReader (IAsyncResult asyncResult) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteNonQuery () - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public IAsyncResult BeginExecuteNonQuery (AsyncCallback callback, Object stateObject) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Asynchronous behavior not implemented")] - public int EndExecuteNonQuery (IAsyncResult asyncResult) - { - throw new NotImplementedException (); - } -#endif - #endregion - #endregion // Methods - } -} diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConnection.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConnection.cs deleted file mode 100644 index bf556bb0cd9..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConnection.cs +++ /dev/null @@ -1,234 +0,0 @@ -// -// System.Data.SqlClient.SqlConnection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Data; -using System.Data.Common; -using System.Collections; -using System.Data.ProviderBase; - -using java.sql; - -using System.Configuration; -using Mainsoft.Data.Configuration; -using Mainsoft.Data.Jdbc.Providers; - -namespace System.Data.SqlClient -{ - public class SqlConnection : AbstractDBConnection - { - #region Fields - - private const int DEFAULT_PACKET_SIZE = 8192; - - #endregion // Fields - - #region Constructors - - public SqlConnection() : this(null) - { - } - - public SqlConnection(String connectionString) : base(connectionString) - { - } - - #endregion // Constructors - - #region Events - - [DataCategory ("InfoMessage")] - [DataSysDescription ("Event triggered when messages arrive from the DataSource.")] - public event SqlInfoMessageEventHandler InfoMessage; - - #endregion // Events - - #region Properties - - public string WorkstationId - { - get { return (string)ConnectionStringBuilder["workstation id"]; } - } - - public int PacketSize - { - get { - string packetSize = (string)ConnectionStringBuilder["Packet Size"]; - if (packetSize == null || packetSize.Length == 0) { - return DEFAULT_PACKET_SIZE; - } - try { - return Convert.ToInt32(packetSize); - } - catch(FormatException e) { - throw ExceptionHelper.InvalidValueForKey("packet size"); - } - catch (OverflowException e) { - throw ExceptionHelper.InvalidValueForKey("packet size"); - } - } - } - - protected override IConnectionProvider GetConnectionProvider() { - IDictionary conProviderDict = ConnectionStringDictionary.Parse(ConnectionString); - string provider = (string)conProviderDict["Provider"]; - if (provider == null) - provider = "SQLCLIENT"; - - return GetConnectionProvider("Mainsoft.Data.Configuration/SqlClientProviders", provider); - } - - #endregion // Properties - - #region Methods - - protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { - return BeginTransaction(isolationLevel); - } - - public SqlTransaction BeginTransaction(String transactionName) - { - return BeginTransaction(IsolationLevel.ReadCommitted,transactionName); - } - - public new SqlTransaction BeginTransaction(IsolationLevel isolationLevel) - { - return BeginTransaction(isolationLevel,"Transaction"); - } - - public new SqlTransaction BeginTransaction() - { - return BeginTransaction(IsolationLevel.ReadCommitted); - } - - public SqlTransaction BeginTransaction(IsolationLevel isolationLevel, string transactionName) - { - return new SqlTransaction(isolationLevel, this, transactionName); - } - - public new SqlCommand CreateCommand() - { - return new SqlCommand(this); - } - - protected override DbCommand CreateDbCommand() { - return CreateCommand(); - } - - protected internal sealed override void OnSqlWarning(SQLWarning warning) - { - SqlErrorCollection col = new SqlErrorCollection(warning, this); - OnSqlInfoMessage(new SqlInfoMessageEventArgs(col)); - } - - protected sealed override SystemException CreateException(SQLException e) - { - return new SqlException(e, this); - } - - protected sealed override SystemException CreateException(string message) - { - return new SqlException(message, null, this); - } - - private void OnSqlInfoMessage (SqlInfoMessageEventArgs value) - { - if (InfoMessage != null) { - InfoMessage (this, value); - } - } - -#if NET_2_0 - - [MonoNotSupported("")] - public static void ChangePassword (string connectionString, string newPassword) - { - throw new NotImplementedException (); - - // FIXME: refactored from Mono implementation. Not finished!!! - if (connectionString == null || newPassword == null || newPassword == String.Empty) - throw new ArgumentNullException (); - if (newPassword.Length > 128) - throw new ArgumentException ("The value of newPassword exceeds its permittable length which is 128"); - - SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder (connectionString); - if (builder.IntegratedSecurity) { - throw new ArgumentException ("Can't use integrated security when changing password"); - } - - using (SqlConnection conn = new SqlConnection (connectionString)) { - conn.Open (); - SqlCommand cmd = conn.CreateCommand (); - cmd.CommandText = "sp_password"; - cmd.CommandType = CommandType.StoredProcedure; - // FIXME: Need to extract old password and user from our structures - // of the connectionString. - cmd.Parameters.Add (builder.Password); // Is this good??? - cmd.Parameters.Add (newPassword); - cmd.Parameters.Add (builder.UserID); // Is this good??? - cmd.ExecuteNonQuery(); - } - } - - #region Pooling - - [MonoNotSupported("Pooling not supported")] - public static void ClearPool (SqlConnection connection) - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Pooling not supported")] - public static void ClearAllPools () - { - throw new NotImplementedException (); - } - - #endregion - #region Statistics - - [MonoNotSupported ("Statistics not supported")] - public IDictionary RetrieveStatistics () - { - throw new NotImplementedException (); - } - - [MonoNotSupported ("Statistics not supported")] - public void ResetStatistics () - { - throw new NotImplementedException (); - } - - #endregion -#endif - #endregion // Methods - - } -} diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConvert.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConvert.cs deleted file mode 100644 index 17d9db29caf..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlConvert.cs +++ /dev/null @@ -1,243 +0,0 @@ -// -// System.Data.SqlClient.SqlConvert -// -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Data.Common; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.SqlClient -{ - internal sealed class SqlConvert : DbConvert - { - #region Methods - - internal static String JdbcTypeNameToDbTypeName(string jdbcTypeName) - { - return jdbcTypeName.Trim(); - } - - internal static SqlDbType JdbcTypeToSqlDbType(int jdbcType) - { - // FIXME : other java.sql.Type - // Types.ARRAY - if(Types.BIGINT == jdbcType) return SqlDbType.BigInt; - if(Types.BINARY == jdbcType) return SqlDbType.Binary; - if(Types.BIT == jdbcType) return SqlDbType.Bit; - if(Types.BLOB == jdbcType) return SqlDbType.Binary; - // Types.BOOLEAN - if(Types.CHAR == jdbcType) return SqlDbType.Char; - if(Types.CLOB == jdbcType) return SqlDbType.Binary; - if(Types.DATE == jdbcType) return SqlDbType.DateTime; - if(Types.DECIMAL == jdbcType) return SqlDbType.Decimal; - // Types.DISTINCT - if(Types.DOUBLE == jdbcType) return SqlDbType.Float; - if(Types.FLOAT == jdbcType) return SqlDbType.Float; - if(Types.INTEGER == jdbcType) return SqlDbType.Int; - // Types.JAVA_OBJECT - if(Types.LONGVARBINARY == jdbcType) return SqlDbType.Image; - if(Types.LONGVARCHAR == jdbcType) return SqlDbType.Text; - // Types.NULL - if(Types.NUMERIC == jdbcType) return SqlDbType.Decimal; - if(Types.REAL == jdbcType) return SqlDbType.Real; - // Types.REF - if(Types.SMALLINT == jdbcType) return SqlDbType.SmallInt; - // Types.STRUCT - if(Types.TIME == jdbcType) return SqlDbType.DateTime; - if(Types.TIMESTAMP == jdbcType) return SqlDbType.DateTime; - if(Types.TINYINT == jdbcType) return SqlDbType.TinyInt; - if(Types.VARBINARY == jdbcType) return SqlDbType.VarBinary; - if(Types.VARCHAR == jdbcType) return SqlDbType.NVarChar; - return SqlDbType.Variant; - } - - internal static SqlDbType ValueTypeToSqlDbType(Type type) - { - switch (Type.GetTypeCode(type)) { - case TypeCode.Boolean: return SqlDbType.Bit; - case TypeCode.Byte: return SqlDbType.TinyInt; - case TypeCode.Char: return SqlDbType.Char; - case TypeCode.DateTime: return SqlDbType.DateTime; - case TypeCode.DBNull: return SqlDbType.Variant; - case TypeCode.Decimal: return SqlDbType.Decimal; - case TypeCode.Double: return SqlDbType.Float; - case TypeCode.Empty: return SqlDbType.Variant; - case TypeCode.Int16: return SqlDbType.SmallInt; - case TypeCode.Int32: return SqlDbType.Int; - case TypeCode.Int64: return SqlDbType.BigInt; - default: - case TypeCode.Object: { - if (type.Equals(DbTypes.TypeOfByteArray)) return SqlDbType.VarBinary; - //if (type.Equals(DbTypes.TypeOfTimespan)) return OleDbType.DBTime; - if (type.Equals(DbTypes.TypeOfGuid)) return SqlDbType.UniqueIdentifier; - - if (type.IsEnum) - return ValueTypeToSqlDbType (Enum.GetUnderlyingType (type)); - - return SqlDbType.Variant; - } - case TypeCode.SByte: return SqlDbType.TinyInt; - case TypeCode.Single: return SqlDbType.Float; - case TypeCode.String: return SqlDbType.NVarChar; - case TypeCode.UInt16: return SqlDbType.SmallInt; - case TypeCode.UInt32: return SqlDbType.Int; - case TypeCode.UInt64: return SqlDbType.BigInt; - } - } - - internal static Type SqlDbTypeToValueType(SqlDbType sqlDbType) - { - switch (sqlDbType) { - case SqlDbType.BigInt : return typeof(long); - case SqlDbType.Binary : return typeof(byte[]); - case SqlDbType.Bit : return typeof(bool); - case SqlDbType.Char : return typeof(string); - case SqlDbType.DateTime : return typeof(DateTime); - case SqlDbType.Decimal : return typeof(decimal); - case SqlDbType.Float : return typeof(double); - case SqlDbType.Image : return typeof(byte[]); - case SqlDbType.Int : return typeof(int); - case SqlDbType.Money : return typeof(decimal); - case SqlDbType.NChar : return typeof(string); - case SqlDbType.NText : return typeof(string); - case SqlDbType.NVarChar : return typeof(string); - case SqlDbType.Real : return typeof(Single); - case SqlDbType.UniqueIdentifier : return typeof(Guid); - case SqlDbType.SmallDateTime : return typeof(DateTime); - case SqlDbType.SmallInt : return typeof(Int16); - case SqlDbType.SmallMoney : return typeof(decimal); - case SqlDbType.Text : return typeof(string); - case SqlDbType.Timestamp : return typeof(byte[]); - case SqlDbType.TinyInt : return typeof(byte); - case SqlDbType.VarBinary : return typeof(byte[]); - case SqlDbType.VarChar : return typeof(string); - case SqlDbType.Variant : return typeof(object); - default : throw ExceptionHelper.InvalidSqlDbType((int)sqlDbType); - } - } - - internal static SqlDbType DbTypeToSqlDbType(DbType dbType) - { - switch (dbType) { - case DbType.AnsiString : return SqlDbType.VarChar; - case DbType.Binary : return SqlDbType.VarBinary; - case DbType.Byte : return SqlDbType.TinyInt; - case DbType.Boolean : return SqlDbType.Bit; - case DbType.Currency : return SqlDbType.Money; - case DbType.Date : return SqlDbType.DateTime; - case DbType.DateTime : return SqlDbType.DateTime; - case DbType.Decimal : return SqlDbType.Decimal; - case DbType.Double : return SqlDbType.Float; - case DbType.Guid : return SqlDbType.UniqueIdentifier; - case DbType.Int16 : return SqlDbType.SmallInt; - case DbType.Int32 : return SqlDbType.Int; - case DbType.Int64 : return SqlDbType.BigInt; - case DbType.Object : return SqlDbType.Variant; - case DbType.SByte : throw ExceptionHelper.UnknownDataType(dbType.ToString(),"SqlDbType"); - case DbType.Single : return SqlDbType.Real; - case DbType.String : return SqlDbType.NVarChar; - case DbType.UInt16 : throw ExceptionHelper.UnknownDataType(dbType.ToString(),"SqlDbType"); - case DbType.UInt32 : throw ExceptionHelper.UnknownDataType(dbType.ToString(),"SqlDbType"); - case DbType.UInt64 : throw ExceptionHelper.UnknownDataType(dbType.ToString(),"SqlDbType"); - case DbType.VarNumeric : throw ExceptionHelper.UnknownDataType(dbType.ToString(),"SqlDbType"); - case DbType.AnsiStringFixedLength : return SqlDbType.Char; - case DbType.StringFixedLength : return SqlDbType.NChar; - default : throw ExceptionHelper.InvalidDbType((int)dbType); - } - } - - internal static DbType SqlDbTypeToDbType(SqlDbType sqlDbType) - { - switch (sqlDbType) { - case SqlDbType.BigInt : return DbType.Int64; - case SqlDbType.Binary : return DbType.Binary; - case SqlDbType.Bit : return DbType.Boolean; - case SqlDbType.Char : return DbType.AnsiStringFixedLength; - case SqlDbType.DateTime : return DbType.DateTime; - case SqlDbType.Decimal : return DbType.Decimal; - case SqlDbType.Float : return DbType.Double; - case SqlDbType.Image : return DbType.Binary; - case SqlDbType.Int : return DbType.Int32; - case SqlDbType.Money : return DbType.Currency; - case SqlDbType.NChar : return DbType.StringFixedLength; - case SqlDbType.NText : return DbType.String; - case SqlDbType.NVarChar : return DbType.String; - case SqlDbType.Real : return DbType.Single; - case SqlDbType.UniqueIdentifier : return DbType.Guid; - case SqlDbType.SmallDateTime : return DbType.DateTime; - case SqlDbType.SmallInt : return DbType.Int16; - case SqlDbType.SmallMoney : return DbType.Currency; - case SqlDbType.Text : return DbType.AnsiString; - case SqlDbType.Timestamp : return DbType.Binary; - case SqlDbType.TinyInt : return DbType.Byte; - case SqlDbType.VarBinary : return DbType.Binary; - case SqlDbType.VarChar : return DbType.AnsiString; - case SqlDbType.Variant : return DbType.Object; - default : throw ExceptionHelper.InvalidSqlDbType((int)sqlDbType); - } - } - - internal static int SqlDbTypeToJdbcType(SqlDbType sqlDbType) - { - switch(sqlDbType) { - case SqlDbType.BigInt : return Types.BIGINT; - case SqlDbType.Binary : return Types.BINARY; - case SqlDbType.Bit : return Types.BIT; - case SqlDbType.Char : return Types.CHAR; - case SqlDbType.DateTime : return Types.TIMESTAMP; - case SqlDbType.Decimal : return Types.DECIMAL; - case SqlDbType.Float : return Types.FLOAT; - case SqlDbType.Image : return Types.LONGVARBINARY; - case SqlDbType.Int : return Types.INTEGER; - case SqlDbType.Money : return Types.DECIMAL; - case SqlDbType.NChar : return Types.CHAR; - case SqlDbType.NText : return Types.LONGVARCHAR; - case SqlDbType.NVarChar : return Types.VARCHAR; - case SqlDbType.Real : return Types.REAL; - case SqlDbType.UniqueIdentifier : return Types.CHAR; - case SqlDbType.SmallDateTime : return Types.DATE; - case SqlDbType.SmallInt : return Types.SMALLINT; - case SqlDbType.SmallMoney : return Types.DECIMAL; - case SqlDbType.Text : return Types.LONGVARCHAR; - case SqlDbType.Timestamp : return Types.TIMESTAMP; - case SqlDbType.TinyInt : return Types.TINYINT; - case SqlDbType.VarBinary : return Types.VARBINARY; - case SqlDbType.VarChar : return Types.VARCHAR; - case SqlDbType.Variant : return Types.VARCHAR; // note : ms jdbc driver recognize this sqlserver as varchar - default : throw ExceptionHelper.InvalidSqlDbType((int)sqlDbType); - } - } - - #endregion // Methods - } -} diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlDataReader.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlDataReader.cs deleted file mode 100644 index 83dedecd0c4..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlDataReader.cs +++ /dev/null @@ -1,335 +0,0 @@ -// -// System.Data.SqlClient.SqlDataReader -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Data.SqlTypes; -using System.Data.ProviderBase; - -using java.sql; - -namespace System.Data.SqlClient -{ - public class SqlDataReader : AbstractDataReader - { - - #region Constructors - - internal SqlDataReader(SqlCommand command) : base(command) - { - } - - #endregion // Constructors - - #region Properties - - #endregion // Properties - - #region Methods - - protected sealed override SystemException CreateException(string message, SQLException e) - { - return new SqlException(message, e, (SqlConnection)_command.Connection); - } - - protected sealed override SystemException CreateException(java.io.IOException e) - { - return new SqlException(e, (SqlConnection)_command.Connection); - } - - public override String GetDataTypeName(int columnIndex) - { - try { - string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1); - - return SqlConvert.JdbcTypeNameToDbTypeName(jdbcTypeName); - } - catch (SQLException e) { - throw CreateException(e); - } - } - - protected override int GetProviderType(int jdbcType) - { - return (int)SqlConvert.JdbcTypeToSqlDbType(jdbcType); - } - - // Gets the value of the specified column as a SqlBinary. - public SqlBinary GetSqlBinary(int columnIndex) - { - byte[] bytes = GetBytes(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlBinary.Null; - } - else { - return new SqlBinary(bytes); - } - } - - // Gets the value of the specified column as a SqlBoolean. - public SqlBoolean GetSqlBoolean(int columnIndex) - { - bool boolean = GetBoolean(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlBoolean.Null; - } - else { - return new SqlBoolean(boolean); - } - } - - // Gets the value of the specified column as a SqlByte. - public SqlByte GetSqlByte(int columnIndex) - { - byte byt = GetByte(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlByte.Null; - } - else { - return new SqlByte(byt); - } - } - -#if NET_2_0 - - public virtual SqlBytes GetSqlBytes (int columnIndex) - { - byte [] bytes = GetBytes (columnIndex); - if (IsDBNull (columnIndex)) { - return SqlBytes.Null; - } - else { - return new SqlBytes (bytes); - } - } - - public virtual SqlChars GetSqlChars (int columnIndex) - { - SqlString sqlStr = GetSqlString (columnIndex); - if (sqlStr.IsNull) { - return SqlChars.Null; - } - else { - return new SqlChars (sqlStr); - } - } - - [MonoNotSupported("SqlXml is not fully implemented")] - public virtual SqlXml GetSqlXml (int columnIndex) - { - throw new NotImplementedException (); - } - -#endif - - // Gets the value of the specified column as a SqlDecimal. - public SqlDecimal GetSqlDecimal(int columnIndex) - { - decimal dec = GetDecimal(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlDecimal.Null; - } - else { - return new SqlDecimal(dec); - } - } - - // Gets the value of the specified column as a SqlDateTime. - public SqlDateTime GetSqlDateTime(int columnIndex) - { - DateTime dateTime = GetDateTime(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlDateTime.Null; - } - else { - return new SqlDateTime(dateTime); - } - } - - // Gets the value of the specified column as a SqlDouble. - public SqlDouble GetSqlDouble(int columnIndex) - { - double doubl = GetDouble(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlDouble.Null; - } - else { - return new SqlDouble(doubl); - } - } - - // Gets the value of the specified column as a SqlInt16. - public SqlInt16 GetSqlInt16(int columnIndex) - { - short s = GetInt16(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlInt16.Null; - } - else { - return new SqlInt16(s); - } - } - - // Gets the value of the specified column as a SqlInt32. - public SqlInt32 GetSqlInt32(int columnIndex) - { - int i = GetInt32(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlInt32.Null; - } - else { - return new SqlInt32(i); - } - } - - // Gets the value of the specified column as a SqlInt64. - public SqlInt64 GetSqlInt64(int columnIndex) - { - long l = GetInt64(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlInt64.Null; - } - else { - return new SqlInt64(l); - } - } - - // Gets the value of the specified column as a SqlMoney. - public SqlMoney GetSqlMoney(int columnIndex) - { - decimal dec = GetDecimal(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlMoney.Null; - } - else { - return new SqlMoney(dec); - } - } - - // Gets the value of the specified column as a SqlSingle. - public SqlSingle GetSqlSingle(int columnIndex) - { - float f = GetFloat(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlSingle.Null; - } - else { - return new SqlSingle(f); - } - } - - // Gets the value of the specified column as a SqlString. - public SqlString GetSqlString(int columnIndex) - { - string str = GetString(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlString.Null; - } - else { - return new SqlString(str); - } - } - - // Gets the value of the specified column as a SqlGuid. - public SqlGuid GetSqlGuid(int columnIndex) - { - object obj = GetValue(columnIndex); - if(IsDBNull(columnIndex)) { - return SqlGuid.Null; - } - else { - if (obj is byte[]) { - return new SqlGuid((byte[])obj); - } - else { - return new SqlGuid((string)obj); - } - } - } - - // Gets all the attribute columns in the current row. - public int GetSqlValues(Object[] values) - { - int columnCount = FieldCount; - int i = 0; - for (; i < values.Length && i < columnCount; i++) { - values[i] = GetSqlValue(i); - } - return i; - } - - // Gets an Object that is a representation of the underlying SqlDbType Variant. - public Object GetSqlValue(int columnIndex) - { - try { - int jdbcType = ResultsMetaData.getColumnType(columnIndex + 1); - SqlDbType sqlDbType = SqlConvert.JdbcTypeToSqlDbType(jdbcType); - - switch (sqlDbType) { - case SqlDbType.BigInt : return GetSqlInt64(columnIndex); - case SqlDbType.Binary : return GetSqlBinary(columnIndex); - case SqlDbType.Bit : return GetSqlBoolean(columnIndex); - case SqlDbType.Char : return GetSqlString(columnIndex); - case SqlDbType.DateTime : return GetSqlDateTime(columnIndex); - case SqlDbType.Decimal : return GetSqlDecimal(columnIndex); - case SqlDbType.Float : return GetSqlDouble(columnIndex); - case SqlDbType.Image : return GetSqlBinary(columnIndex); - case SqlDbType.Int : return GetSqlInt32(columnIndex); - case SqlDbType.Money : return GetSqlDecimal(columnIndex); - case SqlDbType.NChar : return GetSqlString(columnIndex); - case SqlDbType.NText : return GetSqlString(columnIndex); - case SqlDbType.NVarChar : return GetSqlString(columnIndex); - case SqlDbType.Real : return GetSqlSingle(columnIndex); - case SqlDbType.UniqueIdentifier : return GetSqlGuid(columnIndex); - case SqlDbType.SmallDateTime : return GetSqlDateTime(columnIndex); - case SqlDbType.SmallInt : return GetSqlInt16(columnIndex); - case SqlDbType.SmallMoney : return GetSqlDecimal(columnIndex); - case SqlDbType.Text : return GetSqlString(columnIndex); - case SqlDbType.Timestamp : return GetSqlDateTime(columnIndex); - case SqlDbType.TinyInt : return GetSqlByte(columnIndex); - case SqlDbType.VarBinary : return GetSqlBinary(columnIndex); - case SqlDbType.VarChar : return GetSqlString(columnIndex); - case SqlDbType.Variant : return GetValue(columnIndex); - default : return GetValue(columnIndex); - } - } - catch (SQLException exp) { - throw new Exception(exp.Message); - } - } - -#if NET_2_0 - protected bool IsCommandBehavior (CommandBehavior condition) - { - return (_command.Behavior & condition) == condition; - } -#endif - #endregion // Methods - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlError.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlError.cs deleted file mode 100644 index 7099ebca0dd..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlError.cs +++ /dev/null @@ -1,173 +0,0 @@ -// -// System.Data.SqlClient.SqlError -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace System.Data.SqlClient -{ - using System.Data.ProviderBase; - using java.sql; - using System.Data.Common; - - /** - * Collects information relevant to a warning or error returned by SQL Server. - */ - - [Serializable] - public class SqlError : AbstractDbError - { - string _serverVersion; - /** - * Initialize SqlError object - * */ - internal SqlError(SQLException e, AbstractDBConnection connection) : base(e, connection) - { - if (connection != null) - _serverVersion = connection.ServerVersion; - } - - /** - * Overridden. Gets the complete text of the error message. - * - * @return A string representation of the current object. - */ - public override String ToString() - { - return String.Concat("SqlError:", Message, _e.StackTrace); - } - - /** - * Gets the name of the provider that generated the error. - * - * @return The name of the provider - */ - public String Source - { - get - { - return DbSource; - } - } - - /** - * Gets a number that identifies the type of error. - * - * @return Number of the error - */ - public int Number - { - get - { - return DbErrorCode; - } - } - - /** - * Gets a numeric error code from SQL Server that represents an error, - * warning or "no data found" message. For more information on how to - * decode these values, see SQL Server Books Online. - * - * @return Error Code - */ - public byte State - { - get - { - return 0; // & BitConstants.ALL_BYTE; - } - } - - /** - * Gets the severity level of the error returned from SQL Server. - * - * @return Severity level of the error - */ - public byte Class - { - get - { - return 0; // & BitConstants.ALL_BYTE; - } - } - - /** - * Gets the name of the instance of SQL Server that generated the error. - * - * @return The name of the server - */ - public String Server - { - get - { - return _serverVersion; - } - } - - /** - * Gets the text describing the error. - * - * @return The text describing the error - */ - public String Message - { - get - { - return DbMessage; - } - } - - /** - * Gets the name of the stored procedure or remote procedure call (RPC) - * that generated the error. - * - * @return The name of stored procedure that generated the error. - */ - public String Procedure - { - get - { - return null; - } - } - - /** - * Bets the line number within the Transact-SQL command batch or stored - * procedure that contains the error. - * - * @return Line number of error in stored procedure - */ - public int LineNumber - { - get - { - return 0; - } - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlErrorCollection.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlErrorCollection.cs deleted file mode 100644 index 68c5651f070..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlErrorCollection.cs +++ /dev/null @@ -1,77 +0,0 @@ -// -// System.Data.SqlClient.SqlErrorCollection -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace System.Data.SqlClient -{ - - /** - * Collects all errors generated by the SQL .NET Data Provider. - */ - - using System.Collections; - using System.Data.Common; - using System.Data.ProviderBase; - using java.sql; - - - [Serializable] - public class SqlErrorCollection : AbstractDbErrorCollection - { - internal SqlErrorCollection(SQLException e, AbstractDBConnection connection) : base(e, connection) {} - /** - * Gets the error at the specified index. - * - * @param index of the error - * @return Error on specified index - */ - public SqlError this[int index] - { - get - { - return (SqlError)GetDbItem(index); - } - } - -#if NET_2_0 - public void CopyTo (SqlError [] array, int index) - { - base.CopyTo (array, index); - } - -#endif - - protected override AbstractDbError CreateDbError(java.sql.SQLException e, AbstractDBConnection connection) { - return new SqlError(e, connection); - } - - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlException.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlException.cs deleted file mode 100644 index a197c3fd926..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlException.cs +++ /dev/null @@ -1,165 +0,0 @@ -// -// System.Data.SqlClient.SqlException -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace System.Data.SqlClient -{ - - using java.sql; - - using System; - using System.Data.ProviderBase; - - /** - * The exception that is thrown when SQL Server returns a warning or error. - * This class cannot be inherited. - */ - - /* - * CURRENT LIMITATIONS - * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc) - * is not supported. - * 2. Method "void GetObjectData(...,...)" is not supported (serialization) - */ - - public sealed class SqlException : AbstractDbException - { - internal SqlException(Exception cause, SqlConnection connection) : base(cause, connection) {} - - internal SqlException(SQLException cause, SqlConnection connection) : base(cause, connection) {} - - internal SqlException(string message, SQLException cause, SqlConnection connection) : base(message, cause, connection) {} - - protected override AbstractDbErrorCollection DbErrors { - get { - return Errors; - } - } - - - - /** - * Gets the severity level of the error returned from the SQL Server .NET - * Data Provider. - * @return severity level of the first error in the collection. - */ - public byte Class - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].Class : (byte)0; - } - } - - /** - * Gets a collection of one or more SqlError objects that give detailed - * information about exceptions generated by the SQL Server .NET Data Provider. - * @return collection of SqlError objects - */ - public SqlErrorCollection Errors - { - get - { - return new SqlErrorCollection(_cause, _connection); - } - } - - /** - * Gets the line number within the Transact-SQL command batch or stored - * procedure that generated the error. - * @return line number of the first error in the collection. - */ - public int LineNumber - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].LineNumber : 0; - } - } - - /** - * Gets a number that identifies the type of error. - * @return number that identifies the type of first error in the collection - */ - public int Number - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].Number : 0; - } - } - - /** - * Gets the name of the stored procedure or remote procedure call (RPC) - * that generated the error. - * @return name of the stored procedure - */ - public String Procedure - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].Procedure : null; - } - } - - /** - * Gets the name of the computer running an instance of SQL Server - * that generated the error. - * @return name of the computer where error generated - */ - public String Server - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].Server : null; - } - } - - - /** - * Gets a numeric error code from SQL Server that represents an error, - * warning or "no data found" message. - * @return numeric error code from SQL Server - */ - public byte State - { - get - { - SqlErrorCollection errors = Errors; - return errors.Count > 0 ? errors[0].State : (byte)0; - } - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlParameter.cs b/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlParameter.cs deleted file mode 100644 index 9315e7d4c89..00000000000 --- a/mcs/class/System.Data/System.Data.SqlClient.jvm/SqlParameter.cs +++ /dev/null @@ -1,270 +0,0 @@ -// -// System.Data.SqlClient.SqlParameter -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.Data; -using System.Data.ProviderBase; -using System.Data.Common; - -using java.sql; - -namespace System.Data.SqlClient -{ - public sealed class SqlParameter : AbstractDbParameter - { - #region Fields - - private SqlDbType _sqlDbType; - - #endregion // Fields - - #region Constructors - - public SqlParameter() - { - } - - public SqlParameter(String parameterName, Object value) - : this(parameterName, SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, value,false) - { - } - - public SqlParameter(String parameterName, SqlDbType dbType) - : this(parameterName, dbType, 0, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null, true) - { - } - - - public SqlParameter(String parameterName, SqlDbType dbType, int size) - : this(parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, String.Empty, DataRowVersion.Current, null, true) - { - } - - - public SqlParameter(String parameterName, SqlDbType dbType, int size, String sourceColumn) - : this(parameterName, dbType, size, ParameterDirection.Input, false, 0, 0, sourceColumn, DataRowVersion.Current, null, true) - { - } - - - public SqlParameter( - String parameterName, - SqlDbType dbType, - int size, - ParameterDirection direction, - bool isNullable, - byte precision, - byte scale, - String sourceColumn, - DataRowVersion sourceVersion, - Object value) : this(parameterName,dbType,size,direction,isNullable,precision,scale,sourceColumn,sourceVersion,value,true) - { - } - -#if NET_2_0 - public SqlParameter ( - string parameterName, - SqlDbType dbType, - int size, - ParameterDirection direction, - byte precision, - byte scale, - string sourceColumn, - DataRowVersion sourceVersion, - bool sourceColumnNullMapping, - Object value, - string xmlSchemaCollectionDatabase, - string xmlSchemaCollectionOwningSchema, - string xmlSchemaCollectionName - ) : this (parameterName, dbType, size, direction, sourceColumnNullMapping, precision, scale, sourceColumn, sourceVersion, value, true) - { - } -#endif - - SqlParameter( - String parameterName, - SqlDbType dbType, - int size, - ParameterDirection direction, - bool isNullable, - byte precision, - byte scale, - String sourceColumn, - DataRowVersion sourceVersion, - Object value, - bool dbTypeExplicit) - { - ParameterName = parameterName; - SqlDbType = dbType; - Size = size; - Direction = direction; - IsNullable = isNullable; - Precision = precision; - Scale = scale; - SourceColumn = sourceColumn; - SourceVersion = sourceVersion; - if (!dbTypeExplicit) { - IsDbTypeSet = false; - } - Value = value; - } - - #endregion // Constructors - - #region Properties - - public override DbType DbType - { - get { return SqlConvert.SqlDbTypeToDbType(_sqlDbType); } - set { SqlDbType = SqlConvert.DbTypeToSqlDbType(value); } - } - - public SqlDbType SqlDbType - { - get { return _sqlDbType; } - set { - _sqlDbType = value; - IsDbTypeSet = true; - } - } - - public override int Size - { - get { - int retVal = base.Size; - return retVal; - } - set { - if (value < 0) { - throw ExceptionHelper.InvalidSizeValue(value); - } - - if (value != 0) { - base.Size = value; - } - else { - base.Size = -1; - } - } - } - -#if NET_2_0 - public new byte Precision - { - get { return base.Precision; } - set { base.Precision = value; } - } - - public new byte Scale - { - get { return base.Scale; } - set { base.Scale = value; } - } -#endif - - protected internal override string Placeholder { - get { - if (ParameterName.Length == 0 || ParameterName[0] == '@') - return ParameterName; - - return String.Concat("@", ParameterName); - } - } - - - public override Object Value - { - get { return base.Value; } - set { - if (!IsDbTypeSet && (value != null) && (value != DBNull.Value)) { - _sqlDbType = SqlConvert.ValueTypeToSqlDbType(value.GetType()); - } - base.Value = value; - } - } - - #endregion // Properties - - #region Methods - - protected internal sealed override object ConvertValue(object value) - { - // can not convert null or DbNull to other types - if (value == null || value == DBNull.Value) { - return value; - } - // .NET throws an exception to the user. - object convertedValue = value is IConvertible ? Convert.ChangeType(value,SqlConvert.SqlDbTypeToValueType(SqlDbType)) : value; - return convertedValue; - } - - protected internal sealed override void SetParameterName(ResultSet res) - { - string name = res.getString("COLUMN_NAME"); - if (name != null && name.Length > 0 && name[0] != '@') - name = String.Concat("@", name); - ParameterName = name; - } - - protected internal sealed override void SetParameterDbType(ResultSet res) - { - int dataType = res.getInt("DATA_TYPE"); - SqlDbType = SqlConvert.JdbcTypeToSqlDbType(dataType); - JdbcType = dataType; - } - -#if NET_2_0 - public void ResetSqlDbType () - { - IsDbTypeSet = false; - } - - public override void ResetDbType () - { - ResetSqlDbType (); - } -#endif - - protected internal sealed override void SetSpecialFeatures (ResultSet res) - { - // do nothing - } - - protected internal sealed override int JdbcTypeFromProviderType() - { - return SqlConvert.SqlDbTypeToJdbcType(SqlDbType); - } - - #endregion // Methods - - } -} diff --git a/mcs/class/System.Data/System.Data.SqlTypes.jvm/SqlDecimal.cs b/mcs/class/System.Data/System.Data.SqlTypes.jvm/SqlDecimal.cs deleted file mode 100644 index aeae5ea3c34..00000000000 --- a/mcs/class/System.Data/System.Data.SqlTypes.jvm/SqlDecimal.cs +++ /dev/null @@ -1,897 +0,0 @@ -// System.Data.SqlTypes.SqlDecimal -// -// Authors: -// Konstantin Triger -// Boris Kirzner -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace System.Data.SqlTypes -{ - - /** - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2002

- *

Company: MainSoft

- * @author Pavel Sandler - * @version 1.0 - */ - - using System; - - using java.math; - - /* - * CURRENT LIMITATIONS: - * 1. public byte[] Data not implemented. - * 2. public byte[] BinData not implemented. - * 3. Precision value is ignored. - * 4. public SqlDecimal AdjustScale(SqlDecimal n, int position) not implemented. - * 5. public SqlDecimal ConvertToPrecScale(SqlDecimal n, int precision, int scale) not implemented. - */ - - - public struct SqlDecimal : INullable - { - - private Decimal _value; - private bool _isNull; - - public static readonly SqlDecimal MaxValue = new SqlDecimal(Decimal.MaxValue); - public static readonly SqlDecimal MinValue = new SqlDecimal(Decimal.MinValue); - public static readonly int MaxPrecision = 38; - public static readonly int MaxScale = MaxPrecision; - public static readonly SqlDecimal Null = new SqlDecimal(true); - - private int _precision; - private int _scale; - - - private SqlDecimal(bool isNull) - { - _value = Decimal.Zero; - _isNull = isNull; - _precision = 38; - _scale = 0; - } - /** - * Initializes a new instance of the SqlDecimal instance using the supplied Decimal value. - * @param value The Decimal value to be stored as a SqlDecimal instance. - */ - public SqlDecimal(Decimal value) - { - _value = value; - _isNull = false; - int[] bits = Decimal.GetBits(value); - int i = bits[3] & 0xff0000; - _scale = i >> 16; - _precision = 38; - } - - /** - * Initializes a new instance of the SqlDecimal instance using the supplied double value. - * @param value The double value to be stored as a SqlDecimal instance. - */ - public SqlDecimal(double value) - { - _value = new Decimal(value); - _isNull = false; - int[] bits = Decimal.GetBits(_value); - int i = bits[3] & 0xff0000; - _scale = i >> 16; - _precision = 38; - } - - /** - * Initializes a new instance of the SqlDecimal instance using the supplied int value. - * @param value The int value to be stored as a SqlDecimal instance. - */ - public SqlDecimal(int value) - { - _value = new Decimal(value); - _isNull = false; - int[] bits = Decimal.GetBits(_value); - int i = bits[3] & 0xff0000; - _scale = i >> 16; - _precision = 38; - } - - /** - * Initializes a new instance of the SqlDecimal instance using the supplied long value. - * @param value The long value to be stored as a SqlDecimal instance. - */ - public SqlDecimal(long value) - { - _value = new Decimal(value); - _isNull = false; - int[] bits = Decimal.GetBits(_value); - int i = bits[3] & 0xff0000; - _scale = i >> 16; - _precision = 38; - } - - - /** - * Indicates whether or not Value is null. - * @return true if Value is null, otherwise false. - */ - public bool IsNull - { - get - { - return _isNull; - } - } - - /** - * Gets the value of the SqlDecimal instance. - * @return the value of this instance - */ - public Decimal Value - { - get - { - if(IsNull) - throw new SqlNullValueException(); - return _value; - } - } - - public byte[] BinData - { - get - { - /** @todo implement this method */ - throw new NotImplementedException(); - } - } - - public byte[] Data - { - get - { - /** @todo implement this method */ - throw new NotImplementedException(); - } - } - - /** - * Indicates whether or not the Value of this SqlDecimal instance is greater than zero. - * @return true if the Value is assigned to null, otherwise false. - */ - public bool IsPositive - { - get - { - if (!IsNull) - { - if (_value >= 0) - return true; - - return false; - } - - throw new SqlNullValueException("The value of this instance is null"); - } - } - - /** - * Gets the maximum number of digits used to represent the Value property. - * @return The maximum number of digits used to represent the Value of this SqlDecimal instance. - */ - public int Precision - { - get - { - return _precision; - } - } - - /** - * Gets the number of decimal places to which Value is resolved. - * @return The number of decimal places to which the Value property is resolved. - */ - public int Scale - { - get - { - return _precision; - } - } - - /** - * The Abs member function gets the absolute value of the SqlDecimal parameter. - * @param n A SqlDecimal instance. - * @return A SqlDecimal instance whose Value property contains the unsigned number representing the absolute value of the SqlDecimal parameter. - */ - public static SqlDecimal Abs(SqlDecimal n) - { - if (n.IsNull) - return new SqlDecimal(); - - Decimal val; - - if (n.IsPositive) - val = n.Value; - else - val = Decimal.Negate(n._value); - - return new SqlDecimal(val); - - } - - /** - * Calcuates the sum of the two SqlDecimal operators. - * @param x A SqlDecimal instance. - * @param y A SqlDecimal instance. - * @return A new SqlDecimal instance whose Value property contains the sum. - * If one of the parameters or their value is null return SqlDecimal.Null. - */ - public static SqlDecimal Add(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlDecimal.Null; - - Decimal res = Decimal.Add(x._value, y._value); - - return new SqlDecimal(res); - } - - public static SqlDecimal AdjustScale(SqlDecimal n, int digits, bool fround) - { - /** @todo find out what the logic */ - throw new NotImplementedException(); - } - - /** - * Returns the smallest whole number greater than or equal to the specified SqlDecimal instance. - * @param n The SqlDecimal instance for which the ceiling value is to be calculated. - * @return A SqlDecimal representing the smallest whole number greater than or equal to the specified SqlDecimal instance. - */ - public static SqlDecimal Ceiling(SqlDecimal n) - { - if (n.IsNull) - return SqlDecimal.Null; - - double d = Math.Ceiling((double)n._value); - return new SqlDecimal(d); - } - - /** - * Compares this instance to the supplied object and returns an indication of their relative values. - * @param obj The object to compare. - * @return A signed number indicating the relative values of the instance and the object. - * Less than zero This instance is less than object. - * Zero This instance is the same as object. - * Greater than zero This instance is greater than object -or- - * object is a null reference. - */ - public int CompareTo(Object obj) - { - if (obj == null) - return 1; - - if (obj is SqlDecimal) - { - SqlDecimal value = (SqlDecimal)obj; - - if (IsNull) - return -1; - - if (value.IsNull) - return 1; - - if (_value == value._value) - return 0; - - return Decimal.Compare(_value, value._value); - } - - throw new ArgumentException("parameter obj is not SqlDecimal : " + obj.GetType().Name); - - - } - - - public SqlDecimal ConvertToPrecScale(SqlDecimal n, int precision, int scale) - { - /** @todo find out what the logic */ - throw new NotImplementedException(); - } - - /** - * The division operator divides the first SqlDecimal operand by the second. - * @param x A SqlDecimal instance. - * @param y A SqlDecimal instance. - * @return A SqlDecimal instance containing the results of the division operation. - * If one of the parameters is null or null value - return SqlDouble.Null. - */ - public static SqlDecimal Divide(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlDecimal.Null; - - Decimal res = Decimal.Divide(x._value, y._value); - - return new SqlDecimal(res); - } - - public override bool Equals(Object obj) - { - if (obj == null) - return false; - - if (obj is SqlDecimal) - { - SqlDecimal dec = (SqlDecimal)obj; - - return Decimal.Equals(_value, dec._value); - } - - return false; - } - - - /** - * Performs a logical comparison on two instances of SqlDecimal to determine if they are equal. - * @param x A SqlDecimal instance. - * @param y A SqlDecimal instance. - * @return true if the two values are equal, otherwise false. - * If one of the parameters is null or null value return SqlBoolean.Null. - */ - public static SqlBoolean Equals(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - if (x.Equals(y)) - return SqlBoolean.True; - - return SqlBoolean.False; - } - - /** - * Rounds a specified SqlDecimal number to the next lower whole number. - * @param n The SqlDecimal instance for which the floor value is to be calculated. - * @return A SqlDecimal instance containing the whole number portion of this SqlDecimal instance. - */ - public static SqlDecimal Floor(SqlDecimal n) - { - Decimal res = Decimal.Floor(n._value); - - return new SqlDecimal(res); - } - - /** - * Compares two instances of SqlDecimal to determine if the first is greater than the second. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return A SqlBoolean that is True if the first instance is greater than the second instance, otherwise False. - * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null. - */ - public static SqlBoolean GreaterThan(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - if (x.CompareTo(y) > 0) - return SqlBoolean.True; - - return SqlBoolean.False; - } - - /** - * Compares two instances of SqlDecimal to determine if the first is greater than or equal to the second. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return A SqlBoolean that is True if the first instance is greaater than or equal to the second instance, otherwise False. - * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null. - */ - public static SqlBoolean GreaterThanOrEqual(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - if (x.CompareTo(y) >= 0) - return SqlBoolean.True; - - return SqlBoolean.False; - } - - /** - * Compares two instances of SqlDecimal to determine if the first is less than the second. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False. - * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null. - */ - public static SqlBoolean LessThan(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - if (x.CompareTo(y) < 0) - return SqlBoolean.True; - - return SqlBoolean.False; - } - - /** - * Compares two instances of SqlDecimal to determine if the first is less than the second. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return A SqlBoolean that is True if the first instance is less than the second instance, otherwise False. - * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null. - */ - public static SqlBoolean LessThanOrEqual(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - if (x.CompareTo(y) <= 0) - return SqlBoolean.True; - - return SqlBoolean.False; - } - - /** - * The multiplication operator computes the product of the two SqlDecimal operands. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return The product of the two SqlDecimal operands. - */ - public static SqlDecimal Multiply(SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlDecimal.Null; - - Decimal res = Decimal.Multiply(x._value, y._value); - - return new SqlDecimal(res); - } - - /** - * Compares two instances of SqlDecimal to determine if they are equal. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return A SqlBoolean that is True if the two instances are not equal or False if the two instances are equal. - * If either instance of SqlDouble is null, the Value of the SqlBoolean will be Null. - */ - public static SqlBoolean NotEquals(SqlDecimal x, SqlDecimal y) - { - SqlBoolean eVal = Equals(x, y); - - if (eVal.IsNull) - return eVal; - if (eVal.IsTrue) - return SqlBoolean.False; - - return SqlBoolean.True; - } - - /** - * Converts the String representation of a number to its Decimal number equivalent. - * @param s The String to be parsed. - * @return A SqlDecimal containing the value represented by the String. - */ - public static SqlDecimal Parse(String s) - { - Decimal val = Decimal.Parse(s); - SqlDecimal retVal = new SqlDecimal(val); - - if (GreaterThan(retVal, MaxValue).IsTrue || LessThan(retVal, MinValue).IsTrue) - throw new OverflowException("The parse of this string is overflowing : " + val); - - return retVal; - - } - - /** - * Raises the value of the specified SqlDecimal instance to the specified exponential power. - * @param n The SqlDecimal instance to be raised to a power. - * @param exponent A double value indicating the power to which the number should be raised. - * @return A SqlDecimal instance containing the results. - */ - public static SqlDecimal Power(SqlDecimal n, double exponent) - { - /** @todo decide if we treat the Decimal as a double and use Math.pow() */ - - double d = (double)n._value; - - d = java.lang.Math.pow(d, exponent); - - return new SqlDecimal(d); - } - - /** - * Gets the number nearest the specified SqlDecimal instance's value with the specified precision. - * @param n The SqlDecimal instance to be rounded. - * @param position The number of significant fractional digits (precision) in the return value. - * @return A SqlDecimal instance containing the results of the rounding operation. - */ - public static SqlDecimal Round(SqlDecimal n, int position) - { - Decimal val = Decimal.Round(n._value, position); - - return new SqlDecimal(val); - } - - /** - * Gets a value indicating the sign of a SqlDecimal instance's Value property. - * @param n The SqlDecimal instance whose sign is to be evaluated. - * @return A number indicating the sign of the SqlDecimal instance. - */ - public static int Sign(SqlDecimal n) - { - if (n._value < 0) - return -1; - if(n._value > 0) - return 1; - return 0; - } - - /** - * The subtraction operator the second SqlDecimal operand from the first. - * @param x A SqlDecimal instance - * @param y A SqlDecimal instance - * @return The results of the subtraction operation. - */ - public static SqlDecimal Subtract(SqlDecimal x, SqlDecimal y) - { - Decimal val = Decimal.Subtract(x._value, y._value); - SqlDecimal retVal = new SqlDecimal(val); - - return retVal; - - } - - /** - * Returns the a double equal to the contents of the Value property of this instance. - * @return The decimal representation of the Value property. - */ - public double ToDouble() - { - return Decimal.ToDouble(_value); - } - - /** - * Converts this SqlDecimal instance to SqlBoolean. - * @return A SqlBoolean instance whose Value will be True if the SqlDecimal instance's Value is non-zero, - * False if the SqlDecimal is zero - * and Null if the SqlDecimal instance is Null. - */ - public SqlBoolean ToSqlBoolean() - { - if (IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(!_value.Equals(Decimal.Zero)); - } - - /** - * Converts this SqlDecimal instance to SqlByte. - * @return A SqlByte instance whose Value equals the Value of this SqlDouble instance. - */ - public SqlByte ToSqlByte() - { - if (IsNull) - return SqlByte.Null; - - return new SqlByte(checked((byte)_value)); - } - - /** - * Converts this SqlDecimal instance to SqlDouble. - * @return A SqlDouble instance whose Value equals the Value of this SqlDecimal instance. - */ - public SqlDouble ToSqlDouble() - { - if (IsNull) - return SqlDouble.Null; - - return new SqlDouble((double)_value); - } - - /** - * Converts this SqlDouble structure to SqlInt16. - * @return A SqlInt16 structure whose Value equals the Value of this SqlDouble structure. - */ - public SqlInt16 ToSqlInt16() - { - if (IsNull) - return SqlInt16.Null; - - return new SqlInt16(checked((short)_value)); - } - - /** - * Converts this SqlDouble structure to SqlInt32. - * @return A SqlInt32 structure whose Value equals the Value of this SqlDouble structure. - */ - public SqlInt32 ToSqlInt32() - { - if (IsNull) - return SqlInt32.Null; - - return new SqlInt32(checked((int)_value)); - } - - /** - * Converts this SqlDecimal structure to SqlInt64. - * @return A SqlInt64 structure whose Value equals the Value of this SqlDecimal structure. - */ - public SqlInt64 ToSqlInt64() - { - if (IsNull) - return SqlInt64.Null; - - return new SqlInt64(checked((long)_value)); - } - - /** - * Converts this SqlDecimal instance to SqlDouble. - * @return A SqlMoney instance whose Value equals the Value of this SqlDecimal instance. - */ - public SqlMoney ToSqlMoney() - { - if (IsNull) - return SqlMoney.Null; - - return new SqlMoney(_value); - } - - /** - * Converts this SqlDecimal instance to SqlSingle. - * @return A SqlSingle instance whose Value equals the Value of this SqlDecimal instance. - */ - public SqlSingle ToSqlSingle() - { - if (IsNull) - return SqlSingle.Null; - - return new SqlSingle(checked((float)_value)); - } - - /** - * Converts this SqlDecimal structure to SqlString. - * @return A SqlString structure whose value is a string representing the date and time contained in this SqlDecimal structure. - */ - public SqlString ToSqlString() - { - return new SqlString(ToString()); - } - - - public override String ToString() - { - if (IsNull) - return "null"; - - return _value.ToString(); - } - - /** - * Truncates the specified SqlDecimal instance's value to the desired position. - * @param n The SqlDecimal instance to be truncated. - * @param position The decimal position to which the number will be truncated. - * @return Supply a negative value for the position parameter in order to truncate the value to the corresponding positon to the left of the decimal point. - */ - public static SqlDecimal Truncate(SqlDecimal n, int position) - { - if (n.IsNull) - return n; - - Decimal tmp = Decimal.Round(n._value, position); - - return new SqlDecimal(tmp); - } - - public override int GetHashCode() - { - return _value.GetHashCode(); - } - - public static SqlDecimal operator + (SqlDecimal x, SqlDecimal y) - { - if(x.IsNull || y.IsNull) - return SqlDecimal.Null; - - return new SqlDecimal(x.Value + y.Value); - } - - public static SqlDecimal operator / (SqlDecimal x, SqlDecimal y) - { - if(x.IsNull || y.IsNull) - return SqlDecimal.Null; - return new SqlDecimal (x.Value / y.Value); - } - - public static SqlBoolean operator == (SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value == y.Value); - } - - public static SqlBoolean operator > (SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value > y.Value); - } - - public static SqlBoolean operator >= (SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value >= y.Value); - } - - public static SqlBoolean operator != (SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value != y.Value); - } - - public static SqlBoolean operator < (SqlDecimal x, SqlDecimal y) - { - - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value < y.Value); - - } - - public static SqlBoolean operator <= (SqlDecimal x, SqlDecimal y) - { - if (x.IsNull || y.IsNull) - return SqlBoolean.Null; - - return new SqlBoolean(x.Value <= y.Value); - } - - public static SqlDecimal operator * (SqlDecimal x, SqlDecimal y) - { - // adjust the scale to the smaller of the two beforehand - if (x.Scale > y.Scale) - x = SqlDecimal.AdjustScale(x, y.Scale - x.Scale, true); - else if (y.Scale > x.Scale) - y = SqlDecimal.AdjustScale(y, x.Scale - y.Scale, true); - - return new SqlDecimal(x.Value * y.Value); - } - - public static SqlDecimal operator - (SqlDecimal x, SqlDecimal y) - { - if(x.IsNull || y.IsNull) - return SqlDecimal.Null; - - return new SqlDecimal(x.Value - y.Value); - } - - public static SqlDecimal operator - (SqlDecimal n) - { - if(n.IsNull) - return n; - return new SqlDecimal (Decimal.Negate(n.Value)); - } - - public static explicit operator SqlDecimal (SqlBoolean x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.ByteValue); - } - - public static explicit operator Decimal (SqlDecimal n) - { - return n.Value; - } - - public static explicit operator SqlDecimal (SqlDouble x) - { - checked - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - } - - public static explicit operator SqlDecimal (SqlSingle x) - { - checked - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - } - - public static explicit operator SqlDecimal (SqlString x) - { - checked - { - return Parse (x.Value); - } - } - - public static implicit operator SqlDecimal (decimal x) - { - return new SqlDecimal (x); - } - - public static implicit operator SqlDecimal (SqlByte x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - - public static implicit operator SqlDecimal (SqlInt16 x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - - public static implicit operator SqlDecimal (SqlInt32 x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - - public static implicit operator SqlDecimal (SqlInt64 x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - - public static implicit operator SqlDecimal (SqlMoney x) - { - if (x.IsNull) - return Null; - else - return new SqlDecimal ((decimal)x.Value); - } - - } -} \ No newline at end of file diff --git a/mcs/class/System.Data/System.Data/Res.cs b/mcs/class/System.Data/System.Data/Res.cs deleted file mode 100644 index e9e799a8b5b..00000000000 --- a/mcs/class/System.Data/System.Data/Res.cs +++ /dev/null @@ -1,155 +0,0 @@ -namespace System.Data -{ - - using java.util; - - using System.Globalization; - //using clr.System; - - public class Res - { - private static readonly String FILE_NAME = "SystemData"; - private static readonly ResourceBundle _resource = - ResourceBundle.getBundle(FILE_NAME); - - public static String GetString(String name, Object[] args) - { - return GetString(null, name, args); - } - - public static String GetString(CultureInfo culture, String name, Object[] args) - { - try - { - String str = _resource.getString(name); - if (args != null && (int) args.Length > 0) - { - return String.Format(str, args); - } - else - { - return str; - } - } - catch (MissingResourceException) - { - return null; - } - } - - public static String GetString(String name) - { - return GetString(null, name); - } - - public static String GetString(CultureInfo culture, String name) - { - try - { - return _resource.getString(name); - } - catch (MissingResourceException) - { - return null; - } - } - - public static bool GetBoolean(String name) - { - return GetBoolean(name); - } - - public static bool GetBoolean(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return false; - } - - public static char GetChar(String name) - { - return GetChar(null, name); - } - - public static char GetChar(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return (char)0; - } - - public static int GetByte(String name) - { - return GetByte(null, name); - } - - public static int GetByte(CultureInfo culture, String name) - { - return 0; - } - - public static short GetShort(String name) - { - return GetShort(null, name); - } - - public static short GetShort(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return 0; - } - - public static int GetInt(String name) - { - return GetInt(null, name); - } - - public static int GetInt(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return 0; - } - - public static long GetLong(String name) - { - return GetLong(null, name); - } - - public static long GetLong(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return 0; - } - - public static float GetFloat(String name) - { - return GetFloat(null, name); - } - - public static float GetFloat(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return 0.0f; - } - - public static double GetDouble(String name) - { - return GetDouble(null, name); - } - - public static double GetDouble(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return 0.0; - } - - public static Object GetObject(String name) - { - return GetObject(null, name); - } - - public static Object GetObject(CultureInfo culture, String name) - { - // This online demo only decompiles 10 methods in each class - return null; - } - } -} \ No newline at end of file diff --git a/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs b/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs deleted file mode 100644 index 64592c9667e..00000000000 --- a/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs +++ /dev/null @@ -1,334 +0,0 @@ -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Web.Util; -using System.IO; -using vmw.@internal.io; -using vmw.common; -using System.ComponentModel; -using System.Threading; -using javax.servlet; -using System.Diagnostics; - -namespace System.Web.J2EE -{ - internal static class J2EEUtils - { - #region InputStreamWrapper - - public sealed class InputStreamWrapper : Stream - { - readonly java.io.InputStream _ins; - - public InputStreamWrapper (java.io.InputStream ins) { - _ins = ins; - } - - public override bool CanRead { - get { return true; } - } - - public override bool CanSeek { - get { return _ins.markSupported (); } - } - - public override bool CanWrite { - get { return false; } - } - - public override void Flush () { - } - - public override long Length { - get { return _ins.available (); } - } - - public override long Position { - get { - throw new NotSupportedException (); - } - set { - throw new NotSupportedException (); - } - } - - public override int Read (byte [] buffer, int offset, int count) { - int r = _ins.read (TypeUtils.ToSByteArray (buffer), offset, count); - return r < 0 ? 0 : r; - } - - public override long Seek (long offset, SeekOrigin origin) { - throw new NotImplementedException (); - } - - public override void SetLength (long value) { - throw new NotSupportedException (); - } - - public override void Write (byte [] buffer, int offset, int count) { - throw new NotSupportedException (); - } - - public override void Close () { - _ins.close (); - } - } - - #endregion - - public static int RunProc(string[] cmd) - { - java.lang.Runtime rt = java.lang.Runtime.getRuntime(); - java.lang.Process proc = rt.exec(cmd); - - StreamGobbler errorGobbler = new - StreamGobbler(proc.getErrorStream(), "ERROR"); - - StreamGobbler outputGobbler = new - StreamGobbler(proc.getInputStream(), "OUTPUT"); - - errorGobbler.start(); - outputGobbler.start(); - - int exitVal = proc.waitFor(); - return exitVal; - } - } - - public class StreamGobbler : java.lang.Thread - { - java.io.InputStream _is; - String _type; - - public StreamGobbler(java.io.InputStream ins, String type) - { - this._is = ins; - this._type = type; - } - - public override void run() - { - try - { - java.io.InputStreamReader isr = new java.io.InputStreamReader(_is); - java.io.BufferedReader br = new java.io.BufferedReader(isr); - String line=null; - while ( (line = br.readLine()) != null) - { - Debug.WriteLine(_type + ">" + line); - } - } - catch (Exception ex) - { - Debug.WriteLine (ex); - } - } - } -} - -#region FileSystemWatcher Stub - -namespace System.IO -{ - [DefaultEvent ("Changed")] -#if NET_2_0 - [IODescription ("")] -#endif - public class FileSystemWatcher : Component, ISupportInitialize - { - public FileSystemWatcher () - : this (String.Empty) { - } - - public FileSystemWatcher (string path) - : this (path, "*.*") { - } - - public FileSystemWatcher (string path, string filter) { - } - - #region Properties - - [DefaultValue (false)] - [IODescription ("Flag to indicate if this instance is active")] - public bool EnableRaisingEvents { - get { return false; } - set { } - } - - [DefaultValue ("*.*")] - [IODescription ("File name filter pattern")] - [RecommendedAsConfigurable (true)] - [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)] - public string Filter { - get { return "*.*"; } - set { } - } - - [DefaultValue (false)] - [IODescription ("Flag to indicate we want to watch subdirectories")] - public bool IncludeSubdirectories { - get { return false; } - set { } - } - - [Browsable (false)] - [DefaultValue (8192)] - public int InternalBufferSize { - get { return 8192; } - set { } - } - - [DefaultValue (NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite)] - [IODescription ("Flag to indicate which change event we want to monitor")] - public NotifyFilters NotifyFilter { - get { return NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite; } - set { } - } - - [DefaultValue ("")] - [IODescription ("The directory to monitor")] - [RecommendedAsConfigurable (true)] - [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)] - [Editor ("System.Diagnostics.Design.FSWPathEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)] - public string Path { - get { return String.Empty; } - set { } - } - - [DefaultValue (null)] - [IODescription ("The object used to marshal the event handler calls resulting from a directory change")] -#if NET_2_0 - [Browsable (false)] -#endif - public ISynchronizeInvoke SynchronizingObject { - get { return null; } - set { } - } - - #endregion // Properties - - #region Methods - - protected override void Dispose (bool disposing) { - base.Dispose (disposing); - } - - enum EventType - { - FileSystemEvent, - ErrorEvent, - RenameEvent - } - - void RaiseEvent (Delegate ev, EventArgs arg, EventType evtype) { - if (ev == null) - return; - - if (SynchronizingObject == null) { - Delegate [] delegates = ev.GetInvocationList (); - if (evtype == EventType.RenameEvent) { - foreach (RenamedEventHandler d in delegates) { - d.BeginInvoke (this, (RenamedEventArgs) arg, null, null); - } - } - else if (evtype == EventType.ErrorEvent) { - foreach (ErrorEventHandler d in delegates) { - d.BeginInvoke (this, (ErrorEventArgs) arg, null, null); - } - } - else { - foreach (FileSystemEventHandler d in delegates) { - d.BeginInvoke (this, (FileSystemEventArgs) arg, null, null); - } - } - return; - } - - SynchronizingObject.BeginInvoke (ev, new object [] { this, arg }); - } - - protected void OnChanged (FileSystemEventArgs e) { - RaiseEvent (Changed, e, EventType.FileSystemEvent); - } - - protected void OnCreated (FileSystemEventArgs e) { - RaiseEvent (Created, e, EventType.FileSystemEvent); - } - - protected void OnDeleted (FileSystemEventArgs e) { - RaiseEvent (Deleted, e, EventType.FileSystemEvent); - } - - protected void OnError (ErrorEventArgs e) { - RaiseEvent (Error, e, EventType.ErrorEvent); - } - - protected void OnRenamed (RenamedEventArgs e) { - RaiseEvent (Renamed, e, EventType.RenameEvent); - } - - public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType) { - return WaitForChanged (changeType, Timeout.Infinite); - } - - public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType, int timeout) { - return new WaitForChangedResult (); - } - - #endregion - - #region Events and Delegates - - [IODescription ("Occurs when a file/directory change matches the filter")] - public event FileSystemEventHandler Changed; - - [IODescription ("Occurs when a file/directory creation matches the filter")] - public event FileSystemEventHandler Created; - - [IODescription ("Occurs when a file/directory deletion matches the filter")] - public event FileSystemEventHandler Deleted; - - [Browsable (false)] - public event ErrorEventHandler Error; - - [IODescription ("Occurs when a file/directory rename matches the filter")] - public event RenamedEventHandler Renamed; - - #endregion // Events and Delegates - - #region ISupportInitialize Members - - public void BeginInit () { - } - - public void EndInit () { - } - - #endregion - } -} -#endregion diff --git a/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs b/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs deleted file mode 100644 index 35b063f46a8..00000000000 --- a/mcs/class/System.Web/System.Web.J2EE/ObjectInputStream.cs +++ /dev/null @@ -1,244 +0,0 @@ -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// -// Authors: -// Vladimir Krasnov -// Konstantin Triger -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using java.io; - -namespace Mainsoft.Web.Hosting -{ - public sealed class ObjectInputStream : System.IO.Stream, ObjectInput - { - readonly ObjectInput _javaObjectInput; - - public ObjectInputStream (ObjectInput stream) - { - _javaObjectInput = stream; - } - - public override bool CanRead - { - get - { - return true; - } - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override bool CanSeek - { - get - { - return true; - } - } - - public override long Length - { - get - { - throw new NotSupportedException (); - } - } - - public override long Position - { - get - { - throw new NotSupportedException (); - } - set - { - throw new NotSupportedException (); - } - } - - public override void Flush () - { - throw new NotSupportedException (); - } - - public override long Seek (long offset, System.IO.SeekOrigin origin) - { - if (origin == System.IO.SeekOrigin.Current) - return _javaObjectInput.skip (offset); - - throw new NotSupportedException (); - } - - public override void SetLength (long value) - { - throw new NotSupportedException (); - } - - public override int Read (byte [] buffer, int offset, int count) - { - int rv = _javaObjectInput.read (vmw.common.TypeUtils.ToSByteArray (buffer), offset, count); - return rv > 0 ? rv : 0; - } - - public override void Write (byte [] buffer, int offset, int count) - { - throw new NotSupportedException (); - } - - public override int ReadByte () - { - return _javaObjectInput.read (); - } - - public override void Close () - { - _javaObjectInput.close (); - } - - #region ObjectInput Members - - public int available () - { - return _javaObjectInput.available (); - } - - public void close () - { - _javaObjectInput.close (); - } - - public int read (sbyte [] __p1, int __p2, int __p3) - { - return _javaObjectInput.read (__p1, __p2, __p3); - } - - public int read (sbyte [] __p1) - { - return _javaObjectInput.read (__p1); - } - - public int read () - { - return _javaObjectInput.read (); - } - - public object readObject () - { - return _javaObjectInput.readObject (); - } - - public long skip (long __p1) - { - return _javaObjectInput.skip (__p1); - } - - #endregion - - #region DataInput Members - - public bool readBoolean () - { - return _javaObjectInput.readBoolean (); - } - - public sbyte readByte () - { - return _javaObjectInput.readByte (); - } - - public char readChar () - { - return _javaObjectInput.readChar (); - } - - public double readDouble () - { - return _javaObjectInput.readDouble (); - } - - public float readFloat () - { - return _javaObjectInput.readFloat (); - } - - public void readFully (sbyte [] __p1, int __p2, int __p3) - { - _javaObjectInput.readFully (__p1, __p2, __p3); - } - - public void readFully (sbyte [] __p1) - { - _javaObjectInput.readFully (__p1); - } - - public int readInt () - { - return _javaObjectInput.readInt (); - } - - public string readLine () - { - return _javaObjectInput.readLine (); - } - - public long readLong () - { - return _javaObjectInput.readLong (); - } - - public short readShort () - { - return _javaObjectInput.readShort (); - } - - public string readUTF () - { - return _javaObjectInput.readUTF (); - } - - public int readUnsignedByte () - { - return _javaObjectInput.readUnsignedByte (); - } - - public int readUnsignedShort () - { - return _javaObjectInput.readUnsignedShort (); - } - - public int skipBytes (int __p1) - { - return _javaObjectInput.skipBytes (__p1); - } - - #endregion - } - -} diff --git a/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs b/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs deleted file mode 100644 index 18f780b70dd..00000000000 --- a/mcs/class/System.Web/System.Web.J2EE/ObjectOutputStream.cs +++ /dev/null @@ -1,220 +0,0 @@ -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// -// Authors: -// Vladimir Krasnov -// Konstantin Triger -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using java.io; - -namespace Mainsoft.Web.Hosting -{ - public sealed class ObjectOutputStream : System.IO.Stream, ObjectOutput - { - readonly ObjectOutput _javaObjectOutput; - - public ObjectOutputStream (ObjectOutput stream) - { - _javaObjectOutput = stream; - } - - public override bool CanRead - { - get - { - return false; - } - } - - public override bool CanSeek - { - get - { - return false; - } - } - - public override bool CanWrite - { - get - { - return true; - } - } - - public override void Close () - { - _javaObjectOutput.close (); - } - - public override void Flush () - { - _javaObjectOutput.flush (); - } - - public override long Length - { - get - { - throw new NotSupportedException (); - } - } - - public override long Position - { - get - { - throw new NotSupportedException (); - } - set - { - throw new NotSupportedException (); - } - } - - public override long Seek (long offset, System.IO.SeekOrigin origin) - { - throw new NotSupportedException (); - } - - public override void SetLength (long value) - { - throw new NotSupportedException (); - } - - public override int Read (byte [] buffer, int offset, int count) - { - throw new NotSupportedException (); - } - - public override void Write (byte [] buffer, int offset, int count) - { - _javaObjectOutput.write (vmw.common.TypeUtils.ToSByteArray (buffer), offset, count); - } - - public override void WriteByte (byte value) - { - _javaObjectOutput.write (value); - } - - public ObjectOutput NativeStream - { - get { return _javaObjectOutput; } - } - - #region ObjectOutput Members - - public void close () - { - _javaObjectOutput.close (); - } - - public void flush () - { - _javaObjectOutput.flush (); - } - - public void write (sbyte [] __p1, int __p2, int __p3) - { - _javaObjectOutput.write (__p1, __p2, __p3); - } - - public void write (sbyte [] __p1) - { - _javaObjectOutput.write (__p1); - } - - public void write (int __p1) - { - _javaObjectOutput.write (__p1); - } - - public void writeObject (object __p1) - { - _javaObjectOutput.writeObject (__p1); - } - - #endregion - - #region DataOutput Members - - - public void writeBoolean (bool __p1) - { - _javaObjectOutput.writeBoolean (__p1); - } - - public void writeByte (int __p1) - { - _javaObjectOutput.writeByte (__p1); - } - - public void writeBytes (string __p1) - { - _javaObjectOutput.writeBytes (__p1); - } - - public void writeChar (int __p1) - { - _javaObjectOutput.writeChar (__p1); - } - - public void writeChars (string __p1) - { - _javaObjectOutput.writeChars (__p1); - } - - public void writeDouble (double __p1) - { - _javaObjectOutput.writeDouble (__p1); - } - - public void writeFloat (float __p1) - { - _javaObjectOutput.writeFloat (__p1); - } - - public void writeInt (int __p1) - { - _javaObjectOutput.writeInt (__p1); - } - - public void writeLong (long __p1) - { - _javaObjectOutput.writeLong (__p1); - } - - public void writeShort (int __p1) - { - _javaObjectOutput.writeShort (__p1); - } - - public void writeUTF (string __p1) - { - _javaObjectOutput.writeUTF (__p1); - } - - #endregion - } -} diff --git a/mcs/class/System.Web/System.Web/IHttpExtendedWorkerRequest.cs b/mcs/class/System.Web/System.Web/IHttpExtendedWorkerRequest.cs deleted file mode 100644 index 0a0d9793d71..00000000000 --- a/mcs/class/System.Web/System.Web/IHttpExtendedWorkerRequest.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// (C) 2007 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Text; -using javax.servlet.http; - -namespace Mainsoft.Web -{ - public interface IHttpExtendedWorkerRequest - { - HttpSession GetSession (bool create); - } - - public interface IHttpUnifyWorkerRequest - { - } - - public class UnifyRequestException : Exception - { - public UnifyRequestException (Exception innerException) - : base (String.Empty, innerException) { - } - } -}