Wednesday, 2 July 2014

ORA-01591 quick solution

While working on BPEL engine one of my instance goes into recovery.When i tried to recover the same I came across following error from server side


ORA-01591: lock held by in-doubt distributed transaction 5.6.239425

We don't really see this error often. So I did a little research. 

The error message doc from Oracle has pretty good explanation but didn't provide a solution how to resolve the same.Also you will find couple of copy cats copying the same messages to the various forums without proper solution.

ORA-01591:

lock held by in-doubt distributed transaction string
Cause:
Trying to access resource that is locked by a dead two-phase commit transaction that is in prepared state.
Action:
DBA should query the pending_trans$ and related tables, and attempt to repair network connection(s) to coordinator and commit point. If timely repair is not possible, DBA should contact DBA at commit point if known or end user for correct outcome, or use heuristic default if given to issue a heuristic commit or abort command to finalize the local portion of the distributed transaction.

Rollback force didn't do the trick. What I end up did is very easy,  The DBMS_TRANSACTION helped.

SQL> select local_tran_id from dba_2pc_pending;

LOCAL_TRAN_ID
----------------------
 5.6.239425

SQL> rollback force '5.6.239425';

Rollback complete.

SQL> select local_tran_id from dba_2pc_pending;

LOCAL_TRAN_ID
----------------------
 5.6.239425

SQL> exec dbms_transaction.purge_lost_db_entry(' 5.6.239425');

PL/SQL procedure successfully completed.

SQL> commit;

Commit complete.

SQL> select local_tran_id from dba_2pc_pending;


no rows selected

Monday, 16 June 2014

Resolving ORACLE Database Errors - ORA-28000,ORA-28001,ORA-28002,XS$NULL

 

ORACLE ERROR:ORA-28000: The account is locked

 

After installation of Oracle10g/11g, there was a problem..couldnt login using SQL+. None of the accounts(scott/tiger) worked . At last a quick web search gave the solution . Here is what it is:
From your command prompt, type 
sqlplus "/ as sysdba"

Once logged in as SYSDBA, you need to unlock the SCOTT account 

SQL> alter user scott account unlock;

SQL> grant connect, resource to scott;


ORA-28001: the password has expired


Applies to:

Oracle Database Software Std & Enterprise Edition - Version: 11.1.1.1.0 and later   [Release: 11gR1 and later ]Information in this document applies to any platform.

Reason:

In Oracle Database, A remote DBAface this because password have reached 180 Default limit for Password life time. The life of a password is defined as 180 days by default. DBA has to change this limit to unlimited to solve this and to avid this in future. Before getting this error DBA will also show ORA-28002: the password will expire within n days 


So lets deal with the issue  ORA-28001

The users password were expired and in their grace period.Here is what it looked like:


SQL> select username,account_status,expiry_date from dba_users;

USERNAME                      ACCOUNT_STATUS               EXPIRY_DATE
------------------------------ ------------------------   ------------
SELFLOAD                      OPEN
PROD                          OPEN
TECHNO                        EXPIRED(GRACE)                 11-JAN-14
SCOTT                         EXPIRED & LOCKED               08-JUL-14
ORACLE_OCM                    EXPIRED & LOCKED               15-AUG-09
XS$NULL                       EXPIRED & LOCKED               15-AUG-13
MDDATA                        EXPIRED & LOCKED               15-AUG-13
DIP                           EXPIRED & LOCKED               15-AUG-09
APEX_PUBLIC_USER              EXPIRED & LOCKED               15-AUG-09
SPATIAL_CSW_ADMIN_USR         LOCKED                         15-AUG-09


So here is what I did:-


connect to sql like- sqlplus "/ as sysdba"

SQL> select password from sys.user$ where name='TECHNO';

PASSWORD
------------------------------
7A0F2B316C212D67

This gave me the hashed password for the user TECHNO

Then again set the same password for user TECHNO:

SYS> alter user TECHNO identified by values '7A0F2B316C212D67';

Now the account is open again and not expired or in grace period:

USERNAME                      ACCOUNT_STATUS               EXPIRY_DATE
----------------------     -------------------           --------------
SELFLOAD                      OPEN
PROD                          OPEN
TECHNO                        OPEN                           11-JAN-14
SCOTT                         EXPIRED & LOCKED               08-JUL-14
ORACLE_OCM                    EXPIRED & LOCKED               15-AUG-09
XS$NULL                       EXPIRED & LOCKED               15-AUG-13
MDDATA                        EXPIRED & LOCKED               15-AUG-13
DIP                           EXPIRED & LOCKED               15-AUG-09
APEX_PUBLIC_USER              EXPIRED & LOCKED               15-AUG-09
SPATIAL_CSW_ADMIN_USR         LOCKED                         15-AUG-09




The above option may not work completely on the case "EXPIRED & LOCKED" it may remain LOCKED although it will no longer appear EXPIRED like:-


USERNAME                      ACCOUNT_STATUS               EXPIRY_DATE
----------------------     -------------------           --------------
SCOTT                           LOCKED                       08-JUL-14


So in that case unlock the user as illustrated below:-


connect to sql as- sqlplus "/ as sysdba"

Once logged in as SYSDBA, you need to unlock the SCOTT account 

SQL> alter user scott account unlock;

SQL> grant connect, resource to scott;

The other way to to open the expired password is to try to connect the user using the command prompt, it will ask to you to change the password as follows,  It will ask you for the password provide the password,account will be open.

SQL> conn techno/password
ERROR:
ORA-28001: the password has expired

Changing password for techno
New password:
Retype new password:
Password changed
Connected.


 

XS$NULL

Although by above methods one can unlock the users but the following user XS$NULL  remains "EXPIRED & LOCKED"

Explanation for the same:-

Oracle introduced a new user in version 11g called XS$NULL. It is for Oracle’s internal use only and you should leave it alone. For this reason it is locked and expired when it is created:

SQL> select account_status from dba_users

  2  where username = 'XS$NULL';

ACCOUNT_STATUS
--------------------------------
EXPIRED & LOCKED

SQL>

You are advised not to alter this account in any way, even if an auditor asks you to. Oracle does not let you change its password:

SQL> conn / as sysdba

Connected.

SQL> alter user xs$null identified by new_pwd
  2  /
alter user xs$null identified by new_pwd
                                 *
ERROR at line 1:
ORA-01031: insufficient privileges

SQL>

Although you can do so with the password command:

SQL> select password from sys.user$
  2  where name = 'XS$NULL';

PASSWORD
------------------------------
DC4FCC8CB69A6733

SQL> password xs$null
Changing password for xs$null
New password:
Retype new password:
Password changed


SQL> select password from sys.user$where name = 'XS$NULL';

PASSWORD
------------------------------
C17AE3B0A14EA63F

SQL>

This is because of bug 12822989 and you must not do this.




ERROR: ORA-28002: the password will expire within 6 days. 
Lets see what we can do about resolving this issue.
You could simply just change the users password. In an ideal and secure world, this is exactly what you would do. Though this may not be practical, there may be a whole host of reasons for postponing the change.
In Oracle 11g, users are assigned to a profile, the default profile is named “DEFAULT”. This default profile comes configured with a maximum password lifetime of a 180 days.
[box type="info"] Just note that this document’s steps have been performed on Oracle 11g Release 11.2.0.3.0 running on Red Hat Enterprise Linux 6.3. The SQL syntax provided “should” work on all Oracle 11g platforms.[/box]

Step 1: Identify the Users Profile

Log into Oracle 11g using SQL*Plus tool as sysdba


Step 1: Identify the Users Profile
Log into Oracle 11g using SQL*Plus tool as sysdba
[oracle@oracle1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Nov 20 12:18:08 2012
Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

SQL>
Lets confirm that the user is running the default profile. Note you must capitalize the username.

SQL> SELECT profile FROM dba_users WHERE username = 'USER1';

PROFILE
------------------------------
DEFAULT

we can change the password ,

As you can see, the user has the profile of “DEFAULT” configured.

Step 2: View the Profile settings
Lets examine the settings of the profile


SQL> select resource_name,resource_type, limit from dba_profiles where profile='DEFAULT';
 
RESOURCE_NAME                                                           RESOURCE LIMIT
-------------------------------- --------                 ----------------------------------------
COMPOSITE_LIMIT                                                        KERNEL   UNLIMITED
SESSIONS_PER_USER                                                     KERNEL   UNLIMITED
CPU_PER_SESSION                                                          KERNEL   UNLIMITED
CPU_PER_CALL                                                              KERNEL   UNLIMITED
LOGICAL_READS_PER_SESSION                                        KERNEL   UNLIMITED
LOGICAL_READS_PER_CALL                                             KERNEL   UNLIMITED
IDLE_TIME                                                                    KERNEL   UNLIMITED
CONNECT_TIME                                                              KERNEL   UNLIMITED
PRIVATE_SGA                                                                  KERNEL   UNLIMITED
FAILED_LOGIN_ATTEMPTS                                           PASSWORD 10
PASSWORD_LIFE_TIME                                                PASSWORD 180
PASSWORD_REUSE_TIME                                          PASSWORD UNLIMITED
PASSWORD_REUSE_MAX                                         PASSWORD UNLIMITED
PASSWORD_VERIFY_FUNCTION                              PASSWORD NULL
PASSWORD_LOCK_TIME                                               PASSWORD 1
PASSWORD_GRACE_TIME                                           PASSWORD 7
 
16 rows selected 


As you can see the PASSWORD_LIFE_TIME is to 180 days, you may configure this however you want.

Step 3: Set PASSWORD_LIFE_TIME
In this example, we’re going to make the password life unlimited so that it never expires. This may not be the wisest thing to do in a production environment. However there may be circumstances that require a password change at a later date.

To make this change we simply need to run the following command:

SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

Profile altered.
Step 4: Re-Enter the Password
You may notice that even after setting the password expiry to unlimited you are still getting the “ERROR: ORA-28002: the password will expire” message. I’m guessing this is due to additional processes that Oracle does in the background for checking password age etc. So this forces us to “reset” the password to it’s current value to remove the error.

This is done via the following SQL

SQL> alter user USER1 identified by "password";

User altered.
Just note that the password must be double quoted and not single quoted.

…and that’s it, you should no longer receive the “ORA-28002: the password will expire” message for USER1 when logging in.

[box type="warning"] Just note that having never expiring passwords probably isn’t the best password policy to maintain. Oracle’s password expiration setting is a great way to remind users and admin’s to change their passwords regularly.[/box]

In the End:-

It should serve as a warning that when the account has a status of EXPIRED & LOCKED after initial database creation it is much different than if that account is altered to that status after an account has been assigned a password and unlocked. Some tools, such as SQL*Plus will allow the user the chance to change the password if the old password is properly supplied. 

For example:

1.  We can easily expire the password for the ANONYMOUS account

SQL> ALTER USER anonymous PASSWORD EXPIRE;
User altered.
And the status would clearly be:
USERNAME              ACCOUNT_STATUS    LOCK_DATE EXPIRY_DA
--------------------- ----------------- --------- ---------
ANONYMOUS             EXPIRED                     11-SEP-09

2.  The ANONYMOUS account would be prompted for a password and allowed to connect after entering a new password:

SQL> connect anonymous/abc
ERROR:
ORA-28001: the password has expired
 
Changing password for anonymous
New password: xyz
Retype new password: xyz
Password changed
Connected.
By contrast, if you really wanted to lock out a user from connecting in the future, regardless of password expiration, you should LOCK the account. For example:


3.  We can easily lock the ANONYMOUS account
SQL> ALTER USER anonymous ACCOUNT LOCK;
User altered.
And the status would clearly be:
USERNAME              ACCOUNT_STATUS    LOCK_DATE EXPIRY_DA
--------------------- ----------------- --------- ---------
ANONYMOUS             LOCKED            11-SEP-09 10-MAR-10

4.  The ANONYMOUS account is totally locked out and unable to connect:
SQL> connect anonymous/abc
ERROR:

ORA-28000: the account is locked

Expiring and locking user accounts are one of the first steps to securing who can connect to an Oracle database. The expiration of account passwords is not an effective lock-out mechanism but should instead be used to encourage users to just change their passwords over time. Locking an account though has the effect of truly locking out an account so no one can use it to connect to the database. If you need to disable an account this is the preferred method other than dropping it. Just be warned that expiring an account leaves the prior password intact. Under this condition if you were to lock the account and someone came up behind your work and unlocked the account, the user could still log in by changing the password. It is therefore suggested to alter the password before expiring and locking. That way even if the lock were removed the user would have no way of ever connecting again.



Thank You.










Saturday, 24 May 2014

Oracle Adapters

Introduction to Oracle JCA Adapters


Adapters support a robust, light weight, highly scalable, and standards-based integration framework, which enables disparate applications to communicate with each other. For example, adapters enable you to integrate packaged applications, legacy applications, databases, and Web services. Using Oracle JCA Adapters, you can ensure interoperability by integrating applications that are heterogeneous, provided by different vendors, based on different technologies, and run on different platforms.

Features of Oracle JCA Adapters:-

Oracle JCA Adapters provide the following benefits:
• Provide a connectivity platform for integrating complex business processes: Adapters integrate mainframe and legacy applications with enterprise resource planning (ERP), customer relationship management (CRM), databases, and messaging systems. Oracle provides adapters to connect various packaged applications, such as SAP and Siebel, and databases. In addition, adapters integrate middleware messaging systems, such as MQSeries and Oracle Advanced Queuing, and legacy applications, such as CICS and Tuxedo, to provide a complete solution.
• Support open standards: Adapters are based on a set of standards such as J2EE Connector Architecture (JCA) version 1.5, Extensible Markup Language (XML), and Web Service Definition Language (WSDL). The support for standards reduces the learning curve of a user and eliminates the dependency of users on a single vendor.
• Service Component Architecture (SCA) assembly model: Provides the service details and their interdependencies to form composite applications. SCA enables you to represent business logic as reusable service components that can be easily integrated into any SCA-compliant application. The resulting application is known as an SOA composite application. The specification for the SCA standard is maintained by the Organization for the Advancement of Structured Information Standards (OASIS).
• Implement a Service-Oriented Architecture (SOA): The support for open standards enables adapters to implement an SOA, which facilitates loose coupling, flexibility, and extensibility.
• Use native APIs: Adapters support multiple ways of interfacing with the back-end system and provide various deployment options. Using native APIs, adapters communicate with the back-end application and also translate the native data to standard XML, which is provided to the client.
• Model data: Adapters convert native APIs to standard XML and back, based on the adapter metadata configured during design time. Adapter configurations are defined during design time, which will be used by run-time components.
• Facilitate real-time and bidirectional connectivity: Adapters offer bidirectional communication with various back-end systems. This includes sending requests to back-end systems and receiving a response. Adapters also support the real-time event notification service. This service notifies about the back-end events associated with successful back-end transactions for creating, deleting, and updating back-end data. This two-way connectivity ensures faster, flexible, efficient integration, and reduces the cost of integration.
• Maximize availability: Oracle JCA Adapters are based on the J2CA 1.5 specification. Adapters can, therefore, fully leverage the scalability and high availability of the underlying Oracle Application Server platform.
For more information, see Oracle Fusion Middleware Programming Resource Adapters for Oracle WebLogic Server.
In addition, adapters can be deployed on the JBoss and WebSphere platforms.
• Provide easy-to-use design-time tools: Adapters use design-time tools that provide a graphical user interface (GUI) to configure and administer adapters for fast implementation and deployment. In addition, the tools let you to browse, download, and configure back-end schemas.
• Support seamless integration with Oracle Application Server components: Adapters integrate with Oracle Fusion Middleware. Adapters integrate with the JCA Binding Component of the Oracle Fusion Middleware platform, thereby seamlessly integrating with other service engines and binding components.

Types of Oracle JCA Adapters

Oracle JCA Adapters include:-

• Oracle Technology Adapters
• Legacy Adapters
• Packaged-Application Adapters
• Oracle Adapter for Oracle Applications




Oracle Technology Adapters

Oracle technology adapters integrate Oracle Application Server and Oracle Fusion Middleware components such as Oracle BPEL Process Manager (Oracle BPEL PM) or Oracle Mediator components to file systems, FTP servers, database queues (advanced queues, or AQ), Java Message Services (JMS), database tables, and message queues (MQ Series).
These adapters include:
·         Oracle JCA Adapter for Files/FTP
·         Oracle JCA Adapter for Sockets
·         Oracle JCA Adapter for Oracle Streams Advanced Queuing (Oracle JCA Adapter for AQ)
·         Oracle JCA Adapter for JMS
·         Oracle JCA Adapter for Database
·         Oracle JCA Adapter for MQ Series
Oracle technology adapters are installed as part of Oracle Fusion Middleware.


Legacy Adapters

Legacy adapters integrate Oracle Application Server with legacy and mainframe applications using legacy communication protocols.
These adapters include:
·         OracleAS Adapter for Tuxedo
·         OracleAS Adapter for CICS
·         OracleAS Adapter for VSAM
·         OracleAS Adapter for IMS/TM
·         OracleAS Adapter for IMS/DB

Packaged-Application Adapters

Packaged-application adapters integrate Oracle Application Server with various packaged applications, such as SAP and Siebel.
These adapters include:
·         OracleAS Adapter for PeopleSoft
·         OracleAS Adapter for SAP R/3
·         OracleAS Adapter for Siebel
·         OracleAS Adapter for J.D. Edwards





Oracle Adapter for Oracle Applications

Oracle Applications are built on a unified information architecture that consolidates data from Oracle and non-Oracle applications and enables a consistent definition of customers, suppliers, partners, and employees across the entire enterprise. This results in a suite of applications that can give you information, such as current performance metrics, financial ratios, profit and loss summaries. To connect Oracle Applications to non-Oracle applications, you use Oracle Adapter for Oracle Applications.
Adapter for Oracle Applications is also informally known as Oracle E-Business Suite Adapter”
Oracle Adapter for Oracle Applications provides comprehensive, bidirectional, multimodal, synchronous, and asynchronous connectivity to Oracle Applications.