Skip to main content

Posts

Showing posts from January, 2012

Convert Clob to String in Java

import java.sql.Clob; private String clobToStringConversion(Clob clb) throws IOException, SQLException {         if (clb == null) {             return null;         }         StringBuffer str = new StringBuffer();         String data = null;         BufferedReader bufferRead = new BufferedReader(clb.getCharacterStream());         while ((data = bufferRead.readLine()) != null) {             str.append(data);         }         return str.toString();     }

Calling Oracle Stored Procedure using EclipseLink/Toplink JPA

Lets assume that the Stored Procedure is something like this MY_PROCEDURE (inputVal number, outputVal out varchar2) @ annotations approach ------------------------------------- ===>  Define annotations following way in the entity class @Entity  @NamedStoredProcedureQuery(name = " xxMethod Namexx ", procedureName = " MY_PROCEDURE ", parameters = {         @StoredProcedureParameter(name = " inputVal ", queryParameter = " inputVal ", direction = Direction.IN, type = Long.class),         @StoredProcedureParameter(name = " outputVal ", queryParameter = " outputVal ", direction = Direction.OUT, type = String.class) }) @Table(name = " XXXTABLENAMEXXX ") ==> Calling method of Interface should be as follows  String Method Name (@Param(" inputVal ")Long inputVal,@Param(" outputVal ")String outputVal ) @ declaring in orm.xml approach -------------------------------------   ...