Thursday, May 26, 2016

Java - XMLGregorianCalendar to java.sql.date

Refer below..


private Date toDate(XMLGregorianCalendar calendar){
        if(calendar == null) {
            return null;
        }
     
        java.util.Date dt = calendar.toGregorianCalendar().getTime();
        java.sql.Date sqlDt = new java.sql.Date(dt.getTime());
        return sqlDt;
       
    }

Sunday, April 3, 2016

Curl - Send Webservice Request thru Linux terminal

Below is step by step to test request and response on webservice.

Create a request01.xml in server.
Example command : cat > request01.xml

and then paste your xml.

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:NSS="http://tempuri.org/MyService">
   <soapenv:Header/>
   <soapenv:Body>
      <NSS:retrieveDataReq>
         <AgencyCode>123456</AgencyCode>
         <BranchCode>MyBranch011</BranchCode>
         <RequestDateTime>2016-01-18T14:35:00</RequestDateTime>
      </NSS:retrieveDataReq>
   </soapenv:Body>
</soapenv:Envelope>

Ctrl + c to exit the cat command.

Use below curl command to send the request.

curl --header "Content-Type: application/soap+xml;charset=UTF-8" --data @request01.xml http://192.168.1.20:82/webserviceName?wsdl

The response will show in terminal with the raw XML. this curl is use for test the request and response on webservice.

Java wsimport - create webservice client


mkdir C:\temp
cd C:\temp

"C:\Program Files\Java\jdk1.8.0_73\bin\wsimport" -keep http://localhost:83/yourWebservice?wsdl


Sunday, June 28, 2015

UNIX - Remove ^M

Open the file with “vi” editor and type the following:

:%s/^M//g

NOTE: To get the ^M in there, you should type CTRL+V+M

Saturday, June 13, 2015

Oracle - Show all sequence

SELECT us.sequence_name
              FROM USER_SEQUENCES us;

Oracle - Show all table name

SELECT ut.table_name
              FROM USER_TABLES ut;

Oracle - PL/SQL - Delete all table

DECLARE
BEGIN
    --Bye Tables!
  FOR i IN (SELECT ut.table_name
              FROM USER_TABLES ut) LOOP
    EXECUTE IMMEDIATE 'drop table '|| i.table_name ||' CASCADE CONSTRAINTS ';
  END LOOP;

END;

Oracle - PL/SQL - Delete all sequence

DECLARE
BEGIN
--Bye Sequences!
  FOR i IN (SELECT us.sequence_name
              FROM USER_SEQUENCES us) LOOP
    EXECUTE IMMEDIATE 'drop sequence '|| i.sequence_name ||'';
  END LOOP;


END;

Wednesday, February 25, 2015

Sun Solaris : Check Memory like Unix Top command

Here you go :

prstat -Z

Sun solaris : Ping not found

Ping tool usually found under /usr/sbin/ping

You can use directly by do this :

/usr/sbin/ping 10.10.10.11


You can edit your ~/.profile and put in the path.

PATH=$PATH:/usr/sbin
export PATH


Exit and login back the terminal ssh. and try "ping 10.10.10.11".

Oracle : Check last analyzed after gather statistic of schema

select table_name, last_analyzed
from user_tables
order by last_analyzed desc nulls last;
It show all table that has been analyzed with last analyzed date..

Sunday, September 28, 2014

Oracle : find duplicate row and total duplicate




select column_name, count(column_name)
from table
group by column_name
having count (column_name) > 1;

Monday, September 1, 2014

Oracle : display all date in month

Here some example for show all date in current/before/after month or specific month

select to_char( add_months(trunc(sysdate,'MM'),-1) + level - 1, 'YYYYMMDD' ) from dual connect by level <= last_day(add_months(trunc(sysdate,'MM'),-1)) -  add_months(trunc(sysdate,'MM'),-1) + 1;
Above is before current month


select to_char( add_months(trunc(sysdate,'MM'),1) + level - 1, 'YYYYMMDD' ) from dual connect by level <= last_day(add_months(trunc(sysdate,'MM'),1)) -  add_months(trunc(sysdate,'MM'),1) + 1;
Above is after current month


select to_char( trunc(sysdate,'MM') + level - 1, 'YYYYMMDD' ) from dual connect by level <= last_day(trunc(sysdate,'MM')) -  trunc(sysdate,'MM') + 1;

Above is current month

select to_char( trunc(to_date('20140101','YYYYMMDD'),'MM') + level - 1, 'YYYYMMDD' ) from dual connect by level <= last_day(trunc(to_date('20140101','YYYYMMDD'),'MM')) -  trunc(to_date('20140101','YYYYMMDD'),'MM') + 1;
Above is specific month but you must enter date.

Sunday, April 27, 2014

Windows : Continous ping ipaddress

using this command you can ping ipaddress continously to monitor stablity of network between you pc to the ipaddress.

ping 192.168.2.201 -t

UNIX : Kill PID

How to kill process in UNIX ?

first get pid by using grep command.

root 21122 21123 0 13:00:01 ? 0:00 /temp/dummyscript.sh

get the PID number, yellow highlight for above output.

run this command : kill -9 21122 21123

or you can run multiple process by just add the pid number.

example : kill -9 12343 24437 372846 8364 8273 82746

Unix : Grep


grep specific program

ps -ef | grep *batch*
ps -ef | grep batch.sh


grep by username

ps -ef | grep root
ps -ef | grep unixuser



Friday, April 25, 2014

Oracle : How to find all indexes under certain table.

How to find all indexes under certain table.

select index_name, column_name
 from user_ind_columns
 where table_name = '<table_name>';

Saturday, February 22, 2014

Oracle rebuild index

Hi,

Here some reference command that you can re-index you index.

select ' ALTER INDEX ' || INDEX_NAME || ' REBUILD ; COMMIT;' from user_indexes;

run this command, and copy all the output. Paste into SQL script or editor, and run as script.

Wednesday, August 14, 2013

JACC Policy Provider:Failed Permission Check: context (" ..... ") , permission (" (java.lang.RuntimePermission reflectionFactoryAccess) ") |#]

Same thing with previous post.. I got this error after i try to invoke my application in glassfish server.

"JACC Policy Provider:Failed Permission Check: context (" ..... ") , permission (" (java.lang.RuntimePermission reflectionFactoryAccess) ") |#]"

Just grant this reflectionFactoryAccess inside server.policy

please find grant { }

and insert below permission into that grant content.

    permission java.lang.RuntimePermission "reflectionFactoryAccess";


save it and please restart.

JACC Policy Provider:Failed Permission Check: context (" .....") , permission (" (org.osgi.framework.AdminPermission (id=92) resolve,resource) ") |#]

Im facing below error when i try to run my application in glassfish server.

"JACC Policy Provider:Failed Permission Check: context (" .....") , permission (" (org.osgi.framework.AdminPermission (id=92) resolve,resource) ") |#]"

so the solution is just need to put some grant in server.policy. please find grant { }

and insert below statement.

permission org.osgi.framework.AdminPermission "(id=92)", "resolve,resource";

save it.. and please restart your glassfish server.