2013年9月11日 星期三

SQL: T1 without matching T2

SELECT T1.Field1, T1.ID FROM T1 LEFT JOIN T2 ON T1.Field1 = T2.Field1 WHERE (((T2.Field1) Is Null));

2013年8月15日 星期四

2013年8月5日 星期一

VMWare: HP ENVY: ERROR When Start up: binary translation is incompatible with long mode on this platform

Go to BIOS:

  • Start up Laptop
  • F10 to get into BIOS screen
  • Search Intel Virtualization Technology (VT) is "disabled" by default, in the BIOS
  • Change to Enable

2013年7月31日 星期三

WebLogic: Setup log4j for your Java Application

This is from: "http://phillips4jc.blogspot.com/2012/01/configuring-web-logic-1035-and-log4j.html"

I recently spent several days trying to track this down why Apache log4j for my Java application was working when deployed to Oracle WebLogic Server 10.3.5. I am posting my findings here in the hopes of saving others some time. I found several blogs that talked about this, but the end result was that log4j was still not working correctly. There was always one step missing. A co-worker and I finally figured it out for both Linux and Windows.

1. Copy wllog4j.jar from your WebLogic server/lib directory and place it in your domain_root/lib folder.
2. Copy your version of log4j.jar to your domain_root/lib folder.
3. Copy your log4j.xml to your domain_root folder. 
4. Log in to the your WebLogic admin server console. Click on Servers -> Admin Server -> Logging. Click on advanced mode, and change the logging implementation from JDK to Log4J. Save your changes.

Most of the blogs had these items, but the one critical piece that was missing:
5. (Linux)Edit the setDomainEnv.sh file in the domain_root/bin directory. and find the following code:

if [ "${LOG4J_CONFIG_FILE}" != "" ] ; then
       JAVA_PROPERTIES="${JAVA_PROPERTIES} -Dlog4j.configuration=file:${LOG4J_CONFIG_FILE}"
       export JAVA_PROPERTIES
fi

Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:

LOG4J_CONFIG_FILE=”/u01/app/oracle/middleware/user_projects/domains/base_domain/log4j.xml”
Export LOG4J_CONFIG_FILE

5. (Windows)
Edit the setDomainEnv.cmd file in the domain_root/bin directory. and find the following code:

if NOT "%LOG4J_CONFIG_FILE%"=="" (                                                          
            set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)

Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:

set LOG4J_CONFIG_FILE=”C:\Oracle\Middleware\user_projects\domains\base_domain\log4j.xml”


6. Activate the changes and restart the admin server.

Here is a sample log4j.xml file. Obviously, you will need to update it for a valid location for your file appender, and replace yourcompany and yourproject with valid values.





   
   
   
    
        
        
            
            
        
    

    
        
        
        
            
        
    

    
    

    
      
    

    
        
    

    
        
    

    
    
    
        
        
    

Weblogic: Properties and xml files under WEB-INF/classes disappear after deployment

on WebLogic 10, all the Properties files and xml files will be on the _wls_cls_gen.jar file after deployment.
_wls_cls_gen.jar file will save under _WL_user/[application]... /lib folders.

zip:C:/bea103/user_projects/domains/Test_Domain/servers/AdminServer/tmp/_WL_user/testWebApp/8j5e1y/war/WEB-INF/lib/_wl_cls_gen.jar!/test.properties 

Now if we write the following code inside out application like Servlet then it won’t work and will fail while reading the Properties file: 

Note: Many frameworks uses the Following techinques and Sometimes WebLogic Code causes this issue..(http://forums.oracle.com/forums/thread.jspa?messageID=4217650#4217650)…which may cause our applications to fail while reading jar Archieved resources. because they uses the following techinque to read the resources available inside a JAR file: 

Change code:
  1. InputStream stream = null;  
  2.   
  3. try {  
  4.   
  5. Properties p = new Properties();  
  6.   
  7. String path=Thread.currentThread().getContextClassLoader().getResource(“Info.properties”).getPath();  
  8.   
  9. System.out.println(“—————-PATH: “+path);  
  10.   
  11. p.load(new java.io.FileInputStream(path));  
  12.   
  13. Host = p.getProperty(“Host”);  
  14.   
  15. Pot = p.getProperty(“Port”);  
  16.   
  17. User = p.getProperty(“User”);  
  18.   
  19. Passwd = p.getProperty(“Passwd”);  
  20.   
  21. System.out.println(“Property Key-Values:” +”\n”+ Host +”\n”+ Pot + “\n”+User+ “\n”+Passwd);  
  22.   
  23. catch (Exception e) {  
  24.   
  25. e.printStackTrace();  
  26.   
  27. }  


To:

  1. InputStream stream = null;  
  2.   
  3. System.out.println(“————————————”);  
  4.   
  5. try {  
  6.   
  7. Properties p = new Properties();  
  8.   
  9. stream=this.getClass().getClassLoader().getResourceAsStream(“Info.properties”);  
  10.   
  11. p.load(stream);  
  12.   
  13. Host = p.getProperty(“Host”);  
  14.   
  15. Pot = p.getProperty(“Port”);  
  16.   
  17. User = p.getProperty(“User”);  
  18.   
  19. Passwd = p.getProperty(“Passwd”);  
  20.   
  21. System.out.println(“Property Key-Values:” +”\n”+ Host +”\n”+ Pot + “\n”+User+ “\n”+Passwd);  
  22.   
  23. catch (Exception e) {  
  24.   
  25. e.printStackTrace();  
  26.   
  27. }  


2013年7月25日 星期四

JAVA on running Unix command: Not enough space

That's not what you think of "disk space". It means not enough swap, because your Java suddenly wants lots of GB of memory. When Java launches fork, it starts a new VM as a fork from current process. Thus for a short period between fork and exec, there is two instances of your stuff. That's temporary though. Exactly at this moment your system cries for a lack of swap.

2013年6月18日 星期二

Oracle: Update CLOB from file


Check file directory:
select * from dba_directories

Create directory:

create or replace directory dirName as
 'c:\data';



create or replace
procedure UPDATE_CLOB
AS

or use

DECLARE

   dest_clob CLOB;
   src_clob BFILE := BFILENAME('xxx from dba_directories', 'data1.txt');
   dst_offset number := 1 ;
   src_offset number := 1 ;
   lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
   warning number;
   BEGIN
DBMS_OUTPUT.ENABLE(100000);

SELECT text_value
      INTO   dest_clob
      FROM   SUBSIDY_ADMINISTRATION_SETTING
      WHERE  setting_id = 'test1'
      FOR UPDATE;

DBMS_OUTPUT.PUT_LINE('dest_clob' || dest_clob);

DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
DBMS_OUTPUT.PUT_LINE('length: ' || DBMS_LOB.GETLENGTH(src_clob));
DBMS_OUTPUT.PUT_LINE('length: ' || lang_ctx);

DBMS_LOB.LoadCLOBFromFile(
DEST_LOB => dest_clob
, SRC_BFILE => src_clob
, AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
, DEST_OFFSET => dst_offset
, SRC_OFFSET => src_offset
, BFILE_CSID => DBMS_LOB.DEFAULT_CSID
, LANG_CONTEXT => lang_ctx
, WARNING => warning
);

UPDATE   SUBSIDY_ADMINISTRATION_SETTING set text_value= dest_clob
WHERE  setting_id = 'test1';
     
     
DBMS_LOB.CLOSE(src_clob);
COMMIT;
DBMS_OUTPUT.PUT_LINE('Loaded File using DBMS_LOB.LoadCLOBFromFile: (ID=1001).');
END;



2013年4月22日 星期一

Oracle: Cannot connect

Remember setup
export ORACLE_HOME=/oracle/11g/product/11.2.0

export ORACLE_SID=F87DEV

2013年2月26日 星期二

Install WebCenter 11.1.1.6 on Linux

Prepare linux.

Remember register linux:

yum install glibc.i686

yum install xorg-x11-apps
xhost +localhost.localdomain
    (xhost +computer name)

[reference also: 

other usefull yum(1) commands:
yum provides '*/xclock'
yum grouplist
yum groupinstall 'X Window System'
]

SQL Server: Restore from file


RESTORE DATABASE PSIWebV3
FROM DISK = 'C:\temp\PSIWebV3.dat'
WITH REPLACE