Java functions with Oracle 10g

I have browsed through other related message threads on this forum and it seems that the general recommendation is to develop stored procedures and functions using PL/SQL.
I need to implement a set of functions that perform date related processing and are self contained (no SQL code or calls). For this I could reuse some Java methods that I have successfully used in an Apache Derby database. In this situation what is your experience related to performance of Java functions compared to PL/SQL? Does the effort of rewriting this code in PL/SQL make sense?

I made some changes on the class posted by to solve the encoding problems with CLOBs.
So here is the result of my job.
import java.sql.SQLException;
import oracle.sql.*;
import java.io.*;
import java.util.zip.InflaterInputStream;
import java.util.zip.DeflaterOutputStream;
* A simple class for LOB compression and decompression in Oracle Database.
* Will work in 8i and better.  Use utl_compress from 10g onward.
public class CompressionUtility {
     private static void pipeStreams( InputStream inStream, OutputStream outStream, int bufferSize) throws IOException {
          //System.out.println("PIPE -");
          byte[] buffer=new byte[bufferSize];
          int cnt;
          while ((cnt=inStream.read(buffer))!=-1) {
               outStream.write(buffer,0,cnt);
     private static void pipeStreams( Reader inStream, Writer outStream) throws IOException {
          //System.out.println("PIPE Reader-Writer");
          int val = 0;
          while ( (val = inStream.read()) != -1 ) {
               outStream.write(val);
     private static void pipeStreams( Reader inStream, OutputStream outStream) throws IOException {
          //System.out.println("PIPE Reader-");
          int val = 0;
          while ( (val = inStream.read()) != -1 ) {
               outStream.write(val);
    private static void pipeStreams( InputStream inStream, Writer outStream) throws IOException {
          System.out.println("PIPE -Writer");
          int val = 0;
          while ( (val=inStream.read()) != -1 ) {
               outStream.write(val);
* Compresses the CLOB into BLOB
* @param clob the source CLOB (plain text)
* @param blob the target BLOB (will hold compressed binary data) it should be
* an empty BLOB retrieved for example with dbms_lob.createtemporary(l_blob,true);
* @throws Exception mostly I/O exception if ever
     public static void compress(CLOB clob, BLOB blob) throws IOException, SQLException {
          //System.out.println("Compressione C->B");
          Reader in=clob.getCharacterStream();
          Writer z=new OutputStreamWriter(new DeflaterOutputStream(blob.getBinaryOutputStream()));
          DeflaterOutputStream z = new DeflaterOutputStream(blob.getBinaryOutputStream());
          int val = 0;
          while ( (val=in.read()) != -1 ) {
               z.write(val);
          pipeStreams(in, z);
          in.close();
          z.close();
* Decompresses the BLOB into CLOB
* @param blob the source BLOB (compressed binary data)
* @param clob the target CLOB (will hold plain text) it should be an empty CLOB
* retrieved for example with dbms_lob.createtemporary(l_clob,true);
* @throws Exception mostly I/O exception if ever
    public static void decompress(BLOB blob, CLOB clob)
      throws IOException, SQLException {
           //System.out.println("Decompressione B->C");
        Writer out=clob.getCharacterOutputStream();
        Reader z=new InputStreamReader(new InflaterInputStream(blob.getBinaryStream()));
          InflaterInputStream z = new InflaterInputStream(blob.getBinaryStream());
        int val = 0;
          while ( (val=z.read()) != -1 ) {
               out.write(val);
        pipeStreams(z, out);
        z.close();
        out.close();
* Compresses the BLOB into BLOB
* @param slob the source BLOB (plain binary data)
* @param blob the target BLOB (will hold compressed binary data) it should be
* an empty BLOB retrieved for example with dbms_lob.createtemporary(l_blob,true);
* @throws Exception mostly I/O exception if ever
    public static void compress(BLOB slob, BLOB blob)
      throws IOException, SQLException {
           //System.out.println("Compressione B->B");
        InputStream in=slob.getBinaryStream();
        DeflaterOutputStream z=new DeflaterOutputStream(blob.getBinaryOutputStream());
        pipeStreams(in, z, blob.getBufferSize());
        in.close();
        z.close();
* Decompresses the BLOB into CLOB
* @param blob the source BLOB (compressed binary data)
* @param slob the target CLOB (will hold plain binary data) it should be an
* empty CLOB retrieved for example with dbms_lob.createtemporary(l_blob,true);
* @throws Exception mostly I/O exception if ever
    public static void decompress(BLOB blob, BLOB slob)
      throws IOException, SQLException {
           //System.out.println("Decompressione B->B");
        OutputStream out=slob.getBinaryOutputStream();
        InflaterInputStream z=new InflaterInputStream(blob.getBinaryStream());
        pipeStreams(z, out, blob.getBufferSize());
        z.close();
        out.close();
}The main problem was with the getAsciiStream() function that has to be replaced by getCharacterStream().

Similar Messages

  • Java function with oracle parameters

    Hi all,
    Does someone knows why i have an error using the java function setDouble with the NLS_TERRITORY = FRANCE and not with NLS_TERRITORY = AMERICA ?
    what have i do to correct it ?
    Thanks in advance

    What is the output of the following, both when
    NLS_TERRITORY = FRANCE and with NLS_TERRITORY = AMERICA ?
    SQL> select to_number('123.45') from dual ;
    TO_NUMBER('123.45')
                 123.45
    1 row selected.
    SQL> select to_number('123,45') from dual ;
    select to_number('123,45') from dual
    ERROR at line 1:
    ORA-01722: invalid number
    SQL>

  • Sqlj runtime error with oracle 10G in Websphere6 or 5.1

    We are trying to migrate from oracle 9i to 10G and we are compiled all our sqlj code with codegen = -oracle option.(previously we used to use codegen=-jdbc which for some reason doesnot work).it compiles fine with out any erros.. But when we try to run then get this exception.
    java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso. java.lang.IllegalArgumentException: SQLJ programs translated with the option -codegen=oracle must be run under Oracle JDBC 9.0.0 or higher. If the Oracle JDBC driver is wrapped, then the wrapper must implement all of the oracle.jdbc.OracleXxxx interfaces. Alternatively, you can translate SQLJ programs either with -codegen=iso.
    at sqlj.runtime.ref.ConnectionContextImpl.getOracleConnection(ConnectionContextImpl.java:167)
    at sqlj.runtime.ExecutionContext$OracleContext.prepareOracleStatement(ExecutionContext.java:1397)
    We are using ojdbc14.jar that came with oracle 10G.
    Hope any one can give any pointers.

    I'm having same issue - but I'm having it when I try to invoke a method that contains a database Object type from a Tibco Business Works Process called a Java Method.
    How exactly do you do the codegen=iso configuration?
    I've tried:
    1. Project Properties / Compiler SQLJ and then select from Code Generation drop down iso.
    2. From Connections / Database / Navigate to package / right-click / Generate Java / Browse to my custom jpub.properties file where I have tried multiple entries such as (by themselves and in some combination.:
    - jpub.codegen=jdbc
    - jpub.codegen=iso
    - jpub.compatible=9i
    - jpub.compatible=8i
    - compatible=both8i
    - jpub.usertypes=oracle
    - jpub.compatible=customdatum
    - jpub.compatible=sqlj
    I've also played with changing from the default some of the Mapping Options in Connections / Database / Navigate to package / right-click / Generate Java / Mapping Options.
    This doc here, says that code should change (section 6 JPublisher Input Files - based on configuration of Input files)
    Oracle® Database
    JPublisher User's Guide
    10g Release 2 (10.2)
    B14188-01
    No matter what I do, the code that gets generate is the same.
    Also, the documentation talks about running things from the command line but how exactly do you do that? Do I need to be in specific directory? I tried the c:\ C:\jdev\system and c\jdev\ and c:jdev\bin and always get error message: 'jpub' is not recognized as an internal or external command, operable program or batch file.
    I've built a java client in JDeveloper to successfully call the same method and I don't see the error.
    Edited by: disaak on Mar 9, 2010 11:51 AM

  • SunOneAppServ with Oracle 10g vers. 10.1.0.3.0

    Hello,
    I'm using two different versions of SunOneAppServer,
    Sun Java System Application Server Enterprise Edition 8.1_02(build b19-p08) and
    Sun Java System Application Server 7 2004Q2UR2.
    These two instances of Application Servers work over two different databases, Oracle 8 and Oracle 10g vers. 10.1.0.3.0.
    When working with Oracle 10 I get locks over some records during transactions and that transactions don't run correctly so the records remain locked and all following transactions go on waiting indefinitely or until I kill the session using toad.
    Looking at the query locking the record it seems to me it's a query done by the application server.
    Using the same software and making the same operation over the database with Oracle 8 this doesn't happen.
    Does anyone has the same problem or knows how to solve it?
    A collegue of mines told me that these versions of application servers doesn't support Oracle 10g. Is it true?

    Both versions of the appserver below will work with Oracle 10g.
    There is not enough details as to asist with your problem, but it could well be a change in semantics for locking in 10g that is causing your issue

  • Error: SAP installation of ERP Sr3 with ORACLE 10g on Windows 2008 server

    Dear all,
    while installaing SAP ERP SR3 with ORACLE 10g on windows 2008 server...
    we are getting error as not support.
    please confirm wether this version of OS is uspported or not.
    thanking you in all,
    by
    Animesh

    actualy we tried to change Oraparam.ini file in the installation folder...
    edited ...  windows= 5.0, 5.1, 6.0
    we had entered 6.0
    Yes - that is necessary.
    and started ... but after starting we are getting ERROR like unKNOWN and installation popup (OUI popup) exiting with .. error popup.
    Yes - because Oracle delivers its own Java version - which is too old to run on Windows 2008.
    if you suggest us to use 2003 64 bit for temporaray .... purpose.
    and is there any specified procedure to UPgrade OS.
    like... DB should be updated before OS upgradation.
    You can run 10.2.0.4 on Windows 2003 x64 nicely and upgrade to Windows 2008. Since there is no "upgrade" (it is the highest version supported) there´s no need to do anything.
    The question you have to ask is:
    Why do you need Windows 2008? Is there any technical implication?
    Markus

  • IAS 65. with Oracle 10g

    Hi,
    Are there any known issues when running iAS 6.5 with Oracle 10g?
    Thanks!

    It has been more than a year since iAS6.5 has been EOLd. I do not think iAS 6.5 has been tested with Oracle 10g. But having said that, I don't think there should be any problems if you use the proper driver and do not use any new features introduced in 10g. There is also a possibility that this will not be a supported configuration if you see any issues.
    I would also like to mention that you should start planning your migration to Sun Java Application Server 8.x as soon as possible.
    Good Luck

  • SAP R/3 4.7 EXt200 installation on RedHat Linux 5.2 with Oracle 10G

    Hi,
    I got this error during Database Instance Installation:
    All file system node operations of table tORA_SapdataNodes processed successfully.
    ERROR      2009-08-31 11:04:39 [iaxxinscbk.cpp:289]
               abortInstallation
    MDB-06020  File not found: [no oracle rdbms file found].
    I am done with CI Installation.
    Any help would be appreciated.

    Hi ,
         First of all please check availability of your OS + DB requiremnts whether it is supported by SAP or not.You can check this at Product Availability Matrix at ::
    http://service.sap.com/pam
         If this support for your environment i.e.RedHat Linux 5.2 with Oracle 10G then be informed that after starting sapinst in step create database it will prompt you for installing your oracle DB. So open a new window & install your databse ,do the patching of your DB & then continue with sapinst after successfull installation of oracle.Rest of details sapinst will prompot you during instal;lation.
        Hope this will guide you for your query.
    Thanks..
    Mohit

  • Using JDeveloper with Oracle 10g Express Edition

    Hi,
    can JDeveloper 11g 11.1.1.4.0 Studio Edition be used to develop applications connection with Oracle 10g Express Edition?
    If not, is there a version downloadable that can?
    TIA

    Yes, it can.
    John

  • Using Java Dictionary With Oracle

    Can Someone tell how can i configure my java dictionary with oracle...Currently if a create a table from my IDE and then deploy it it  deploys to the Default SAP DB ...how do  i directrly create  tables in oracle by just  specifying the Deploy option ...
    And further  on  I want my web Dynpro application to talk with oracle db..how do i acheive this..
    Please Help!!

    Hi, 
             Does this mean that the additional features of The Java Dictionary (bufferring etc ) can only be implemented if we ONLY connect to the SAP DB---- YES
    If I have to utilize the services of Java Dictionary in my application i can only use The SAP DB database -- YES
    You deploy a dictionary project to create a table in the DB.
    When it is a DB created and used by Web AS ,it is possible to create tables in that DB with dictionary project using the standard connection parameters specified in visual admin.
    Java Dictionary purpose is to create a DB abstraction by providing a standard interface to create tables whatever the DB used by WebAS maybe.
    Regards
    Bharathwaj
    Edited by: Bharathwaj R - Hope this makes it clear !

  • Small Business Server 2003 Compatibility with Oracle 10G, licensing?

    Hello all,
    Is Windows SBS 2003 compatible with Oracle 10G, I looked at the compatibility and didn't notice it but I wanted to see if anyone here had any experience with the two.

    The licensing isn't by cpu slots, it's by the number
    of cores times a multipier, which I believe for intel
    is .5, so if you have a cpu w/ 2 cores, you would
    purchase a 1 cpu license. If you have a quad core
    cpu, you would need to purchase a 2 cpu license. I
    would definitely talk to your sales rep about this to
    make sure the multipier is right (and if it has
    changed w/ intel quad technology).Thanks Jim. The multiplier used above for Intel is indeed correct. However, Oracle has (in the last few weeks) introduced the term 'socket' into it's licensing metrics as follows:
    "When licensing Oracle programs with Standard Edition One or Standard Edition in the product name, a processor is counted equivalent to an occupied socket. See http://www.oracle.com/corporate/pricing/technology-price-list.pdf "
    To quote another source (CRN):
    "..Standard Edition was licensed for servers with up to four single-core processor cores. For multicore chips, users could only license it for up to eight cores total. Oracle's formula was to multiply the number of cores by 0.50 to get the CPU license number to determine price. So a four-core box counted as two CPUs.
    Now Standard Edition can be licensed on servers with up to four sockets, or four processors running one-, two- or four-core chips (and possibly a higher number of cores)." This source overlooks to mention that the multiplier relates to Intel!
    Regards,
    Graham
    www.oracleonwindows.co.uk
    Regards, Graham

  • I am trying to connect oracle develper suit form with oracle 10g database

    i am trying to connect oracle develper suit form with oracle 10g database
    but when i pass username and password
    this message apperars
    ORA-12560:TNS:protocol adapter error
    every time even i try to connect Report or Designer each time same problem
    making no connection .
    can any body help can help me to reslove this prblem
    Arshad khan

    Duplicate thread:
    Re: connection problem

  • Is TimesTen 11.2.1 compatible with Oracle 10g (Oracle 10.2.0.5.0)?

    Is TimesTen 11.2.1 compatible with Oracle 10g (Oracle 10.2.0.5.0)?

    Yes it is. Following version are supported for TT 11.2.1.8.x releases
    ■ Oracle 11g Release 2
    ■ Oracle 11g Release 1
    ■ Oracle 10g Release 2 (10.2.0.4.0 or above)

  • Install Oracle 9i client on a computer with Oracle 10g Client

    Hello all!!
    I'm using a computer with Oracle 10g client, and I access two databases. One server has Oracle 10g server, and the other server has Oracle 9i server.
    I want to install 9i client, to have it also in my computer. I haver read that I just have to install it in a different ORACLE_HOME, but I have a doubt.
    If I install 9i client, would I be able to use the utilities, (exp, expddp, sqlldr) of both versions, or which version will be used in the command line for the utilities.
    Thanks a lot!!!

    To start with, Home Selector is a "9i thing" (and older), in 10g there's the OUI -> Installed Products... -> Environment tab instead.
    About the 9i dbca with other Oracle products installed. If you use launch.exe to start via dbca start menu shortcut, it uses ora92\assistants\dbca as working directory ("start from"). So when not looking for "numbered dlls" like oracore9.dll, a later/different version will be loaded if earlier in path, since loading goes through jre directories, ora92\assistants\dbca, then the dir's from path variable. From there it may start to link in libraries from different homes (on my laptop, "launch.exe dbca" uses files from 2 additional home paths!)
    But, if you instead use dbca.bat started from ora92\bin, it will look in the right directories first and there's no dll mess-up. (But only when using the correct cwd!)
    Plain and simple: stay very far away from multiple-general-home installs. It is possible to install allright, in different homes and all very nicely, but there will be pain when you decide to use the stuff (perhaps with sql*plus as the only exception, but I've run into bugs with that too).
    Message was edited by:
    orafad

  • Oracle 11g compatibility with oracle 10g and 9i?

    Hi All
    I have some queries on 11g compatibility.
    Is oracle 11g client compatible with oracle 10g client which is already installed on desktop?
    If yes any changes to be done and where?
    Is oracle 11g compatible with oracle 10g/9i on the same server where 10g/9i are installed?
    Regards

    Thanks Justin Thats right ...
    Problem elaboration is as follows
    We currently have an application which requires oracle 10g(10.2.0.3) client to connect to database from user desktops. As
    part of new application development the oracle 11g clients need to be installed on all the user deskotps.
    The complete application software along with oracle client 11g has to be roled out on these desktop as part of
    implementaion of new application besides the existing application(The application software is packaged along with oracle
    10g client).
    We would like to understand if there is any software provided by oracle using which we can switch between different oracle
    versions while accessing the respective applications simultaneously. Also are there any known bugs/issues in running
    oracle 10g client and oracle 11g client together on the same user desktops with different oracle homes?

  • Does Informatica 7.1 work with Oracle 10g?

    Hi All,
    I have Oracle 10g (10.2.0.1.0) and I just installed Informatica 7.1. While creating a new repository in Informatica Repository Admin Console, I am getting error as:
    "Unable to create the repository content. Make sure that the database connection and the license keys are correct. Check the activity log for more details."
    I confirmed that the license keys are correct. The database connection is also good as I could connect using the same username/password in SQLPlus. The activity log says:
    WARNING : RS_39204 [Mon Mar 22 15:05:38 2010] : (5160|5392) Bad config file [Config\infrepo-es.cfg]. Has it been manually named and placed in the Config directory? The expected name is [Config\_Yrepository_0name_Z-es.cfg].
    ERROR : RS_39194 [Mon Mar 22 15:51:52 2010] : (5160|5568) Failure in running command-line request type[100401] [pmrepagent create -r "Info_Repo" -t "Oracle" -u infrep -c orcl -d "MS1252" -h sathe-3766a91ad -o 9999  -a Info_0Repo-es.lic -H "sathe-3766a91ad" -O 5001 -K 2082340862]. Error is [An error occurred while creating the repository.
    I did not change anything manually,as it says in the warning. I have no idea what the error says.
    My friend has Oracle 9i and he do not get any error like this. So does Informatica 7.1 works with Oracle 10g ?
    Please help.
    Yogini                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I found that with Oracle 10g you have to grant all DBA privileges to the repository user. This is not needed in Oracle 9i. Thats why I was getting error.
    Now it works fine.
    Thanks!
    Yogini

Maybe you are looking for

  • Java web start running on windows NT4 work station

    I have installed java web start on a windows NT4 work station (service pack 6) with a directx v5. I successfuly launch the sun applications such as swing set 2, but I have some troubles concerning our software which used another look and feel than th

  • Webcam not working with adobe air

    hey frnds, i'm trying to capture webcam snaps and storing it on local desktop. Below code of capuring snap is working with flex but same code not working in adobe air. I'm using Adobe Flash builder beta 2 is any setting is required to use webcam with

  • Creating custom interface panels in LabVIEW for use in VBAI.

    Greetings everyone, I hope that someone can give me some insight with the following problem. I have on my bench a 1742 Smart Camera and a computer loaded with VBAI 3.6 and LabVIEW 8.6 Pro (all the latest and greatest stuff). Up to this point, everyth

  • Mass change recipient and unloading point on material

    Hello Experts, Is there a way to mass change recipient and unloading point on materials in PS? It is quite a task to go into every parts general data screen and enter it there rgds GAR

  • Change language Prefs in App Store

    living in the Netherlands but english speaking, how do I change to language prefs to English in the App Store my system is in English but for some reason or other the App Store is in Dutch