Thursday, February 20, 2014

java.lang.OutOfMemoryError: Java heap space when Jdeveloper integrated with SVN

When we have jdeveloper integrated with SVN, jdeveloper requires more heap space and below error might occur.

Uncaught exception
java.lang.OutOfMemoryError: Java heap space
  j.util.Arrays.copyOf(Arrays.java:2882)
  j.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
  j.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
  j.lang.StringBuffer.append(StringBuffer.java:224)
  org.tmatesoft.svn.core.SVNErrorMessage.getFullMessage(SVNErrorMessage.java:257)
  org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:58)
  org.tmatesoft.svn.core.internal.wc.admin.SVNAdminAreaFactory.open(SVNAdminAreaFactory.java:163)
  org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess.doOpen(SVNWCAccess.java:364)
  org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess.open(SVNWCAccess.java:272)
  org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess.open(SVNWCAccess.java:265)
  org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess.openAnchor(SVNWCAccess.java:145)
  org.tmatesoft.svn.core.wc.SVNStatusClient.doStatus(SVNStatusClient.java:320)
  org.tmatesoft.svn.core.javahl.SVNClientImpl.status(SVNClientImpl.java:296)
  org.tmatesoft.svn.core.javahl.SVNClientImpl.status(SVNClientImpl.java:278)
  org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter.getStatus(AbstractJhlClientAdapter.java:480)
  org.tigris.subversion.svnclientadapter.svnkit.SvnKitClientAdapter.getStatus(SvnKitClientAdapter.java:141)
  org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter.getStatus(AbstractJhlClientAdapter.java:466)
  o.ji.vcs.svn.SVNURLInfoCacheSimpleStrategy.getURLInfo(SVNURLInfoCacheSimpleStrategy.java:79)
  o.ji.vcs.svn.SVNURLInfoCache.getLastChangedRevision(SVNURLInfoCache.java:69)
  o.ji.vcs.svn.SVNOverlayProducer.createTooltip(SVNOverlayProducer.java:240)
  o.ji.vcs.svn.SVNOverlayProducer.getDecoratedOverlay(SVNOverlayProducer.java:144)
  o.ji.vcs.svn.SVNOverlayProducer.produceOverlay(SVNOverlayProducer.java:113)
  o.j.vcs.spi.VCSOverlayItemProducer.produceOverlays(VCSOverlayItemProducer.java:83)
  o.j.vcs.spi.VCSOverlayItemProducer.getOverlayItems(VCSOverlayItemProducer.java:65)
  o.j.vcs.spi.VCSNodeOverlayTracker.getOverlays(VCSNodeOverlayTracker.java:288)
  o.i.explorer.IconOverlayTracker.processPendingNodes(IconOverlayTracker.java:574)
  o.i.explorer.IconOverlayTracker.access$1400(IconOverlayTracker.java:69)
  o.i.explorer.IconOverlayTracker$7.run(IconOverlayTracker.java:487)
  j.util.TimerThread.mainLoop(Timer.java:512)
  j.util.TimerThread.run(Timer.java:462)





The heap space can be increased for JDeveloper by modifying the ide.conf and jdev.conf files of your jdeveloper installation and below is a sample value.
$installationdir\jdeveloper\ide\bin\ide.conf 

AddVMOption  -Xmx1024M
AddVMOption  -Xms128M
$installationdir\jdeveloper\jdev\bin\jdev.conf

AddVMOption  -XX:MaxPermSize=1024M

The maximum size depends on the operating system and if the errors still persist we can disable the SVN connection.

 JDeveloper > Choose Versioning>Configure  and Uncheck 'Versioning support for Subversion'



Tools like Tortoise SVN can be used to do the version control.



Friday, February 7, 2014

Java Connect to Informatica Data Service using jdbc

We had a requirement to connect to informatica and get the values from the virtual table.Using the below java code we were able to connect and fetch the records.


The Infadsjdbc.jar will need to be kept in the classpath.


 package com.sample;  
 import java.sql.Connection;  
 import java.sql.DriverManager;  
 import java.sql.ResultSet;  
 import java.sql.SQLException;  
 import java.sql.Statement;  
 import java.util.ArrayList;  
 import java.util.List;  
 /**  
 * @author venky  
 *  
 */   
     public class ConnectInfaImpl{   
     static final String DB_URL = "jdbc:informatica:sqlds//@hostname:port?dis=DIS&sqlds=N_Dummy.DS_N_Dummy";  
     static final String USER = "Administrator";  
     static final String PASS = "********";  
     public static void main(String[] args) {  
     Connection conn = null;  
     Statement stmt = null;  
     List al =null;  
     try{  
      //STEP 2: Register JDBC driver  
      Class.forName("com.informatica.ds.sql.jdbcdrv.INFADriver");  
      //STEP 3: Open a connection  
      System.out.println("Connecting to database...");  
       System.out.println("DB_URL==>"+DB_URL);  
       System.out.println("USER==>"+USER);  
       System.out.println("PASS==>"+PASS);  
       System.out.println("Connecting to database...");  
       conn = DriverManager.getConnection(DB_URL,USER,PASS);  
      //STEP 4: Execute a query  
      System.out.println("Creating statement...");  
      stmt = conn.createStatement();  
      String sql;  
      sql = "select * from my_table";  
      ResultSet rs = stmt.executeQuery(sql);  
      //STEP 5: Extract data from result set  
       al =new ArrayList();  
      while(rs.next()){  
            System.out.println("result==:"+rs.next());  
      }  
     }catch(SQLException se){  
      //Handle errors for JDBC  
      se.printStackTrace();  
     }catch(Exception e){  
      //Handle errors for Class.forName  
      e.printStackTrace();  
     }finally{  
      //finally block used to close resources  
      try{  
        if(stmt!=null)  
         stmt.close();  
      }catch(SQLException se2){  
        se2.printStackTrace();  
      }  
      try{  
        if(conn!=null)  
         conn.close();  
      }catch(SQLException se){  
        se.printStackTrace();  
      }  
     }  
     System.out.println("Goodbye!");  
   }  
   }