On making call to Oracle procedures from Java, Value becomes null on oracle
We are using some user defined Oracle data types in my Java/J2EE application
and some of them are Oracle collections(ex. VARRAY).
We are making a call to Procedures/Functions from Java, there are some
parameters of user defined data types declared in the
procedures/functions, from java the values are properly setting to these
user defined data type parameters and sending to Procedures.
We are not getting any exception at Java side and Oracle side and values
are becoming blank/null at oracle procedure side for the parameters of
user defined data types.
But when do the count of collection of user defined data type then it is
properly giving the size of collection(VARRAY).
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.
Please let me know if you have any suggestion on this?
user7671994 wrote:
When we are trying to read the values from the collection(VARRAY) it is
giving blank/null value and there is no exception.If you are talking about VARCHAR2 parameters of the objects - then you should add orai18n.jar to classpath.
Similar Messages
-
Calling packaged stored procedure from Java
Hi All,
I'm trying to call a stored procedure from Java but I'm having
problems with registrating the output parameter. I'm getting
the error: Conflicting parameters.: sqltype=2003
This is the stored procedure which is located in a package in
the Oracle database:
package Pack_GetAgencyInformation as
Type InfoType is record ( agen_code varchar(3), agen_designation
varchar(30), agen_adresse varchar(60), agen_tel varchar(12) );
function GetAgencyInformation( P_AGENCE VARCHAR )
return Pack_GetAgencyInformation.InfoType
end Pack_GetAgencyInformation;
This is the Java source from where I'm calling the procedure:
//DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@164.48.69.125:1521:ventes", "system", "*****
// @machineName:port:SID,
userid, password
CallableStatement cs = conn.prepareCall("{ ? = call
Pack_GetAgencyInformation.GetAgencyInformation( ? )}");
try {
cs.registerOutParameter( 1,
oracle.jdbc.driver.OracleTypes.ARRAY);
} catch (SQLException e) {
e.printStackTrace();
cs.setString(2, "001" );
//ResultSet rset = cs.executeQuery();
The stacktrace:
java.sql.SQLException: Parametertypen conflicteren.:
sqlType=2003
at oracle.jdbc.dbaccess.DBError.throwSqlException
(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException
(DBError.java:210)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
(OracleCallableStatement.java:220)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
(OracleCallableStatement.java:350)
at dbAccess.main(dbAccess.java:25)
I think it has to do with the type InfoType which is created in
the Stored Procedure. I'm absolute no Oracle expert and I
prefer not to make changes to the Oracle database. So any
solution in Java is welcome!
BR, H.RietmanI managed to get it to work only by changing the stored
procedure. I have changed the return type record to a Ref
Cursor type (had to change alot of code for this). It seams
that Oracle JDBC drivers DON'T support the Record type as a
return type.
So the next question is: is it possible to typecast a record
type to a ref cursor type in Oracle. In this way I can easily
change the return type for the stored procedures.
/Harald -
Jdbc NullPointerException calling pl/sql procedure from java
Hi.
Getting the following exception calling a plsql procedure from jdbc.
- Jdbc version is 10.2.0.2, but it also happens running several other variants, including 10.1.0.5.0.
- Application is running in Weblogic 8.1.3 (8.1 SP 3).
The procedure call itself has 2 in/out parameters which are tables (actually just 1 dimensional arrays), which I'm suspecting has something to do with the problem. I can successfully call this procedure using a plsql developer tool with the same bind parameters.
Any ideas?
Exception encountered while executing PL/SQL procedure MVT_Web_Inquiry.ShowInquiry:
java.lang.NullPointerException at oracle.jdbc.driver.T4CTTIiov.processRXD([Loracle.jdbc.driver.Accessor;I[B[C[SILoracle.jdbc.driver.DBConversion;[B[B[[Ljava.io.InputStream;[[[B[[Loracle.jdbc.oracore.OracleTypeADT;Loracle.jdbc.driver.OracleStatement;[B[C[S)[Loracle.jdbc.driver.Accessor;(T4CTTIiov.java:139)
at oracle.jdbc.driver.T4C8Oall.receive()V(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(ZZZZ)V(T4CCallableStatement.java:215)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(Z)V(T4CCallableStatement.java:1119)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:1278)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal()I(OraclePreparedStatement.java:3446)
at oracle.jdbc.driver.OraclePreparedStatement.execute()Z(OraclePreparedStatement.java:3552)
at oracle.jdbc.driver.OracleCallableStatement.execute()Z(OracleCallableStatement.java:5261)
at weblogic.jdbc.wrapper.PreparedStatement.execute()Z(PreparedStatement.java:70)
at
[snip]OK... I figured it out.
Apparently, this error happens when you forget to register the output part of an in/out parameter. I would have hoped for better error messaging, but oh well.
-ed- -
Calling invalid stored procedure from java
Will the stored procedure which is invalid get re-compiled automatically when called from a java program?
1.a stored procedure is invalid (oracle 9i)
2.calling the stored procedure from a java program
3.what will happen a.oracle recompiles the stored procedure
b.returns an sql exception
what happens,kindly help
drop your mail to [email protected]
Keep Smiling and Mailing,
Vijay Anand Natesan.thank you ..Kindly let me know if any of your friends have tried this
-
Calling PL/SQL Procedures from Java
Hello,
I want to know, if it is possible to call PL/SQL Procedures from
SQLJ(which uses htp.print from the Package web toolkit ).
Though, it is possible to call normal procedures but if I want
to call PL/SQL procedures with htp.print then I get I error.
For example:
#sql{Call html_test()};
Can you give me a advice?
Your help is much appreciated!
M|llerOracle's htp packages are develop to be work with
mod_plsql/OAS/OWS webserver.
If you are trying to use htp packages first need to instanciate
some enviroment vars for htp packages, for example first you has
to call to owa.initialize procedure, populate owa.cgi array and
so on.
If you need more information about how this toolkit works you
could get the source of DB Prism at
http://www.plenix.com/dbprism/ this open source framework
includes backward compatibility with mod_plsql application and
then includes settings of this values from Java code.
Best regards, Marcelo. -
How can I call a hsqldb procedure from Java
Hello,
I am trying to call from Java a stored procedure but I keep having exceptions!!!
In addition, I have no idea how I can get the result of the procedure !!!!
I have spent the whole day in Internet.... no luck!!
===============================================
I[b] java.lang.Exception: +updatejava.sql.SQLException: Unexpected token: # in statement [ call MODIFY_FIELD_SEPARATOR(#) ]
at util.UtilBean.test_upd(UtilBean.java:369)
===============================================
The following procedures have been created and tested withing the database and there work.
- public static String manage_field_separator(String ifs)
-public static String manage_refresh_interval(int val)
The alias have been created:
CREATE ALIAS MODIFY_FIELD_SEPARATOR FOR "com.lucent.util.StoredProcedures.manage_field_separator";
CREATE ALIAS MODIFY_REFRESH_INTERVAL FOR "com.lucent.util.StoredProcedures.manage_frefresh_interval
My file.java contains the flollowing:
public String test_upd(String tableName, String paramValue)
throws Exception
String res="0";
Connection conn=null;
CallableStatement cs= null;
try
conn=DBConnection.DBConnect();
String p="MODIFY_"+tableName.toUpperCase()+"("+paramValue+")";
cs=conn.prepareCall( "{call "+p+"}");
cs.execute();
// Suppose to get the result res of the function!!!!
catch (SQLException e)
exceptionMessage="+update"+e.toString();
System.out.println("exceptionMessage="+exceptionMessage);
throw new Exception(exceptionMessage);
finally
Statement stmt=null;
DBConnection.closeConnection(conn,stmt);
return res;
}Obviously I am doing something wrong ..... but I don't know what!!!
Could you help me please?
THanks a lot!Thanks for your quick response.
I need to construct the name of the procedure on the fly because I don't know the name of the table I need to modify until excecution time.
I have modified the code the following way but it still does not work!!!
I still get the exception:
java.lang.Exception: +updatejava.sql.SQLException: Unexpected token CALL, requires SELECT in statement [(call MODIFY_FIELD_SEPARATOR(?)}]
at util.UtilBean.test_upd(UtilBean.java:380)
public String test_upd(String tableName, String paramValue)
throws Exception
String res="0";
Connection conn=null;
CallableStatement cs= null;
try
conn=DBConnection.DBConnect();
cs=conn.prepareCall( "(call MODIFY_"+tableName.toUpperCase()+"(?)}");
cs.setString( 1, paramValue);
cs.execute();
// Suppose to get the result res of the function!!!!
catch (SQLException e)
exceptionMessage="+update"+e.toString();
System.out.println("exceptionMessage="+exceptionMessage);
throw new Exception(exceptionMessage);
finally
Statement stmt=null;
DBConnection.closeConnection(conn,stmt);
return res;
} -
Calling a Stored Procedure from Java
Hi all
I am trying to run a stored proc which has the following name: test.myProcedure(?)}
In my Java I am declaring the parameters as follows:
declareParameter(new SqlOutParameter("value", Types.DOUBLE));
Then I have a execute() which looks like this:
public Map execute() { Map<String, Double> testMap = new HashMap<String, Double>(); testMap.put("value", 2.0d); return execute(testMap); }
Now my understanding was that I am specifying above in the declare the name of the variable which is called "value" and its type - in this case a Double value. Then I populated my test HashMap with the key value pair which I pass to the execute function.
I get the following error:
wrong number or types of arguments in call
Please could someone point me in the right direction. Thanks for any suggestions.Thanks for the responses thought it would be easier to paste the short code here to make things clear on what I am doing. So I have a test method which gets the database credentials (getDataSource())...Then I am declaring a sql parameter which is the input called: "v_offset" - this also matches the name of the variable in the stored proc too. Then I am declaring the output which is a Cursor and again the name of the output cursor matches that of the procedure.
Then I am creating a Map which contains the input param name and the value which is 2. Running this code fails with the following error:
+CallableStatementCallback; bad SQL grammar [{? = call MY_PROC(?)}]; nested exception is java.sql.SQLException: ORA-06550: line 1, column 13:+
wrong number or types of arguments in call
public Map testMethod()
final String SQL = "MY_PROC";
final String V_OFFSET = "v_offset";
DataSource ds = TestDBStuff.getDataSource();
setDataSource(ds);
setFunction(true);
setSql(SQL);
declareParameter(new SqlParameter("v_offset", Types.DOUBLE));
declareParameter(new SqlOutParameter("v_cursor", oracle.jdbc.OracleTypes.CURSOR));
compile();
Map inputs = new HashMap();
inputs.put(V_OFFSET, 2);
Map results = super.execute(inputs);
TestDBStuff.printMap(results);
return results;
}Any suggestions would be appreciated - I am sure its the way I am specifying the input or output but I am not sure what I am doing wrong...
Edited by: notforgoogle on Sep 16, 2009 11:15 AM -
Bug calling PL/SQL procedure from Java
Has anybody encountered this problem/know the solution to the following problem?
I have a collection of Java Beans that call the database (8.1.6). The code works perfectly except when done through a user on the DB who only has permissions to execute the PL/SQL code defined by another user AND when I use the thin drivers.. using OCI works a treat.
The error appears to be a security exception saying that no table or view was found 'ORA-00942: table or view does not exist'..
This does not happen for all of the procedures, only the ones that return ref cursors.
This code worked fine on Oracle8, the problem is limited to 8i and thin drivers.
Any suggestions as to what the problem could be/confirmation that it is a bug with Oracle would be appriciated.
Thanx,
- Chris.
Brainbench MVP Java2.I have seen this behavior too. Oracle, could you please respond on this one.
Thanks -
Date Format Question - calling a store procedure from java side
What is the best approach to handle a DATE as an IN parameter to a procedure?
1) emp table has a column called hire_date and its data type is DATE;
2) the procedure tried to retrieve all employees hired on a specific date, so there will be an IN parameter called p_hire_date, what data type should it use? Something like p_hire_date IN emp.HIRE_Date%TYPE? <== is this correct?
3) so inside the procedure body, when retrieving the record,
SELECT first_name, last_name
FROM EMP
Where hire_date = p_hire_date <==is this correct? or when do I use to_date()?
4) On the Java side, when calling this procedure, what data type should the hire_date use?
Thanks,
new2Oraclenew2Oracle wrote:
it seems our java team passed the hire_date as a string, so in this case, i should make the following change
1) p_hire_date IN varchar2
2) in the SELECT statement, it will be like
select fname, lname
from emp
where hire_date = to_date(p_hire_date, 'MM/DD/YYYY') <== the hire date is stored in the table as 1/1/2005
Would the change above work?
Thanks,Yes it would , but:
if it was 01/03 is this jan 3rd, or mar 1st
Bets way is to pass in to parameters
p_hire_date=>1/1/2005
p_date_format=>'mm/dd/yyyy';
then your code can say in initialisation section
v_hire_date varchar2(30) := to_date(p_hire-date,p_date_format);and no more conversions in your code.
select fname, lname
from emp
where hire_date = v_hire_date;Much clearer this way, I think. -
Error while calling stored procedure from Java
Hi Guys,
How are you everybody? I hope everything is goin fine on your side. I have one issue in PL/SQL while calling below stored procedures from Java.
Problem Description: We have a stored procedure PROCEDURE BULK_INSERTS (
V_SESSION_ID_TAB IN T_SESSION_ID_TAB_TYPE,
V_SERVICE_TYPE_TAB IN T_SERVICE_TYPE_TAB_TYPE,
V_SERVICE_LOCATION_TAB IN T_SERVICE_LOCATION_TAB_TYPE,
V_SERVICE_CALL_NAME_TAB IN T_SERVICE_CALL_NAME_TAB_TYPE,
V_SERVICE_CALL_START_TIME_TAB IN T_SERVICE_CALL_ST_TAB_TYPE,
V_SERVICE_CALL_END_TIME_TAB IN T_SERVICE_CALL_ET_TAB_TYPE,
V_SERVICE_CALL_DURATION_TAB IN T_SERVICE_CALL_DUR_TAB_TYPE,
V_STATUS_TAB IN T_STATUS_TAB_TYPE,
V_NOTES_TAB IN T_NOTES_TAB_TYPE
) and we are getting ora errors while calling this stored procedure from java.
All tab types are declared locally, at package level.
Here is error which occur while calling this sp:
{call BULK_PKG.BULK_INSERTS(?,?,?,?,?,?,?,?,?)}
And the parameter types we are using are:
SESSION_ID - NUM_TAB_TYPE
SERVICE_TYPE - VAR_TAB_TYPE
SERVICE_LOCATION - VAR_TAB_TYPE
SERVICE_CALL_NAME - VAR_TAB_TYPE
SERVICE_CALL_START_TIME - DATE_TIME_TAB_TYPE
SERVICE_CALL_END_TIME - DATE_TIME_TAB_TYPE
SERVICE_CALL_DURATION - NUM_TAB_TYPE
STATUS - VAR_TAB_TYPE
NOTES - VAR_TAB_TYPE
And the Exception stack trace is:
ERROR (com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServi
ceCallDAO.java:143)@ExecuteThread: '252' for queue: 'weblogic.kernel.Default') {Error attempting to save collected ESC data}
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:191)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:944)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3482)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:3856)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1373)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:98)
at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.doBulkInsert(ExternalServiceCallDAO.java:220)
at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServiceCallDAO.java:138)
Please help my guys out of this. I will really appreciate all suggestions and advices.
Thank you everybody.I am trying to pass parameter to test my procedure but it is giving this error : ORA-06531: Reference to uninitialized collection
ORA-06512: at line 12
Here is example for my test procedure:
declare
v_session_id_tab SESSION_ID_TAB_TYPE;
v_service_type_tab SERVICE_TYPE_TAB_TYPE ;
v_service_location_tab SERVICE_LOCATION_TAB_TYPE ;
v_service_call_name_tab SERVICE_CALL_NAME_TAB_TYPE;
v_service_call_start_time_tab SERVICE_CALL_ST_TAB_TYPE;
v_service_call_end_time_tab SERVICE_CALL_ET_TAB_TYPE;
v_service_call_duration_tab SERVICE_CALL_DUR_TAB_TYPE;
v_status_tab STATUS_TAB_TYPE;
v_notes_tab NOTES_TAB_TYPE;
begin
v_session_id_tab(1) := 1;
v_service_type_tab(1) := 'db';
v_service_location_tab(1) := 'local';
v_service_call_name_tab(1) := 'Name of call';
v_service_call_start_time_tab(1) := SYSDATE;
v_service_call_end_time_tab(1) := SYSDATE;
v_service_call_duration_tab(1) := 100;
v_status_tab(1) := 'Z';
v_notes_tab(1) := 'NOTES';
BULK_INSERTS (v_session_id_tab,v_service_type_tab, v_service_location_tab,v_service_call_name_tab,v_service_call_start_time_tab,v_service_call_end_time_tab,
v_service_call_duration_tab, v_status_tab, v_notes_tab);
end;
I declare all types at schema level.
Please give your comments.
Thank you -
Calling stored procedure from Java raises ORA-1722 exception
Hi,
As the title says, when I call the stored procedure from java I got the exception ORA-1722 (invalid number) but I've checked and rechecked my procedure on SQL-Developer and It's alright it works nice and clean !
What's happening? is there something I'm missing?
The way I call the stored procedure is:
public void execProcedure(String procedure) {
CallableStatement cs;
try {
cs = conn.prepareCall(procedure);
cs.execute();
} catch (SQLException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
where
String procedure = "{call validateinfo}"I really need help on this, it's frustraiting me 'cause I need to finish a system but this little big problem is killing me ...
Thanks any advice is very welcome :)Thanks for your help. Haven't tested the SP with a DB access client... which one do you recommend to use?
The SP is the following:
create or replace
PROCEDURE validateInfo IS
var number;
BEGIN
UPDATE temp_desarrollo
SET status = '1';
COMMIT;
// Some string validations ...
//This one just checks if the value of "monto" is a number
//This update goes good
UPDATE temp_desarrollo tmp
SET cve_status = Decode(cve_status, NULL, '15', cve_status||',15')
WHERE IsNumber(tmp.monto) = 'F';
COMMIT;*/
//This one just checks if the value of "monto" is greater than 0
//if not, change de add to cve_status an errorValue
UPDATE temp_desarrollo tmp
SET cve_status = Decode(cve_status, NULL, '14', cve_status||',14')
WHERE (cve_status NOT LIKE '%15%' OR cve_status IS NULL)
AND to_number(tmp.monto) <= 0;
COMMIT;
//More string validations
EXCEPTION
WHEN OTHERS THEN
var := SQLCODE;
insert into excepciones values(to_char(var));
END;I've deleted much code from the SP since I know there's nothing to do with the excepcion, just that UPDATE statement is the one giving me the exception.
If those two UPDATES statements work with the same field (monto) why the first one is succeding and the second one not?
Cheers,
Federico
P.S. the "isNumber" function is as follows, just in case.
create or replace
function IsNumber(val1 varchar2) return varchar2 is
n number := null;
begin
n := to_number(val1,'9999999999999999.99');
return 'T';
exception
when others then
return 'F';
end; -
Calling a stored procedure from within a ViewObject
Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
If not, is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
Yes. Using our expert-mode query feature this is possible.
is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
Yes. See this article about basing a view object on a REF CURSOR:
http://radio.weblogs.com/0118231/2003/03/03.html
In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
No. Not directly. What's the business requirement here so I can understand better?
We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.
REF CURSOR would work fine, or if it's just the statement that needs to be generated dynamically, you could fetch the text of the SQL statement from the stored procedure, then use createViewObjectFromQueryStmt(). Although this has runtime overhead involved with describing the query.
The REF CURSOR based approach is probably best for this. -
Problem in calling Oracle stored procedure from Java.
I am trying to invoke the Oracle stored procedure from Java. The procedure does not take any parameters and does not return anything. If I call it from SQL prompt it is working perfectly. I am calling it in my program as follows.
callable_stmt=con.prepareCall("{call pkg_name.proc_name()}");
callable_stmt.execute();
The problem is the control-of-flow is getting strucked in the second line I wrote. It is not giving any error also.
Please clarify me what's wrong with my code?
Seenu.And how long does the stored procedure take to run from your client machine when running it via sqlplus?
-
Curious thing while calling a procedure from Java !...
Hi !. My name is Agustin and my doubt would be the following one... I am working for a e-business comp and they asked me to call a procedure from java... The code is the following one:
CallableStatement cs = null;
System.out.println("Fecha Nro. 1: " + paramFechaDesde);
System.out.println("Fecha Nro. 2: " + paramFechaHasta);
try
cs = getDBTransaction().createCallableStatement("{call paq_w_ListadoSiniestralidadART. p_sinsiniest(?,?,?,?) }",0);
cs.registerOutParameter(4,OracleTypes.VARCHAR);
cs.setInt(1,paramContrato.intValue());
cs.setString(2,paramFechaDesde);
cs.setString(3,paramFechaHasta);
cs.setString(4,paramNombreArchivo);
cs.executeQuery();
String nomArchivo = cs.getString(4);
System.out.println("### " + nomArchivo +" ###");
catch(SQLException e)
The weird thing is that, I was expecting a big big exception but the only thing I got is
### Error ###
The String I am expecting is a file's name !; so I am a little bit confused...
Also I didn't know where to post so If it's in the wrong category... I apologize !... If anyone need more details, I'll be checking out... The account I am working on is an Insurance company, who is the one who provide access to the DB and the procedures... So I can't check what's inside...Please provide your Java and OS versions, the JDBC jar file and the Oracle DB version being used when you post.
>
I was expecting a big big exception
>
Then why do you have an empty exception block? That just makes it disappear so you won't see one if it happens.
And your code has
cs.registerOutParameter(4,OracleTypes.VARCHAR);
cs.setString(4,paramNombreArchivo);You use 'registerOutParameter' for an OUT parameter and the 'setXXX' methods for other parameters.
Remove the 'setSTring' for the OUT parameter.
Then as malcollmmc already said
>
Sounds like the PL/SQL is returning "Error" as the 4th parameter of the call
>
The actual value returned by PL/SQL is strictly determined by the PL/SQL code and Java and JDBC are not involved.
Fix the code problems, retest, and folllowup with whoever wrote the code if it still returns ERROR. -
Calling Stored Procedures from JAVA Application
Hi all,
i am using JDeveloper 3.2.2 for creating a DB Application that
uses Oracle8i as DB Server.
One approach of the application is to only use PL/SQL Stored
Procedures to write Data back to the DB.
Some of the stored procedures expect more than 20 parameters.
I want to know if there is a better way to call such a stored
procedure from Java than using a CallableStatement and setting
its 20 parameters.
Another reason why the way above isnt possible for me is that
i need a dynamic way to set the parameters of the stored
procedure.
A solution for that dynamic way i could think of is to get
the information of the stored procedure by using some functions
of DatabaseMetaData and than use this information to map the
parameters with their respective variables in the java
application.
The best argument against this way is that it would be time and
performance consuming.
So could anybody tell me a solution to call PL/SQL stored
procedures from java which is better than doing something like:
String calString = "{Call myStoredProc(";
while(counter < 22) {
params += "?";
if(counter<21) params += ",";
counter++;
calString += params + ")}";
try {
CallableStatement cs = session.prepareCall(calString);
} catch(SQLException ex) { ... }
cs.setString(1, var1);
cs.setString(1, var2);
And that for every Stored Procedure i want to call ?!?
Any help or direction-leading would be really appreciated.
Tank you much.
MfG,
Oliver BankelHi Oliver,
If you your Stored Procedures were in Java and seamlessly
integrated with your Java application would that make your life
easier?
I don't know if this is a practical or acceptable solution in
your environment but it would certainly solve all of your issues
and provide your with a couple of nice advantages. Scalability
and platform independence are just a couple I could think of.
There is a tool called in2j (see http://www.in2j.com) which will
automatically migrate your PL/SQL Stored Procedures into Java.
You can download a copy of the tool and migrate your PL/SQL to
Java with no upfront costs. If you're happy with the generated
Java and want to deploy it, the migration fee falls due - simple.
Hope this helps.
Elton
Maybe you are looking for
-
Will I lose my app data when I upgrade to ios 8
I Am considering upgrading to ios 8 for the new apps and features it brings but I am wondering if my apps will work on ios 8 and data will be saved? I know that when I upgraded to ios 7 all my data was still there, and I have heard ios 8 is similar t
-
BI Publisher : view Template HTML with graph=String index out of range: -1
Hello, Do you have the same problem : I have made an rtf template with graphics, I have published it and when I edit it with BI Publisher as HTML model, I have the error : String index out of range: -1 but I am able to see it as RTF model ? As PDF mo
-
I'm trying to manage my subscriptions but can't seem to navigate my way around and find the page on my iPhone. Somebody please help?
-
Hi, I am facing problem at the time of patching on 11.5.10 system. ==========AD Worker ERROR================= Calling /u2/oracle/prodcomn/util/java/1.4/j2sdk1.4.2_04/bin/java ... Start of Core Modules - AK Loader file Upload Session. TUE 01 08 2013 1
-
How do you export a Premiere Pro screen shot without distortion when importing into Photoshop?
How can I take a screen shot in Premiere Pro (CS6 or CC) without it becoming distorted? Lately, when doing this, the images are elongated. Then, when I bring the image into Photoshop, it looks fine, except that the Pixel Aspect Ratio has been automat