Oracle: Script to find all the INDEX hints from the files with specific extension

#!/bin/csh

foreach i (`grep -l -e ‘\/\s*\*\s*+’ -e ‘–\s*+’ *.$1`)
echo “$i”
echo `cat “$i”` | grep -o -P -e ‘\/\*\+.*?\*\/’ | grep –color -i -o -P -e ‘index.*?\(.+?\)’
cat “$i” | grep -o -P -e ‘–\+.*’ | grep –color -i -o -P -e ‘index.*?\(.+?\)’
end

[pupakare@unix ~/tmp]$ m2.sh 0
pk.0
index( _PK )
index( _PK1 )
index( _PK2 )
index_asc ( _PK33 )
u1.0
index( _U1 )
index( _U2 )
index( _U3 )
index( _U4 )
index( _U5 )
index( _U6 )
index( _U7 )
u2.0
index( _U01 )
index( _U02 )
index( _U03 )
index( _U11 )
uk.0
index( _U K )
index( _UK1 )
index( _UK2 )
index( _UK3 )

Posted in Uncategorized | Leave a comment

How to see if the string is all numeric using regex

sql> l
1 select 1
2 from dual
3* where regexp_like(‘500000’, ‘[^0-9]’)

sql> /

no rows selected  — which means that all the characters in the string are NUMERIC

sql> l
1 select 1
2 from dual
3* where regexp_like(‘500A000′, ‘[^0-9]’)

sql> /
1
——————–
1

1 row selected  — which means that one or more characters in the string are NOT NUMERIC

You can use similar pattern regexp_like(‘IAMTestInGHeRe’, ‘[^a-zA-Z]’) to find if there is anything but alphabets  ..

Posted in Uncategorized | Leave a comment

Remove extra parentheses

A small utility to get rid of those extraneous parentheses from a SQL query (or any string for that matter) ..

Just copy the attached .class in your directory — and use as follows ..

And… use it as follows..

$ java RemoveExtraBraces ((((()))))(())
<<<——————— Changed String is ———————>>>
                         (        )(  ) 

Requirement: Balanced String with same# of open [(] and close [)] parentheses.

Algorithm:

Make the input string dense.

str=str.replaceAll(“\\s+?\\(\\s+?”,”(“);
str=str.replaceAll(“\\s+?\\)\\s+?”,”)”);

Get the String into charArray.

static char[] charArray;

static char[] setCharArray(String str)
{
charArray = str.toCharArray();
return charArray;
}

Loop thru the whole charArray and find all open and closing parentheses

keep them in a hash map with the position of a parenthesis. This will prepare you for next looping – hopefully there are other strings that don’t need to be scanned in next round.

static HashMap<Integer, Character> parenthesisMap = new LinkedHashMap<Integer, Character>();

static boolean fillInArrayOfParentheses(int startPosition)
{
int position;
char charAt;
int i=0, j=0;
for (position = startPosition; position < charArray.length; position++)
{
charAt = charArray[position];
if (charAt == ‘(‘)
{
parenthesisMap.put(position, charAt);
i++;
}
else if (charAt == ‘)’)
{
parenthesisMap.put(position, charAt);
j++;
}
}
if (i != j)
{
return false;
}
return true;
}

For each open parenthesis [‘(‘] and loop thru parenthesisMap and find the last closing parenthesis [‘)’] position.

static int getClosingBracketPosition(int startPosition)
{
char charAt;
int position = startPosition, bracketCount = 0;
if (!parenthesisMap.isEmpty())
{
for (Integer i: parenthesisMap.keySet())
{
if (i >= startPosition)
{
position = i;
charAt = parenthesisMap.get(i);
if (charAt == ‘(‘)
{
bracketCount++;
}
else
{
if (–bracketCount == 0)
{
break;
}
}
}
}
}
return position;
}

Main algorithm:

ArrayList<Integer> whichSubscriptToBlankout = new ArrayList<Integer>();

for (pos = 0; pos < charArray.length; pos++)
{
curChar = charArray[pos];
if (curChar == ‘(‘)
{
endPos = getClosingBracketPosition(pos);
if (prevChar == ‘(‘)
{
endPlusOneChar = charArray[endPos + 1];
//System.out.println(prevChar+”+”+endPlusOneChar+”+”+(pos)+”+”+(endPos));
}
if (prevChar == ‘(‘ && endPlusOneChar == ‘)’)
{
//System.out.println(” to be changed”);
whichSubscriptToBlankout.add(pos);
whichSubscriptToBlankout.add(endPos);
}
}
prevChar = curChar;
}

for (Integer bracketPosition: whichSubscriptToBlankout)
{
// blankout the elements for which the subscript was captured in whichSubscriptToBlankout
charArray[bracketPosition] = ‘ ‘;
}
String strFinal = String.valueOf(charArray);

Enjoy!!

Posted in Uncategorized | Leave a comment

Dynamic partner link (how to)

For dynamic partner link stuff to work one would need following:
1) Composite ‘Called’ created and deployed to SOA server.
2) Create a Caller composite.
   a) Create a partner link using a deployed composite from (1) above.
   b) You could copy the wsdl (we call it now a concrete wsdl – will have the port information) from the SOA server.
   c) Composite.xml
      <reference name=”CalledServie”
             ui:wsdlLocation=”http://pupakare-lap.us.oracle.com:8001/soa-infra/services/default/Called/Called.wsdl”&gt;
        <interface.wsdl interface=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.interface(Called)&#8221;
                    callbackInterface=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.interface(CalledCallback)”/&gt;
          <binding.ws port=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.endpoint(called_client_ep/Called_pt)
                location=”called_client_ep.wsdl” soapVersion=”1.1″>
            <property name=”weblogic.wsee.wsat.transaction.flowOption” type=”xs:string”
                many=”false”>WSDLDriven</property>
          </binding.ws>
          <callback>
              <binding.ws port=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.endpoint(called_client_ep/CalledCallback_pt)”/&gt;
          </callback>
      </reference>
   d) concrete wsdl [called_client_ep.wsdl] (this could be the oramds location or in a Composite project 

<wsdl:service name=”called_client_ep”>
         <wsdl:port name=”Called_pt” binding=”client:CalledBinding”>
            <soap:address xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/&#8221; location=”<blankout>“/>
         </wsdl:port>
      </wsdl:service>

   e) In Caller’s bpel you will need to have following
      a) Variable needed.
         1) copy schema from http://schemas.xmlsoap.org/ws/2003/03/addressing/ into xsd folder as say ws_addressing.xsd
         2) create a variable of type EndpointReference using the schema above.
            <variables>
               <variable name=”ep_variable” element=”ns2:EndpointReference”/>
            </variables>
      b) Assignment of the REAL (concrete) address to Address portion of the EndpointReference variable.   
         <assign name=”Assign”>
            <copy>
                <from expression=”‘http://pupakare-lap.us.oracle.com:8001/soa-infra/services/default/Called/called_client_ep'”/&gt;
                <to variable=”ep_variable” query=”/ns2:EndpointReference/ns2:Address”/>
            </copy>
      c) And, assignment of EndpointReference variable to a partnerlink
            <copy>
                <from variable=”ep_variable” query=”/ns2:EndpointReference”/>
                <to partnerLink=”CalledServie”/>
            </copy>
        </assign>

     f) Not really required but for consistency following can be changed

         a) File composite.xml

             <import namespace=”http://xmlns.oracle.com/DPL_jws/Called/Called&#8221;
                                  location=”called_client_ep.wsdl
              importType=”wsdl”/>

          b) File CallerProcess.componentType

               <reference name=”CalledServie”
                        ui:wsdlLocation=”<blank out>
                         <interface.wsdl       interface=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.interface(Called)&#8221; callbackInterface=”http://xmlns.oracle.com/DPL_jws/Called/Called#wsdl.interface(CalledCallback)”/&gt;
                   </reference>

Posted in Uncategorized | Leave a comment

My experience with installing SOA suite RCU

  1. Installing Jdev and WLS server
  2. run soa 1.2 suite and
  3. (only then) run soa 1.3
  4. run rcu1.3

Installing the rcu on windows XP.
Run <drive>\rcu3\rcuHome\BIN\rcu.bat.

The RCU attempt failed for whatever reason and I had to undertake some clean up activity–

I had to get rid of the users with DEV_* and the table spaces created with DEV_*.

select * from all_users;

drop user DEV_SOAINFRA cascade;
drop user DEV_ORASDPM  cascade;
drop user DEV_PORTLET  cascade;
drop user DEV_MDS      cascade;

drop tablespace DEV_MDS;
drop tablespace DEV_SOAINFRA;
drop tablespace DEV_ORABAM;
drop tablespace DEV_IAS_PORTLET;
drop tablespace DEV_IAS_ORASDPM;

select * from dba_data_Files;

Also got rid of datafiles (physical delete) after getting rid of tablespaces.

sqlplus sys/sys as sysdba
show parameters processes
show parameters open_cursors

##Removed the RCU : 6107 DB using

ALTER SYSTEM SET processes=500 SCOPE=spfile;
and
ALTER SYSTEM SET open_cursors=500 SCOPE=spfile;

SHUT DOWN the db and brought it back up.

========================================
SQL Test=select 1 from schema_version_registry where owner=(select user from dual) and mr_type=’SOAINFRA’ and version=’11.1.1.2.0′

CFGFWK-60850: Test Failed!
CFGFWK-60853: A connection was established to the database but no rows were returned from the test SQL statement.

Connect as SYS
select * from schema_version_registry where mr_type=’SOAINFRA’ and version=’11.1.1.2.0′;

delete schema_version_registry ; (5 rows deleted)

Again ran <drive>\rcu3\rcuHome\BIN\rcu.bat.

this time successfully 🙂

================= admin server.bat =====================
title ADMIN server
SETLOCAL

set DOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\xe_domain

call “%DOMAIN_HOME%\bin\startWebLogic.cmd” %*

ENDLOCAL
================= soa server.bat =======================
title SOA server
SETLOCAL

set DOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\xe_domain

%DOMAIN_HOME%\bin\startManagedWebLogic.cmd soa_server1

ENDLOCAL

======boot.properties===============

create a boot.properties file if does not exist under ~\Middleware\user_projects\domains\<domain>\servers\soa_server1\security

with following two entries

#Tue Jun 15 23:40:54 EDT 2010
password=
username=

If you get dreaded

Testing JSR-160 Runtime … failed.
Cannot establish connection.
Testing JSR-160 DomainRuntime … skipped.
Testing JSR-88 … skipped.
Testing JSR-88-LOCAL … skipped.
Testing JNDI … skipped.
Testing JSR-160 Edit … skipped.
Testing HTTP … success.
Testing Server MBeans Model … skipped.

try to disable proxy settings in JDeveloper (Tools –>Preferences –> Web Browser and Proxy).
Then, re-start JDeveloper IDE and re-test your application server Connection, it might  work.

==============================

Configuring DBAdaptor for your own JNDI.

Domain->services->jdbc->datasource
Create jdbc/myjndi
follow thru – and test the connection.

Set appropriate targets using Target’s tab. (soa-server1 for example)

Domain->Deployments
Click on DbAdapter
Settings for DbAdapter
Configuration
Outbound Connection Pools
Groups and Instances expand javax.resource.cci.ConnectionFactory by hitting (+)
Hit New
Choose javax.resource.cci.ConnectionFactory
JNDI Name: eis/myjndi
you should see eis/myjndi under Groups and Instances
click on eis/myjndi
Properties
Outbound Connection Properties
xADataSourceName  : jdbc/myjndi

<< this is where the eis/myjndi and jdbc/myjndi are connected >>

Redeploy the DBAdaptor. Check DBAdaptor->Update->Redeploy.

We will use eis/myjndi from JDev on our DBAdaptor.

===================================

If you do get error “Error occurred during initialization of VM
Could not reserve enough space for object heap” — then  setSOADomainEnv.cmd file the following
set DEFAULT_MEM_ARGS=%DEFAULT_MEM_ARGS% -XX:PermSize=128m -XX:MaxPermSize=360m

Posted in Uncategorized | 1 Comment

How to find the jar file or the location where the .class exists?

==============================================

package util;

import java.security.ProtectionDomain;
import java.security.CodeSource;
import java.net.URL;

class WhichJarIsUserClassIn {
public static void main (String[] args) {
System.out.println(“\n”);
System.out.println(“\n”);
if (args.length != 1) {
System.out.println(“usage: java -classpath <yourclasspath> util.WhichJarIsUserClassIn fullyQualifiedClassName (like util.WhichJarIsUserClassIn)”);
return;
}

try {
Class cls = Class.forName(args[0]);
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc            = cSource.getLocation();
System.out.println(“The class ‘” + args[0] + “‘ is in ” + loc + “\n”);

} catch (ClassNotFoundException e) {
String     clspth= System.getProperty(“java.class.path”);
System.out.println(“The class ‘” + args[0] + “‘ not found in the classpath ‘”+clspth +”‘”);
}

catch (NullPointerException e) {
System.out.println(“The class ‘” + args[0] + “‘ may be a core java class!”);
}

}

}

==============================================

Sample run and output —

D:\Pushkar>java  -classpath D:\Oracle\MIDDLE~1\WLSERV~1.3\server\ext\jdbc\oracle
\11g\ojdbc6dms.jar;D:\Oracle\Middleware\Oracle_SOA\soa\modules\user-patch.jar;D:
\Oracle\Middleware\Oracle_SOA\soa\modules\soa-startup.jar;;D:\Oracle\MIDDLE~1\pa
tch_wls1033\profiles\default\sys_manifest_classpath\weblogic_patch.jar;D:\Oracle
\MIDDLE~1\patch_jdev1111\profiles\default\sys_manifest_classpath\weblogic_patch.
jar;D:\Oracle\MIDDLE~1\JDK160~1\lib\tools.jar;D:\Oracle\MIDDLE~1\WLSERV~1.3\serv
er\lib\weblogic_sp.jar;D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.jar;D:\
Oracle\MIDDLE~1\modules\features\weblogic.server.modules_10.3.3.0.jar;D:\Oracle\
MIDDLE~1\WLSERV~1.3\server\lib\webservices.jar;D:\Oracle\MIDDLE~1\modules\ORGAPA
~1.1/lib/ant-all.jar;D:\Oracle\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar
;D:\Oracle\Middleware\Oracle_SOA\soa\modules\oracle.soa.common.adapters_11.1.1\o
racle.soa.common.adapters.jar;D:\Oracle\MIDDLE~1\ORACLE~1\soa\modules\commons-cl
i-1.1.jar;D:\Oracle\MIDDLE~1\ORACLE~1\soa\modules\oracle.soa.mgmt_11.1.1\soa-inf
ra-mgmt.jar;D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.xdk_11.1.0\xsu12.jar;D:\O
racle\MIDDLE~1\modules\features\weblogic.server.modules.xquery_10.3.1.0.jar;D:\O
racle\Middleware\Oracle_SOA\soa\modules\db2jcc4.jar;D:\Oracle\MIDDLE~1\USER_P~1\
domains\wls_soa1.3\config\soa-infra;D:\Oracle\Middleware\Oracle_SOA\soa\modules\
fabric-url-handler_11.1.1.jar;D:\Oracle\Middleware\Oracle_SOA\soa\modules\quartz
-all-1.6.5.jar;D:\Oracle\Middleware\Oracle_SOA\soa\modules\oracle.soa.fabric_11.
1.1\oracle.soa.fabric.jar;D:\Oracle\Middleware\Oracle_SOA\soa\modules\oracle.soa
.adapter_11.1.1\oracle.soa.adapter.jar;D:\Oracle\Middleware\Oracle_SOA\soa\modul
es\oracle.soa.b2b_11.1.1\oracle.soa.b2b.jar;D:\Oracle\MIDDLE~1\ORACLE~1\modules\
oracle.jrf_11.1.1\jrf.jar;D:\Oracle\MIDDLE~1\WLSERV~1.3\common\derby\lib\derbycl
ient.jar;D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar; util.WhichJarIsUserC
lassIn weblogic.servlet.internal.WebAppModule

The class ‘weblogic.servlet.internal.WebAppModule’ is in file:/D:/Oracle/Middlewar
e/wlserver_10.3/server/lib/weblogic.jar

Posted in Uncategorized | Leave a comment