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
Similar Messages
-
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 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. -
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. -
MDM Database command execution error. A SQL statement failed to execute
Hi,
When we tried to execute an MDM Java query modify/create, we get the following dump.
Is this anything to do with the parameters that we pass or is it something to do with the database ?
We have checked the code and we do not find anything wrong with the code at all.
We are using Java API 5.5.63.73 and calling MDM API's using WebDynpro for Java.
I have noticed this issue has been raised here as well :
Database command execution error. (While mounting a repository)
com.sap.mdm.commands.CommandException:
com.sap.mdm.internal.protocol.manual.ServerException: Database command execution error. A SQL
statement failed to execute. The actual error may have been written to a log file. at
com.sap.mdm.data.commands.ModifyRecordCommand.execute(ModifyRecordCommand.java:163) at
Regards,
Subramanian V.
Edited by: Subramanian Venkateswaran on Dec 10, 2008 8:11 PMHi Subramanian ,
The error looks more like a problem with the data base or MDM system rather than the java code.
Which is the underlying database you are using with MDM? As some users have faced some difficulties when working with the DB2 Data base,If this is the data base you too are working upon then may be the issue could be similar,if possible try using the Oracle or SQL data base as these databse show more compatibility than a DB2 when working with MDM .
Also check the MDM users autorization and authentication to modifyor create recordrs in MDM.try given the user the ADMIN rights,and tehn try and see if teh user is able to modify/Create the mdm records.
Lastly you can check the database instance and listener configuration correctly.try restarting the Database service form the system if possible.
Hope It Helped
Thanks & Regards
Simona Pinto -
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 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 -
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 -
How to find out the execution time of a sql inside a function
Hi All,
I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
RETURN NUMBER
IS
exec_time NUMBER;
BEGIN
--Calculate the execution time for the incoming sql statement.
RETURN exec_time;
END function_name;
/Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
A simple test case shows the potential difference of work performed by the database:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Session altered.
SQL>
SQL> drop table count_test purge;
Table dropped.
Elapsed: 00:00:00.17
SQL>
SQL> create table count_test as select * from all_objects;
Table created.
Elapsed: 00:00:02.56
SQL>
SQL> alter table count_test add constraint pk_count_test primary key (object_id)
Table altered.
Elapsed: 00:00:00.04
SQL>
SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.29
SQL>
SQL> set autotrace traceonly
SQL>
SQL> select * from count_test;
5326 rows selected.
Elapsed: 00:00:00.10
Execution Plan
Plan hash value: 3690877688
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5326 | 431K| 23 (5)| 00:00:01 |
| 1 | TABLE ACCESS FULL| COUNT_TEST | 5326 | 431K| 23 (5)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
419 consistent gets
0 physical reads
0 redo size
242637 bytes sent via SQL*Net to client
4285 bytes received via SQL*Net from client
357 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5326 rows processed
SQL>
SQL> select count(*) from (select * from count_test);
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 572193338
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| PK_COUNT_TEST | 5326 | 5 (0)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
16 consistent gets
0 physical reads
0 redo size
412 bytes sent via SQL*Net to client
380 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle:
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Java execution failed. Please check the Java Option in the option dialog.
I recently installed BI Publisher MS Word Add-In.
After installing I get the error "Java execution failed. Please check the Java Option in the option dialog" when trying to preview a template in (pdf, word, excel...).
I tried changing a java parameter as suggested by the following thread but it did not get past the error.
Java execution failed. Please check the Java Option in the option dialog.
Here are my settings to the Word Add-In under "Oracle Bi Publisher > Options... > Preview (tab)
Java Home = C:\Program Files\Java\jre6
Java Option = -Xmx512M
Any help would be appreciated.
ToddIs there a log I can see more about this Java error? I've looked for a log but can't see one.
TIA,
Todd -
Tool to find the execution plan of a SQL query
Hi,
I new to Oracle. I come from the SQL Server world.
I would like to know what tool(s) should I use to identify the execution plan for a SQL statement and to see if a query is missing indices.
Thanks,
PaulUse SQL*PLUS.
SQL> select dummy from dual;
D
X
SQL> set autotrace on explain
SQL> r
1* select dummy from dual
D
X
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1 Bytes=2)
1 0 TABLE ACCESS (FULL) OF 'DUAL' (TABLE) (Cost=2 Card=1 Bytes
=2)
SQL> set autot off
SQL> explain plan for select dummy from dual;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1157671242
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
8 rows selected.
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options
SQL> -
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
-
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.
Maybe you are looking for
-
Connection keeps dropping and speed is getting slo...
Hi, I have had infinity over a week now and after having a speed of 50M and a ping of 17 each day it has dropped and is now iro 34M and ping of 37. What is of more concern is my connection is keeps dropping. Has happened every day - DSL light going
-
Hi Gurus, We have a requirement for moving Block stock to QM stock ( with stock posting). Once the materials is received the stock will be posted to block stock and when needed the blockstock will be moved to Qulaity and checked and posted accordingl
-
Dear Gurus, We have a criteria here where we are creating a reservation for material for consumption for PM Order, we need to check the budget for each reservation. As I am seeing in our system the cost elements are not being copied to our automatica
-
All of a sudden i can´t scroll with the magic mouse?
-
Send me some link to write IDOC inbound program !