ORA-21522: attempted to use an invalid connection in OCI (object mode only)
Cause : User attempted to use an invalid connection or a connection that has been terminated in an OCI environment (object mode), or user attempted to dereference a REF obtained from a connection which has been terminated.
Action - How to fix it : DBA Scripts :: www.high-oracle.com/scripts
Ensure that the connection exists and is still valid.
Well, the reason for above error is that i have taken the above script from a 11g database and running it on 10g database. 11g has bring some changes in password management. Below code is executed on 11g and user created successfully, which is expected result.