public OciStatementHandle CreateStatement()
        {
            OciStatementHandle statement = (OciStatementHandle)environment.Allocate(OciHandleType.Statement);

            if (statement == null)
            {
                OciErrorInfo info = environment.HandleError();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            statement.ErrorHandle = error;
            statement.Service     = service;

            return(statement);
        }
        public void CreateConnection(OracleConnectionInfo conInfo)
        {
            environment = new OciEnvironmentHandle(OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback);

            if (environment.Handle == IntPtr.Zero)
            {
                throw new OracleException(0, "Could not allocate the Oracle environment.");
            }

            service = (OciServiceHandle)environment.Allocate(OciHandleType.Service);
            if (service == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            error = (OciErrorHandle)environment.Allocate(OciHandleType.Error);
            if (error == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            service.ErrorHandle = error;

            server = (OciServerHandle)environment.Allocate(OciHandleType.Server);
            if (server == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            session = (OciSessionHandle)environment.Allocate(OciHandleType.Session);
            if (session == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            session.Username = conInfo.Username;
            session.Password = conInfo.Password;
            session.Service  = service;

            if (!server.Attach(conInfo.Database, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetServer(server))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

#if ORACLE_DATA_ACCESS
            if (conInfo.SetNewPassword == true)
            {
                // open with new password
                if (!service.SetSession(session))
                {
                    OciErrorInfo info = error.HandleError();
                    Disconnect();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
                if (!service.ChangePassword(conInfo.NewPassword, error))
                {
                    OciErrorInfo info = error.HandleError();
                    Disconnect();
                    throw new OracleException(info.ErrorCode, info.ErrorMessage);
                }
                conInfo.Password       = conInfo.NewPassword;
                conInfo.SetNewPassword = false;
                conInfo.NewPassword    = string.Empty;
            }
            else
            {
#endif
            // open normally
            if (!session.BeginSession(conInfo.CredentialType, OciSessionMode.Default, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetSession(session))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
#if ORACLE_DATA_ACCESS
        }
#endif
            connected = true;
        }
Beispiel #3
0
        public void CreateConnection(OracleConnectionInfo conInfo)
        {
            environment = new OciEnvironmentHandle(OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback);

            if (environment.Handle == IntPtr.Zero)
            {
                throw new OracleException(0, "Could not allocate the Oracle environment.");
            }

            service = (OciServiceHandle)environment.Allocate(OciHandleType.Service);
            if (service == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            error = (OciErrorHandle)environment.Allocate(OciHandleType.Error);
            if (error == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            service.ErrorHandle = error;

            server = (OciServerHandle)environment.Allocate(OciHandleType.Server);
            if (server == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            session = (OciSessionHandle)environment.Allocate(OciHandleType.Session);
            if (session == null)
            {
                OciErrorInfo info = environment.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }
            session.Username = conInfo.Username;
            session.Password = conInfo.Password;
            session.Service  = service;

            if (!server.Attach(conInfo.Database, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetServer(server))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!session.BeginSession(conInfo.CredentialType, OciSessionMode.Default, ErrorHandle))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            if (!service.SetSession(session))
            {
                OciErrorInfo info = error.HandleError();
                Disconnect();
                throw new OracleException(info.ErrorCode, info.ErrorMessage);
            }

            connected = true;
        }
Beispiel #4
0
		public void CreateConnection (OracleConnectionInfo conInfo) 
		{
			environment = new OciEnvironmentHandle (OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback);

			if (environment.Handle == IntPtr.Zero)
				throw new OracleException (0, "Could not allocate the Oracle environment.");

			service = (OciServiceHandle) environment.Allocate (OciHandleType.Service);
			if (service == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			error = (OciErrorHandle) environment.Allocate (OciHandleType.Error);
			if (error == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}
			service.ErrorHandle = error;

			server = (OciServerHandle) environment.Allocate (OciHandleType.Server);
			if (server == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			session = (OciSessionHandle) environment.Allocate (OciHandleType.Session);
			if (session == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}
			session.Username = conInfo.Username;
			session.Password = conInfo.Password;
			session.Service = service;
				
			if (!server.Attach (conInfo.Database, ErrorHandle)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			if (!service.SetServer (server)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

#if ORACLE_DATA_ACCESS
			if (conInfo.SetNewPassword == true) {
				// open with new password
				if (!service.SetSession (session)) {
					OciErrorInfo info = error.HandleError ();
					Disconnect ();
					throw new OracleException (info.ErrorCode, info.ErrorMessage);
				}
				if (!service.ChangePassword (conInfo.NewPassword, error)) {
					OciErrorInfo info = error.HandleError ();
					Disconnect ();
					throw new OracleException (info.ErrorCode, info.ErrorMessage);
				}
				conInfo.Password = conInfo.NewPassword;
				conInfo.SetNewPassword = false;
				conInfo.NewPassword = string.Empty;
			} else {
#endif
				// open normally
				if (!session.BeginSession (conInfo.CredentialType, OciSessionMode.Default, ErrorHandle)) {
					OciErrorInfo info = error.HandleError ();
					Disconnect ();
					throw new OracleException (info.ErrorCode, info.ErrorMessage);
				}

				if (!service.SetSession (session)) {
					OciErrorInfo info = error.HandleError ();
					Disconnect ();
					throw new OracleException (info.ErrorCode, info.ErrorMessage);
				}
#if ORACLE_DATA_ACCESS
			}
#endif
			connected = true;
		}
		public void CreateConnection (OracleConnectionInfo conInfo) 
		{
			environment = new OciEnvironmentHandle (OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback);

			if (environment.Handle == IntPtr.Zero)
				throw new OracleException (0, "Could not allocate the Oracle environment.");

			service = (OciServiceHandle) environment.Allocate (OciHandleType.Service);
			if (service == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			error = (OciErrorHandle) environment.Allocate (OciHandleType.Error);
			if (error == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}
			service.ErrorHandle = error;

			server = (OciServerHandle) environment.Allocate (OciHandleType.Server);
			if (server == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			session = (OciSessionHandle) environment.Allocate (OciHandleType.Session);
			if (session == null) {
				OciErrorInfo info = environment.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}
			session.Username = conInfo.Username;
			session.Password = conInfo.Password;
			session.Service = service;
				
			if (!server.Attach (conInfo.Database, ErrorHandle)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			if (!service.SetServer (server)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			if (!session.BeginSession (OciCredentialType.RDBMS, OciSessionMode.Default, ErrorHandle)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			if (!service.SetSession (session)) {
				OciErrorInfo info = error.HandleError ();
				Disconnect ();
				throw new OracleException (info.ErrorCode, info.ErrorMessage);
			}

			connected = true;
		}