PL/SQL vs Java vs C++?
I have developed an inventory control application in MS Access & VBA that has been instrumental in saving my company $6 million so far, with at least another 4 to 5 million over the next 18 months. We are a processing plant and part of a global group of mining companies. My tool has sparked interest across the group and I am about to release an evaluation copy to other sites. Our corporation is in the process of aggressively standardising on SAP (and I extract the data from our SAP system)with Oracle of various flavours being the underlying DB as far as I can tell.
Access is a superb prototyping tool and an excellent standalone platform, however I am considering something rather more professional. For example, to generate the statistical data for 23,000 items with 50 months consumption in VBA takes about 45 minutes, tests indicate the same can be done in C++ in under a minute and the last time I used PL/SQL to calculate Single Exponentially Smooothed Forecasts for the same data set it was done in a matter of seconds.
I have a little Oracle knowledge, I had been studying for certification but dropped it in favour of a B.Comp Sc which I have commenced this year. And now to the question.
What would be the best way to proceed? Learn enough PL/SQL to write the statistical and forecasting engine and use Java to develop a front end? Or C++ and Java? Or <cough> Access and <shudder> ODBC? All of this of course would depend on me convincing our corporate IT department to letting me write an application that digs under SAP, (I know when I first asked for access to SQLplus to get to our data under SAP it felt like I had offered to buy the IT managers daughter).
Looking forward to hearing what real Developers/Analysts would do ( I am but a humble storeman).
Part of the answer will depend on how you plan to deploy the application. If you have a few, local clients you could go with the traditional client/server model. If you have a lot of clients and/or they are spread out over a relatively large area (like a campus setting), a web front-end will save you a lot of hassels down the road when it comes time to upgrade.
Regardless of the the front end, I can tell you that I have been greatly impressed with the throughput you can get by moving most of the code to PL/SQL packages. A few years ago we reworked a VB/Oracle app by moving a lot of the code out of VB and into packages, leaving the client to essentially call procedures and format the output. We had more than a 3x performance increase on the same hardware and our network utilization decreased noticably.
I am now in the process of replacing the client code with Java servlets/JSP, primarily because of the maintenance hassles I mentioned earlier. There are some limitations with an HTML page but most of these have been cosmetic so far.
We are still relying heavily on PL/SQL packages. The servlet code basically gets a request, calls a package to get the data, then hands the results to a JSP page. The JSP then formats the output and sends it to the client. We are little more than halfway through the re-write, but it appears performance will increase again. Not as noticably as before, but I will take what I can get. As you have seen, once something is rolled out it always ends up getting used more than you anticipated. Better to over-engineer now than have to patch it once it is live.
HTH
Similar Messages
-
Partner Application written in other language than PL/SQL and Java
I have an application written in another language than PL/SQL or Java. I want to integrate this application as an Partner apps where I use the same user repository as Portal.
Can I integrate the application by calling a stored PL/SQL-procedure based on the PLSQL SSO APIs examples that authenticates the user based on the username/password in portal and redirects the user to the application ?
Are there any examples / references where this has been done ?
JensCheck out the PDK referance for URL-Services, which allow you to integrate with any web based service/content.
http://portalstudio.oracle.com/servlet/page?_pageid=350&_dad=ops&_schema=OPSTUDIO -
What is the diffrence between package javax.sql and java.sql
Is javax designed for J2EE?
And when to use package javax?Hi,
What is the diffrence between package javax.sql and java.sql?The JDBC 2.0 & above API is comprised of two packages:
1.The java.sql package and
2.The javax.sql package.
java.sql provides features mostly related to client
side database functionalities where as the javax.sql
package, which adds server-side capabilities.
You automatically get both packages when you download the JavaTM 2 Platform, Standard Edition, Version 1.4 (J2SETM) or the JavaTM 2, Platform Enterprise Edition, Version 1.3 (J2EETM).
For further information on this please visit our website at http://java.sun.com/j2se/1.3/docs/guide/jdbc/index.html
Hope this helps.
Good Luck.
Gayam.Srinivasa Reddy
Developer Technical Support
Sun Micro Systems
http://www.sun.com/developers/support/ -
How to generate XML from relational data : PL/SQL or Java
I'm new to Oracle XML and would appreciate some advice. I've been asked to generate XML documents from data stored in relational tables. The XML documents must be validated against a DTD. We will probably want to store the XML in the database.
I've seen a PL/SQL based approach as follows :
1.Mimic the structure of the DTD using SQL object types 2.Assign the relational data to the object type using PL/SQL as required
3.Use the SYS_XMLGEN package to render the required XML documents from the SQL objects
However, creating the object types seems to be quite time consuming (step 1 above) for anything other than the simplest of XML documents.
I've also seen that there is the Java based approach, namely :
1. Use the XML generator to build Java classes based on a DTD.
2. Use these classes to build the required XML
On the face of it, the Java based approach seems simpler. However, I'm not that familiar with Java.
Which is the best way to proceed ? Is the PL/SQL based approach worth pursuing or should I bite the bullet and brush up my Java ?
Is it possible to use a combination of PL/SQL and Java to populate the dtd generated java classes (step 2 of the Java approach) to reduce my learning curve ?
Thanks in advanceTo help answer your questions:
1) Now, in 9iR2, you can use SQL/XML as another choice.
2) You can also use XSU to generate the XML and use XSLT to transform it to a desired format instead of using object views if possible.
3) XDK provide Class generator support to populate XML data to Java classes. -
PL/SQL w/ Java to run OS batch file crashes Oracle
I followed instructions from "Ask Tom" on using PL/SQL with Java to execute an OS batch file. For testing purposes, my batch file does nothing more than display the date and time from the OS.
However, when I run the PL/SQL that executes this simple batch file repeatedly - anywhere from two to four times, the Oracle instance crashes abruptly. Nothing is written to the alert log. No trace files are created.
Here is a sample session:
SQL*Plus: Release 9.0.1.3.0 - Production on Wed Mar 24 10:04:26 2004
(c) Copyright 2001 Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> set serveroutput on size 1000000
SQL> exec dbms_java.set_output(1000000) ;
PL/SQL procedure successfully completed.
SQL> begin
2 rc('c:\dba_tools\jobs\test.cmd') ;
3 end ;
4 /
C:\Ora9ir2\DATABASE>date /t
Wed 03/24/2004
C:\Ora9ir2\DATABASE>time /t
10:05 AM
PL/SQL procedure successfully completed.
SQL> begin
2 rc('c:\dba_tools\jobs\test.cmd') ;
3 end ;
4 /
C:\Ora9ir2\DATABASE>date /t
Wed 03/24/2004
C:\Ora9ir2\DATABASE>time /t
10:06 AM
PL/SQL procedure successfully completed.
SQL>
Shortly after the second "run", Oracle crashed. All I received was the following error message:
Unhandled exception in oracle.exe (ORAJOX9.DLL): 0xC0000005: Access Violation
Here is the Java procedure at the heart of my PL/SQL:
create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;
public class Util extends Object
public static int RunThis(String args)
Runtime rt = Runtime.getRuntime();
int rc = -1;
try
Process p = rt.exec(args);
int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
catch (Exception e)
e.printStackTrace();
rc = -1;
finally
return rc;
I am running Oracle 9i rel. 2 installed on my PC under Windows XP Professional (Service Pack 2). My knowledge of Java is next to nothing.
Can anyone give me an idea(s) as to what might be causing Oracle to crash?
Thanks.Using 9.2.0.4 I made the following adjustments and it seems to run as often as I care to do it:
Java changes:
create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;
public class Util extends Object
public static void RunThis(java.lang.String args)
Runtime rt = Runtime.getRuntime();
int rc = -1;
try
Process p = rt.exec(args);
int bufSize = 4096;
BufferedInputStream bis =
new BufferedInputStream(p.getInputStream(), bufSize)
int len;
byte buffer[] = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
catch (Exception e)
e.printStackTrace();
finally
PL/SQL Wrapper :
create or replace procedure rc (cmd VARCHAR2) as
language java name 'Util.RunThis(java.lang.String)';
Execution:
begin
rc('c:\dba_tools\jobs\test.cmd');
end ;
D:\oracle\ora92\DATABASE>date /t
Fri 03/26/2004
D:\oracle\ora92\DATABASE>time /t
10:48 AM
PL/SQL procedure successfully completed.
SQL> /
D:\oracle\ora92\DATABASE>date /t
Fri 03/26/2004
D:\oracle\ora92\DATABASE>time /t
10:48 AM
PL/SQL procedure successfully completed.
SQL> /
D:\oracle\ora92\DATABASE>date /t
Fri 03/26/2004
D:\oracle\ora92\DATABASE>time /t
10:49 AM
PL/SQL procedure successfully completed.
SQL> /
D:\oracle\ora92\DATABASE>date /t
Fri 03/26/2004
D:\oracle\ora92\DATABASE>time /t
10:50 AM
PL/SQL procedure successfully completed.
SQL>
The only thing I really changed was the reurn value from the java procedure. If it has a return value then it should be declared as a function, not a procedure. Since you probably (apparently) weren't using the return value I dropped it and made it a procedure. -
PL/SQL to Java Interface - Overwhelming Overhead?
My company is running Oracle 10g R2. I am currently exploring the use of java classes from PL/SQL. This is because we have multiple code bases, including Java, PowerBuilder (which can interface with Java), and PL/SQL (which can interface with Java).
Doing some performance testing, I found some rather alarming results. Running a simple java function 1 million times, I tested performance of PL./SQL to java and PowerBuilder to Java.
In PL/SQL, the 1 mil calls executed in ~120 s.
In PowerBuilder, the 1 mil calls executed in ~54 s.
Is it possible that our database is incorrectly configured for best java performance? Not only does it appear that PowerBuilder, a much less pervasive language than PL/SQL, is over twice as fast, but the PB test was run on my laptop, which is no where near as powerful as the database server that the PL/SQL procedure ran against, leading me to believe that the performance gap is actually much wider.
Anyone have any tips to improve the performance? Or is this simply the nature of the beast? I can't seem to find any posts on the net about people experiencing huge PL/SQL to Java overhead, so I'm hoping it is just something I am doing wrong.
Thanks for your help!
-Brett BirschbachBelow is my test code. Any suggestions are appreciated.
Thanks!
-Brett
==================================================
Java Class:
public class TestConvert {
// For running straight from Java
public static void main(String[] args){
System.out.println(callAndTime());
// For running 1 mil calls with only one call from PowerBuilder or PL/SQL
public static long callAndTime(){
TestConvert.convertEsnDecToHex("13005454488");
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++){
TestConvert.convertEsnDecToHex("13005454488");
long end = System.currentTimeMillis();
return end-start;
// For performing the actual work
public static String convertEsnDecToHex(String esn) {
String result = null;
result = Integer.toHexString(new Integer(esn.substring(0, 3)).intValue());
result += Integer.toHexString(new Integer(esn.substring(3)).intValue());
return result.toUpperCase();
// Non-static wrapper necessary for PowerBuilder
public String callAndTimeNS(){
return String.valueOf(callAndTime());
// Non-static wrapper necessary for PowerBuilder
public String convertEsnDecToHexNS(String esn){
return convertEsnDecToHex(esn);
}PL/SQL Script for 1 Million Java Calls:
DECLARE
var VARCHAR2( 20 );
t_begin NUMBER;
t_end NUMBER;
BEGIN
var := testconvert.convertesndectohex( '13005454488' );
t_begin := DBMS_UTILITY.get_time;
FOR i IN 1 .. 1000000
LOOP
var := testconvert.convertesndectohex( '13005454488' );
END LOOP;
t_end := DBMS_UTILITY.get_time;
DBMS_OUTPUT.put_line( var );
DBMS_OUTPUT.put_line( ( t_end - t_begin ) / 100 || ' seconds' );
END;
/PowerBuilder for 1 Million Java Calls:
EJBConnection lEJBConn
TestConvert lnv_test
String ls_ret
Long i
Time t_begin, t_end
lEJBConn = CREATE EJBConnection
lEJBConn.CreateJavaInstance( lnv_test, "TestConvert")
ls_ret = lnv_test.convertesndectohexns("13005454488")
t_begin = now()
FOR i = 1 TO 1000000
ls_ret = lnv_test.convertesndectohexns("13005454488")
NEXT
t_end = now()
MessageBox("Hex Version",ls_ret + " - " + String(SecondsAfter(t_begin, t_end)) + " seconds")
DESTROY lEJBConn -
PL/SQL and Java Swing interface
Everybody in this forum knows that Oracle is the best database around
with many functionalities, stability, performance, etc. We also know
that PL/SQL is a great language to manipulate information directly
in the database with many built in functions, OOP capability,
transaction control, among other features. Today an application that
manipulates information, which needs user interface, requires components
to be developed using different technologies and normally running in
different servers or machines. For example, the interface is done using
a dynamic HTML generator like JSP, PHP, PL/SQL Web Toolkit, etc.
This page is executed in an application server like Oracle iAS or
Tomcat, just to name two, which in turn access a database like Oracle to
build the HTML. Also rich clients like Java applets require an intermediate
server to access the database (through servlets for example) although
it is possible to access the database directly but with security issues.
Another problem with this is that complexity increases a lot, many
technologies, skills and places to maintain code which leads to a greater
failure probability. Also, an application is constantly evolving, new
calculations are added, new tables, changed columns. If you have an
application with product code for example and you need to increase its
size, you need to change it in the database, search for all occurrences
of it in the middle-tier code and perhaps adjust interfaces. Normally
there is no direct dependency among the tier components. On another
issue, many application interfaces today are based on HTML which doesn't
have interactive capabilities like rich-client interfaces. Although it
is possible to simulate many GUI widgets with JavaScript and DHTML, it is
far from the interactive level we can accomplish in rich clients like
Java Swing, Flash MX, Win32, etc. HTML is also a "tag-based" language
originally created to publish documents so even small pages require
many bytes to be transmitted, far beyond of what we see on the screen.
Even in fast networks you have a delay time to wait the page to be
loaded. Another issue, the database is in general the central location
for all kinds of data. Most applications relies on it for security,
transaction and availability. My proposal is to use Oracle as the
central location for interface, processing and data. With this approach
we can create not only the data manipulation procedures in the database,
but procedures that also control and manage user interfaces. Having
a Oracle database as the central location for all components has many
advantages:
- Unique point of maintenance, backup and restore
- Integrated database security
- One language for everything, PL/SQL or Java (even both if desired)
- Inherited database cache, transaction and processing optimizations
- Direct access to the database dictionary
- Application runs on Oracle which has support for many platforms.
- Transparent use of parallel processing, clusters and future
background technologies
Regarding the interface, I already created a Java applet renderer
which receives instructions from the database on how to create GUI
objects and how to respond to events. The applet is only 8kb and can
render any Swing or AWT object/event. The communication is done
through HTTP or HTTPS using Oracles's MOD_PLSQL included in the Apache
HTTP server which comes with the database or application server (iAS).
I am also creating a database framework and APIs in PL/SQL to
create and manipulate the client interface. The applet startup is
very fast because it is very small, you don't need to download large
classes with the client interface. Execution is done "on-demand"
according to instructions received from the database. The instructions
are very optimized in terms of network bandwidth and based on preliminary
tests it can be up to 1/10 of a similar HTML screen. Less network usage
means faster response and means that even low speed connections will
have a good performance (a future development can be to use this in
wireless devices like PDAs e even cell phones, just an idea for now).
The applet can also be executed standalone by using Java Web Start.
With this approach no business code, except the interface, is executed
on the client. This means that alterations in the application are
dynamically reflected in the client, no need to "re-download" the
application. Events are transmitted when required only so network
usage is minimized. It is also possible to establish triggering
events to further reduce network usage. Since the protocol used is
HTTP (which is stateless), the database framework I am creating will
be responsible to maintain the state of connections, variables, locks
and session information, so the developer don't need to worry about it.
The framework will have many layers, from communication up to
application so there will be pre-built functions to handle queries,
pagination, lock, mail, log, etc. The final objective is to have a
rich client application integrated into the database with minimum
programming and maintenance requirements, not forgetting customization
capabilities. Below is a very small example of what can de done. A
desktop with two windows, each window with two fields, a button with an
image to switch the values, and events to convert the typed text when
leaving the field or double-clicking it. The "leave" event also has an
optimization to only be triggered when the text changes. I am still
developing the framework and adjusting the renderer but I think that all
technical barriers were transposed by now. The framework is still in
the early stages, my guess is that only 5% is done so far. As a future
development even an IDE can be created so we have a graphical environment
do develop applications. I am willing to share this with the PL/SQL
community and listen to ideas and comments.
Example:
create or replace procedure demo1 (
jre_version in varchar2 := '1.4.2_01',
debug_info in varchar2 := 'false',
compress_buffer in varchar2 := 'false',
optimize_buffer in varchar2 := 'true'
) as
begin
interface.initialize('demo1_init','JGR Demo 1',jre_version,debug_info,compress_buffer,optimize_buffer);
end;
create or replace procedure demo1_init as
begin
toolkit.initialize;
toolkit.create_icon('icon',interface.global_root_url||'img/switch.gif');
toolkit.create_internal_frame('frame1','Frame 1',50,50,300,136);
toolkit.create_label('frame1label1','frame1',10,10,50,20,'Field 1');
toolkit.create_label('frame1label2','frame1',10,40,50,20,'Field 2');
toolkit.create_text_field('frame1field1','frame1',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
toolkit.create_text_field('frame1field2','frame1',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
toolkit.set_text_field_event('frame1field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
toolkit.set_text_field_event('frame1field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
toolkit.set_text_field_event('frame1field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
toolkit.set_text_field_event('frame1field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
toolkit.create_button('button1','frame1',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
toolkit.set_button_event('button1',toolkit.action_performed_event,'demo1_switch_fields(''frame1field1'',''frame1field2'')','frame1field1:'||toolkit.get_text_method||',frame1field2:'||toolkit.get_text_method);
toolkit.create_internal_frame('frame2','Frame 2',100,100,300,136);
toolkit.create_label('frame2label1','frame2',10,10,50,20,'Field 1');
toolkit.create_label('frame2label2','frame2',10,40,50,20,'Field 2');
toolkit.create_text_field('frame2field1','frame2',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
toolkit.create_text_field('frame2field2','frame2',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
toolkit.set_text_field_event('frame2field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
toolkit.set_text_field_event('frame2field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
toolkit.set_text_field_event('frame2field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
toolkit.set_text_field_event('frame2field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
toolkit.create_button('button2','frame2',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
toolkit.set_button_event('button2',toolkit.action_performed_event,'demo1_switch_fields(''frame2field1'',''frame2field2'')','frame2field1:'||toolkit.get_text_method||',frame2field2:'||toolkit.get_text_method);
end;
create or replace procedure demo1_set_upper as
begin
toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,upper(interface.array_event_value(1)));
toolkit.set_text_field_event(interface.global_object_name,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
end;
create or replace procedure demo1_set_lower as
begin
toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,lower(interface.array_event_value(1)));
toolkit.set_text_field_event(interface.global_object_name,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
end;
create or replace procedure demo1_switch_fields (
field1 in varchar2,
field2 in varchar2
) as
begin
toolkit.set_string_method(field1,toolkit.set_text_method,interface.array_event_value(2));
toolkit.set_string_method(field2,toolkit.set_text_method,interface.array_event_value(1));
toolkit.set_text_field_event(field1,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(2)),'false');
toolkit.set_text_field_event(field2,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
toolkit.set_text_field_event(field1,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(2)),'false');
toolkit.set_text_field_event(field2,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
end;Is it sound like Oracle Portal?
But you want to save a layer 9iAS.
Basically, that was the WebDB.(Oracle changed the name to Portal when version 3.0)
Over all, I agree with you.
>>Having a Oracle database as the central location for all components has many
>>advantages:
>>
>>- Unique point of maintenance, backup and restore
>>- Integrated database security
>>- One language for everything, PL/SQL or Java (even both if desired)
>>- Inherited database cache, transaction and processing optimizations
>>- Direct access to the database dictionary
>>- Application runs on Oracle which has support for many platforms.
>>- Transparent use of parallel processing, clusters and future
>>background technologies
I would like to build 'ZOPE' inside Oracle DB as a back-end
Using Flash MX as front-end.
Thomas Ku. -
Xml dom with pl/sql or java
Hi,
For increase speed an procedure with xmldom, wich langage can I use ? pl/sql or java
Thanks
BenI also recall readings somewhere how Oracle have coded the database packages into native C to boost performance, but for the life of me I can't recall where it was now.
I've not done any Java parsing work, but I have been using PL/SQL to parse XML Schema documents (which are in effect XML documents so there's no difference there really). I found that all I needed to be able to parse the XML schema so that I could navigate through the document and carry out my own processing was the use of the DBMS_XMLDOM package. This allowed me to navigate from the root element down through the siblings and children elements and extract the attributes and any data that was required on the way.
The Oracle PL/SQL Packages and Types Reference details all the available built-in packages sufficiently well.
Regards -
File Deletion from PL/SQL using Java
I'm able to delete a file on the OS from PL/SQL by calling a java class. But there is a problem if I am trying to delete any file located on any machine othere than the one on which the Database is hosted.
Can anyone tell me how delete a file which is on anothere machin using PL/SQL with Java ?You can use a FTP Call: http://www.savarese.org/oro/software/NetComponents.html
-
Execution/ better performace on sql or java)
hi experts,
i would like to began a topic on better performance or best pratice adf using sql or java codes.
basically am from Oracle forms - pl/sql background. well i knew about java and i have some awareness on Exception(my code maynt be consistent somtimes(run time) or or in other words sometimes ran into run time exceptions based on the user entries).
say as example: consider this scenario.
i had input lov named as employee, if the entered data is not avaiable i would throw an entered employee is not found.
basically i would like to follow this method.
method 1:
vo query :
Select * From sometable
Where Btx = :px1 And
:px2 Between Btbx And Btbxo And Btb_x=:pxamimpl.code
public void Validatex(String px ,String px1, oracle.jbo.domain.Date px2 ) {
someVOImpl vo1 = (someVOImpl)this.getsomeRequest1();
Row r = vo1.getCurrentRow();
String Schx = (String)r.getAttribute("Btrxxx");
if(Schxx.equals("somevalue"))
xffVOImpl vo2 = (xffVOImpl)this.getxkEff1();
vo2.setNamedWhereClauseParam("px", px.toString());
vo2.setNamedWhereClauseParam("px1", px1.toString());
vo2.setNamedWhereClauseParam("px2", px2);
vo2.executeQuery();
if(vo2.getEstimatedRowCount() == 0)
throw new JboException("xxx Not Found");
if(Scheme.equalsIgnoreCase("somevalue"))
xxffVOImpl vo = (xxxffVOImpl)this.getxxkEff1();
vo.setNamedWhereClauseParam("px", px);
vo.setNamedWhereClauseParam("px1", px1);
vo.setNamedWhereClauseParam("px2", px2);
vo.executeQuery();
if(vo.getEstimatedRowCount() == 0)
throw new JboException("xxx Not Found");
}this will exposed as method called in when valuechange listeners. it's work fine.
my question is :
if i wrote same thing in java like this. i think it take some more time than above methods sometimes exceptions comes out.
public void Validatex(String px ,String px1, oracle.jbo.domain.Date px2 ) {
some vos... as like same of which i mentioned above
using iterator iterate each and every row.
try{
for (.......)
if(...)
else
} } catch()
}which would be best practice.? i hope that iterating each and every row taking little bit amount of time.
but i feel that method1 without any exception and smarter time produce result.
so people suggest me ? where am which would be better approach.
thanks&&REgards
adf7.Hi,
before went into testing. could please tel me. how to get/display both of the method time taken to execute and some memory consumption.See if this helps..
public HashMap doSomethingInProc(Long serialNo, Long custNo) {
HashMap map = new HashMap();
CallableStatement cs = null;
String stmt = "sy_pkg_xx.p_doSomethingInProc(?,?,?,?)";
logger.info("execute " + stmt);
try {
cs = getCurrentConnection().prepareCall("begin " + stmt + "; end;");
cs.registerOutParameter("O_2", OracleTypes.VARCHAR);
cs.registerOutParameter("O_1", OracleTypes.NUMBER);
cs.setLong("I_SerialNo", serialNo);
cs.setLong("I_CustNo", custNo);
Long start = System.currentTimeMillis();
cs.execute();
Long end = System.currentTimeMillis();
logger.info("time taken to execute " + stmt + " : " + (end - start) + " ms.");
map.put("1", cs.getString("O_1"));
map.put("2", cs.getLong("O_2"));
logger.info("map : " + map.toString());
} catch (SQLException e) {
throw new JboException(e);
}finally{
if(cs!=null){
try{
cs.close();
}catch(SQLException ex){
return map;
private Connection getCurrentConnection() {
Statement st = null;
try {
st = getDBTransaction().createStatement(0);
return st.getConnection();
} catch (SQLException s) {
s.printStackTrace();
return null;
} finally {
if (st != null)
try {
st.close();
} catch (SQLException s2) {
}The main code is
Long start = System.currentTimeMillis();
cs.execute();
Long end = System.currentTimeMillis();
logger.info("time taken to execute " + stmt + " : " + (end - start) + " ms.");In fact i say that every body should use this approach while executing any procedure or function as it helps us to track which part of application is running slow..
Hope this helps !!!
Regards,
Edited by: Santosh Vaza on Jul 16, 2012 3:50 PM -
Some problems about oracle.sql.CharacterSet.java
When I debugging a program,which should execute an insert statement into Oracle database,but I found there's missing Oracle.sql.CharacterSet.java source file,and some errors occur:
java.sql.SQLException: ORA-01400: cannot insert NULL into ("EPICS"."IOC_DB_FILE_ASGN"."EXT_SRC_FILE_NM")
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:542)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:2978)
at gov.sns.apps.jeri.apps.dbimport.DBFileParser.updateDBFileIOCData(DBFileParser.java:3028)
at gov.sns.apps.jeri.apps.dbimport.DBFileParser.saveToDatabase(DBFileParser.java:2930)
at gov.sns.apps.jeri.apps.dbimport.DBImportFrame$19.run(DBImportFrame.java:640)
at java.lang.Thread.run(Thread.java:534)
The database is Oracle 10g,and development tools is Jdeveloper10g。I have added oracle_home/jdbc/lib/classes12.jar into the classpath.but it doesn't work。I hope someone can tell me what's the matter and how to get the source file of CharacterSet.java?I'll be very grateful for your help!Thank you very much!hello user457523
I have found the reason to that error.It's because there's a trigger and ext_src_file_nm is populated by the trigger from another column ext_src_file_loc when inserting and I didn't give any value to ext_src_file_loc so ext_src_file_nm is null.
I have disabled that trigger and now I get new errors.When I traced to a line of Jave code I got missing source file warning,and the source file is also oracle.sql.CharacterSet.java.I can not trace into the source file and then I skipped that code and then I got new errors.I want to know how to trace into the jave code and find what's the matter.
Thank you very much. -
Calling Operating System Commands from PL/SQL using java
Calling Operating System Commands from PL/SQL - The Java Way
wlth help of given thread link,
Calling OS Commands from Plsql
but i had user privilege problem
Declare
x Varchar2(2000);
Begin
x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
DBMS_OUTPUT.Put_Line(x);
End;
o/p;
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
i done the grant privillage also
part
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
dbms_java.grant_permission('
abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
again
get
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
same error;Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back. -
SQL Developer Java Extension possible?
Hello,
I need to parse Oracle SQL queries (to get information about tables used in queries and kind of filtering criteria) for some project.
So, I would like to know if SQL Developer exposes such features in the context of Java extensions.
Moreover, I've read a thread dealing with SQL Devloper java extensions but the sample does exist anymore, are there some docs available somewhere else?
Thanks for your comments.
Regards,
LoïcHi,
If you get JDeveloper and download the ESDK (extension SDK), there are a set of sample extensions that you will find helpful in getting up to speed with some of the terms used (commands, actions, the different parts of the IDE, etc) - quite a few of them "just work" with SQL Developer without any fiddling.
It would be nice to have a bit more visibility of the SQL Developer specifics, though...
HTH,
John -
I am working in a project were we need to move a lot of data (100 Million records a year) into Oracle (8i).
We have a Java program (EJB) that does the file and record integrity checks and loads the data into three Oracle tables.
Then we run a set of SQL stored procedures to check the integrity and validity of the individual fields and store the results in yet another table. We believe this process could not be done with the original files, since they are just plain text files.
The forth table is then use to create a report that will help the people that submitted the data for cleaning purposes, so they can send it again (and re-load it into the database). This process goes on until the data is as clean as possible. At that point the data in the original three tables is moved and converted to another database that will be used for reporting.
This other database is normalized and read only.
The DBA is telling us that we shouldn't use Oracle to do this checking (nor the moving to the final database), but an external application like Java or C++. Our opinion is that it would be faster, and less intensive for the network and the database, to do it in Oracle using PL/SQL.
So the question is ... who is right? or how can I find information or benchmarks on this topic.
Thanks in advance,
Paco MoralesI ran into the same issue before... there are trade offs to either way.
If you are doing a lot of lookups then it will be a lot faster to do the validation in PL/SQL. You will see a large performance increase.
If you do your validation on the server, you will need to increase your database resources. This is probably why the DBA is fighting your development. -
PL/SQL support Java and VB
We are exploring the possibility of one Oracle DB supporting
both Application written in VB and Java. Do I have to write two
sets of PL/SQL stored procedures/packages so that one will work
with VB codes through OraOLEDB and the other set will support
Java through JDBC?
I appreciate any of your inputs.
LisaI think one version of the PL/SQL stored procedure will serve
both VB and Java programs. With Java JDBC, you can also load a
Java stored procedure into the database and then publish it so
that it can be called from another PL/SQL function, of couse in
this case, the Java stored procedure will have a version
different from that used by VB. Hope that this helps.
Good Luck!
Ming Xu.
Maybe you are looking for
-
Mapping the R/3 Fields with InfoObjects
Hi Guru's, I am working on CO-PA Datasource, i have the r/3 fields from which i have to map the info objects in BI. I found all the relevent infoobjects, but few left without mapping.I tried to find these fields from tcode:se11/rsosfie
-
Upgraded from Vista ultimate to Win. 7. Don't know how to install the tv tuner
I upgraded from Vista ultimate to Win. 7. When I tried to install the TV tuner, nothing seemed to happen.
-
ORA-01119: error in creating database file
Hi, I am trying to run scripts adcrtbsp.sql but it is giving following error. adcrtbsp.sql script contains: CREATE TABLESPACE APPS_TS_TX_DATA DATAFILE '?/dbf/transaction_table.dbf' SIZE 1000 M REUSE EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128 K SEGMENT
-
I installed a very complete set of styles of an opentype font with Font Book – Mac OS X 10.9.4 – but when I tried to format a sample text on InDesign CS5.5 I noticed that I could not use the opentype features on the Open Type menu as I usually do. Co
-
Is there authority check in every BAPI?
Hi guys, Does anyone know whether every BAPI have authoriyt check? I read some BAPI's documents,and I found that some documents don't explain BAPI check which authority object.Dose that mean this BAPI don't have anthority check? thanks all. Best