Remote execution of DTS packages from Java Stored Procedures
I'm an Oracle 10G DBA and Linux/Unix Sysadmin looking for a Java guru to help me find a reusable template or locate a solid programming methodology (examples) that will enable me to connect via JDSI to SQL Server 2000/2005 and remotely execute DTS packages from within Oracle. I am working at office that's absolutely addicted to MicroSlop products and the DBA team cannot conceive of giving up their precious DTS packages. I've already converted their MS SQL Server 2000 database to Oracle 10G on RHEL4 via SQLDeveloper but I am unschooled in the art of java programming and would like to locate some sort of rudimentary template or examples or java class that can easily be loaded into the Oracle 10G database instance via the loadjava utility. These java classes/methods/stored procedures need to be executable from within embedded PL/SQL code and able to connect to SQL Server 2000 to execute DTS packages via passing dtsrun commands ... Any help or direction would be greatly appreciated.
Hi Ilford:
Sure you can use fully package notation in your Java classes.
Look at this Java source code:
http://dbprism.cvs.sourceforge.net/dbprism/cms-2.1/src/com/prism/cms/core/
All of them are Java Stored procedures.
Best regards, Marcelo.
Similar Messages
-
Return national language strings from java stored procedures
Hi, all.
How does i can return String which contains national characters from java stored procedure? I.e. convert UTF java string to national language of database. It's does not processing automatically (why?).
declaration of procedure:
CREATE OR REPLACE FUNCTION TestNLSString RETURN VARCHAR2
AS
LANGUAGE JAVA
NAME 'test.SomeClass.getNLSString() return java.lang.String';
SELECT TestNLSString AS X FROM DUAL;
X
iiiii
OS: Windows 2000 Server
Oracle Server version: Oracle 8.1.7.1.4Ok. I had a specific problem.
I want to use java stored procedure (function) to make a connection to remote db using supplied connection parameters make some quieries there end return results in a form of structured data - object.
I have defined an object type in a database where the function will reside. I granted execute privilege to public user on this type, made public synonyms to both, the object type and the function, so anybody connected to the same database would have an access to this functionality.
I supposed that if I supply connection parameters for some other user but the same database when running the function, everything should go smooth. Yeah.
My java code executed ok: it made a connection to the db with some x user, it resolved object type descriptor given (oracle.sql.StructDescriptor), but pl/sql wrapper function reported the error I've mentioned. If I executed the function giving it the connection parameters for same account as where object type was declared, everything went fine.
My final solution is:
Make TWO! connection in java code: 1st for ("jdbc:default:connection:"), 2nd for remote database account.
Use first connection to construct oracle.sql.StructDescriptor
Use second connection to retreive data from remote db -
4gb file size limitation using java.io.* package in java stored procedure
Does anyone know about file size limitations when using java.io.* package inside java stored procedures. I have some java stored procedures that read and write to files. They error out when run as a java stored procedure within oracle on files over 4gb. I have no problems with these procedures when I test them outside of oracle.
I am using 10g Release 10.2.0.1.0, the java version returned by the Oracle JVM is 1.4.2_04
When I tested it outside of oracle I ran it using the java run time in ORACLE_HOME\jdk\bin and it works perfectly on files larger than 4gb.
Thank you for the UTL_FILE suggestion. I have considered using that but there is one method in Java that I can't seem to find a corresponding procedure for in PL/SQL.
RandomAccessFile.setLength()
This allows me to truncate a file. I have a need to strip bytes off the end of a file without creating a copy because I am working with large files and disk space may be limited. It is also much slower to read from the original file and writing the same bytes to a new file (minus the trailing bytes).
If anybody has any insight about the 4gb java.io limitation in Oracle JVM or has a workaround in PL/SQL for the RandomAccessFile.setLength() method in Java, I would really appreciate the help.
Thanks,
Thach -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
Calling external servlet from java stored procedure
Hello,
I need to call an external servlet which is in 9iAS server ( unix box) from Java Stored procedure in oracle database.
Can anybody give me an idea? is it possible?
Thanks,
ViswaI am trying the same. Here is URL which will help u.
http://otn.oracle.com/sample_code/tech/java/jsp/samples/wsclient/Readme.html
Let me know when you run servlet successfully.
Regards
Satish -
Call a function inside a package from a stored procedure
Hello:
I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
can I do the following in proc_c:
my_cursor1 SYS_REFCURSOR;
begin
my_cursor1 := exec pack_a.func_b
end
It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.guys:
Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
DECLARE TEMP VARCHAR2(100);
BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
I tried to use 'set serveroutput on' and got the following error:
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
I am kind of confused now. thank you for your help.
Jack
Here is my procedure:
create or replace
PROCEDURE PROC_SEARCH
( AGENCY_ID IN VARCHAR2,
DEVICE_ID IN VARCHAR2,
L_NAME IN VARCHAR2,
F_NAME IN VARCHAR2,
SEX IN VARCHAR2,
DOB IN VARCHAR2,
CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
AS
v_agy_id varchar2(10);
v_device_id varchar2(20);
v_l_name varchar2(25);
v_f_name varchar2(15);
v_sex varchar2(1);
v_dob date;
-- this cursor is going to be used to store a list of warrant matching
-- name search criteria
cad_srch_cursor sys_refcursor;
objSrch SEARCH_RESULT_TEMP%ROWTYPE;
BEGIN
cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
LOOP
FETCH cad_srch_cursor INTO objSrch;
EXIT WHEN cad_srch_cursor%NOTFOUND;
--insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
end LOOP;
END PROC_LAWS_SEARCH;
----------------------------------------- -
How to call EJB deployed on OC4J from java stored procedure?
Hello,
I'd like to call EJB from java stored procedure. My example works fine from command line, but the problem seems to be with deployment of this code into database. Especialy I'm wondering how to reference jars like oc4jclient.jar, ejb.jar, ... from java stored procedure.
Is there some example how to do that ?
Can You help me please ?
Many thanks,
Radim Kolek,
Eurotel Prague.Hi,
You may want to check up this thread
Calling JBoss EJBs from Java stored procedure
Hope this helps,
Sujatha.
OTN Group. -
ResultSet from Java Stored Procedures
Hi,
How do I obtain a resultset from a Java Stored Procedure?
My stored procedure, deployed in Oracle8i, has Database package as sample.Have published setConnection() and getDept() methods.
Code for Java Stored Procedure:
package SPPackage;
import java.sql.*;
public class StoredProcApplication {
protected static Connection connection = null;
protected static Statement stmt = null;
protected static ResultSet res = null;
public static void setConnection() throws SQLException {
connection = new oracle.jdbc.driver.OracleDriver().defaultConnection();
public static void getDept(Object[] obj) throws SQLException {
if (connection == null) {
setConnection();
if (stmt == null) {
stmt = connection.createStatement();
if (res == null) {
res = stmt.executeQuery("select * from DEPT");
obj[0] = res;
Code for TesterApplication :
package SPPackage;
import java.sql.*;
public class TesterApplication {
private static final String URL = "jdbc:oracle:thin:@sandeep:1521:oracle8i";
private static final String userId = "sandeep";
private static final String password = "sandeep";
private Connection connection;
private CallableStatement stmt;
private ResultSet res;
public void setConnection() throws ClassNotFoundException,SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(URL,userId,password);
public void getResultFromSP() throws SQLException {
//prepare to call the stored procedure
stmt = connection.prepareCall("{call sample.getDept(?)}");
//register the OUT parameters
stmt.registerOutParameter(1,Types.OTHER);
//execute the query
stmt.execute();
ResultSet res = (ResultSet)stmt.getObject(1);
while (res.next()) {
System.out.print(res.getInt(1) + " | " );
System.out.print(res.getString(2) + " | " );
System.out.print(res.getString(3) + " \n " );
public TesterApplication() throws SQLException,ClassNotFoundException {
try {
setConnection();
getResultFromSP();
} finally {
if (res != null) { res.close(); res = null; }
if (stmt != null) { stmt.close(); stmt = null; }
if (connection != null) { connection.close(); connection = null; }
public static void main(String[] args) {
try {
TesterApplication ta = new TesterApplication();
} catch (Exception e) {
System.err.println("Error while executing stored procedure " + e.getMessage());
e.printStackTrace();
When I run the TesterApplication, I get the following exception :
java.sql.SQLException: Invalid column type: get_internal_type
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.get_internal_type(Compiled Code)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Compiled Code)
Also, if I want to execute the ResultSet in the stored proc itself, and return the values as Arrays of int[], and String[], how do I do it?By default the you can populate only int[0], String[0] , i.e. only one value!!!
if my statement is unknown, i.e, it might return a combination of updates and resultsets, how do I go about processing the result?
Please advise!!
TIA
Sandeep
nullHi kkirk,
I found the post you mentioned.Well it dates back to November 1999 - "Problem returning resultset or ARRAY from java stored proc" by Stuart Popejoy ([email protected]).Too bad, it is still not solved!!
I am not very good at PL/SQL.However, it would still be helpful, if you could post the code here, or at my email address.
Meanwhile, I was trying this during the week-end.There seems to be a glimmer of hope!!
Let me know, if this makes sense :
CallableStatement cs = connection.prepareCall("begin open ? for select * from dept; end");
try {
cs.registerOutParameter(1,OracleTypes.CURSOR);
ResultSet res = ((OracleCallableStatement)cs).getCursor(1);
while (res.next()) {
//get the values
} catch (Exception e) {
e.printStacktrace();
However, I am getting an exception trace
Error while executing stored procedure Invalid column type: getLong
java.sql.SQLException: Invalid column type: getLong
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getLongValue(Compiled Code)
Not quite sure why this is happening!!
TIA,
Sandeep
null -
Deploy package with Java Stored Procedure without JDeveloper
I have a set of Java Stored Procedures deployed as a package on a Oracle 8i server. Everything works fine in my development environment, and now I would like to deploy the same package in the customers runtime environment. Both environments are running Oracle 8i rel 2 on NT.
Is there a simple way to use the JDeveloper .prf deployment profile without installing JDeveloper in the customers environment?
If not, can I the get the .jar files and .sql scripts from JDeveloper to create the call specs and package bodys?
I guess JDeveloper must have this information, and my idea was then to write a script using loadjava and SQL*Plus.
Regards,
Tom Bjerreyou would not be able to take just the deployment profile and run it outside JDeveloper.
You would be able to create archive of all java classes in the package using Deployment Wizard in JDeveloper.
Then you can load the jar file using the utilities in 8i.
JDeveloper does generate the SQL for CALL specs etc ., at the deployment time and it is printed in MEssage Viewer along with other information.
Hope that info is useful for you
raghu -
Passing Tables back from Java Stored Procedures
Thomas Kyte has written (in reference to
trying to pass an array back from a stored
function call):
You can do one of two things (and both require the use of
objects). You cannot use PLSQL table types as JDBC cannot bind to
this type -- we must use OBJECT Types.
[snip]
Another way is to use a result set and "select * from
plsql_function". It could look like this:
ops$tkyte@8i> create or replace type myTableType as table of
varchar2 (64);
2 /
Type created.
ops$tkyte@8i>
ops$tkyte@8i>
ops$tkyte@8i> create or replace
2 function demo_proc2( p_rows_to_make_up in number )
3 return myTableType
4 as
5 l_data myTableType := myTableType();
6 begin
7 for i in 1 .. p_rows_to_make_up
8 loop
9 l_data.extend;
10 l_data(i) := 'Made up row ' | | i;
11 end loop;
12 return l_data;
13 end;
14 /
Function created.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( demo_proc2(5) as mytableType )
3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
Made up row 4 [Image]
Made up row 5
So, your JDBC program would just run the query to get the data.
If the function "demo_proc2" cannot be called from SQL for
whatever reason (eg: it calls an impure function in another piece
of code or it itself tries to modify the database via an insert
or whatever), you'll just make a package like:
ops$tkyte@8i> create or replace package my_pkg
2 as
3
4 procedure Make_up_the_data( p_rows_to_make_up in
number ); 5 function Get_The_Data return myTableType;
6 end;
7 /
Package created.
ops$tkyte@8i>
ops$tkyte@8i> create or replace package body my_pkg
2 as
3
4 g_data myTableType;
5
6 procedure Make_up_the_data( p_rows_to_make_up in number )
7 as
8 begin
9 g_data := myTableType();
10 for i in 1 .. p_rows_to_make_up
11 loop
12 g_data.extend;
13 g_data(i) := 'Made up row ' | | i;
14 end loop;
15 end;
16
17
18 function get_the_data return myTableType
19 is
20 begin
21 return g_data;
22 end;
23
24 end;
25 /
Package body created.
ops$tkyte@8i>
ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
PL/SQL procedure successfully completed.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( my_pkg.get_the_data as mytableType
) 3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
And you'll call the procedure followed by a query to get the
data...
I have tried this, and it works perfectly.
My question, is what does the wrapper look
like if the stored function is written
in java instead of PL/SQL? My experiments
with putting the function in java have been
dismal failures. (I supposed I should also
ask how the java stored procedure might
look also, as I suppose that could be where
I have been having a problem)
nullThanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
SELECT java_stored_proc(pl/sql_stored_proc(col_id))
FROM table_of_5000_rows;
Sorry for the lengthy post. -
Use of Java packages in Java stored procedures? (Oracle 10.2)
Hi all-
Does Oracle's Java stored procedures support Java packages? In all the examples I've seen, packages are never used, and when I added one to a test file, it compiled it just fine, but referencing the class from the package itself resulted in a compiling error.
In other words, it seems to make absolutely no difference if I preface my Java class with
package com.mycompany.whatever;
and while I can "import com.mycompany.whatever.MyClass" in another Java file, it seems to not care at all whether I do so or not.
Thanks for any clarification,
IlfordHi Ilford:
Sure you can use fully package notation in your Java classes.
Look at this Java source code:
http://dbprism.cvs.sourceforge.net/dbprism/cms-2.1/src/com/prism/cms/core/
All of them are Java Stored procedures.
Best regards, Marcelo. -
Passing array from java stored procedure to plsql
I have a java store procedure that is parsing an xml document and returning element values to my plsql application(8.1.7). I'm mapping a java.lang.String return type to VARCHAR2. However I'm running into the 4k limit when trying to return a string from java that is over 4k. Truncation of varchar returning over 4k is a known issue in 8i.
So my next idea was to split that value of the element into 2000char and put in an array then pass that back to the plsql procedure. I know that oracle.sql.ARRAY can be converted into a plsql TABLE. But I believe you can only use the oracle.sql.ARRAY type when you are doing jdbc programming and are working with a connection.
SO FINALLY MY QUESTION IS...
Can anyone think of a solution that will allow me to pass over 4k of character data from my java stored procedure (not jdbc), back to my plsql app?
Thanks.My understanding is that oracle 8 has a 4k limitation on any plsql function return data. A varchar can hold 32k within a function/package, but it cannot return more than 4k outside it's scope.
Do you have an example you could share where you use the clob as a return type?
Thanks! -
No line numbers in stack trace from Java Stored Procedure exception
I have a Java Stored Procedure which can generate an exception. In one database (11.1.0.6) the Java stack trace contains line numbers for my code, but not for the classes loaded by default with the JVM. In another database (same version) the Java stack trace does NOT contain line numbers for my code, but does contain them for some of the classes loaded by default with the JVM!
Neither of the schemas where I am running the the Java stored procedure has a JAVA$OPTIONS tables as described here:
http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chtwo.htm#BABIGFGA
So the Java should have been compile "-debug" by default in both schemas. I specifically set the debug option to true using:
exec dbms_java.set_compiler_option('', 'debug', 'true');
but this had no effect.
Can anyone explain this behavior or tell me how to always get line number in the Java stack trace?Hi,
Try using java.util.logging package. Using these packages you can configure your logging information to include context down to the class name. Then each log message would be unique enough to know where it came from.
-Priyanka -
Invoking a UNIX shell command from Java stored procedure
The program below is suppose do send an email using UNIX mailx program. It works correctly when I compile it in UNIX and invoke it from the command line by sending an email to the given address.
I need this program to run as a stored procedure, however. I deploy it as such and try to invoke it. It prints the results correctly to the standard output. It does not send any emails, however. One other difference in execution is that when invoked from the command line, the program takes about a minute to return. When invoked as a stored procedure in PL/SQL program or SQL*Plus anonymous block, it returns immediately.
Why would mailx invocation not work from a stored procedure? Are there other ways to invoke mailx from PL/SQL?
Thank you.
Michael
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class MailUtility
public static void main(String[] args)
System.out.println(mailx("Hey, there", "Hello", "oracle@solaris10ora", 1));
* Sends a message using UNIX mailx command.
* @param message message contents
* @param subject message subject
* @param addressee message addressee
* @param display if greater than 0, display the command
* @return OS process return code
public static int mailx(String message, String subject,
String addressee, int display)
System.out.println("In mailx()");
try
String command =
"echo \"" + message + "\" | mailx -r [email protected]" + " -s \"" + subject + "\" " + addressee;
if (display > 0)
System.out.println(command);
try
Process process = Runtime.getRuntime().exec("/bin/bash");
BufferedWriter outCommand =
new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
outCommand.write(command, 0, command.length());
outCommand.newLine();
outCommand.write("exit", 0, 4);
outCommand.newLine();
outCommand.flush();
process.waitFor();
outCommand.close();
return process.exitValue();
catch (IOException e)
e.printStackTrace();
return -1;
catch (Exception e)
e.printStackTrace();
return -1;try adding the full explicit path to "mailx" in the command string that gets sent to Runtime. i would guess that the shell that gets spawned might not have a proper environment and thus mailx might not be found.
== sfisque -
How to execute a procedure or function from Java Stored procedure
Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
Thanks in advance.
PS. The variable passed in function is just a dummy variable.
-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;
public class Test2{
public static String Testing(String d) {
Connection connection = null; // Database connection object
try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]Long postings are being truncated to ~1 kB at this time.what your after is
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(2, "aa");
cs.executeUpdate();
String result = cs.getString(1);
a more complete description can be found in the documentation at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
Dom
Maybe you are looking for
-
Disk Utility Erase - Default Setting?
Hi everyone, what is the default setting when erasing the HD from Disk Utility? Is it 'Don't Erase Data' option? I didn't check the Security Options before erasing but after it did erase the first time, I went back and used the 7 pass option. Is it s
-
Setting up Intuos4 tablet with Photoshop CC 2014
I'm a digital artist who is moving from using PS Elements 12 to CC, and I can't seem to setup my small Wacom Intuos4 tablet correctly. I can write and use the pen tablet, but all brush dynamics aren't working, even though I have them set to work wit
-
QBE style(Find-Execute) Query not executing when VO has bind parameter
I have an Entity Based ViewObject that is composed of 3 Entities so the entities are related through an Assoc. Then the ViewObject also has a bind paremeter defined and used in the WHERE clause. In my page everything is fine until when I use/click on
-
Path to download kernel path 95
Please let me know the path to download kernel path 95
-
Another user allegedly logged on to my iTunes
When I try to connect my iPod to my PC I receive a message is telling me that there is already someone using my iTunes software and therefore it cannot recognize my iPod. It asks me to "please ask the other user to log out". Well, there is no other u