Oracle callable statement problems in weblogic 5.1
Hi Benzi,
Using Oracle arrays directly will not work because most of
oracle object are not serializable. Not to mention, it's not standard.
So the onlyt way to create arrays is using strored procedures.
There are also array accessor methods supporting some oracle array
extensions, though they are not supported officially and I think they could
be avaialble in the next version of weblogic.
Regards,
Slava Imeshev
"Benzi Galili" <[email protected]> wrote in message
news:[email protected]...
>
Hi Ravi,
Did you ever find a solution? We are running into the same problem withWLS 6.x,
and it seems like we can't get it to use Oracle's thin JDBC properly froma pool
configuration.
Thanx,
Benzi
"Ravi Sundar" <[email protected]> wrote:
e are using the TxDataSource obtained from weblogic connection pool.
Details are shown below:
weblogic.jdbc.connectionPool.oraclePool=\
url=jdbc:oracle:thin:@sirius:1521:sirora,\
driver=oracle.jdbc.driver.OracleDriver,\
loginDelaySecs=0,\
initialCapacity=2,\
maxCapacity=50,\
capacityIncrement=5,\
allowShrinking=true,\
shrinkPeriodMins=10,\
refreshMinutes=5,\
testTable=dual,\
props=user=mrt3c;password=mrt3c
weblogic.allow.reserve.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.allow.reset.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.allow.shrink.weblogic.jdbc.connectionPool.oraclePool=\
everyone
weblogic.jdbc.TXDataSource.oracleDataSource=oraclePool
Next we use the following to obtain a connection:
private Connection getConnection() throws Exception{
InitialContext lvObjCtx = new InitialContext();
DataSource lvObjDs = (DataSource)lvObjCtx.lookup("oracleDataSource");
return lvObjDs.getConnection();
We need to pass an array as IN parameter to oracle stored
procedure. We use the following code in a stateless session ejb:
public Vector insertBranchDetails(int lvIntMapId, int lvIntBranchId,
int
lvIntHierarchyLevel, int lvIntRoleId, String[] lvStrArrBranchId, String[]
lvStrArrBranchName, String[] lvStrArrBranchOrder, String[]
lvStrArrStudentsWeight, String[] lvStrArrDescription, String[]
lvStrArrTimeValue, String[] lvStrArrTimeUnits, String[]
lvStrArrEditorsWeight, String[] lvStrArrExpertsWeight, String[]
lvStrArrExpertsName, String lvStrUserId) throws RemoteException{
OracleCallableStatement lvObjCs = null;
Connection lvObjConn = null;
try{
lvObjConn = ConnectionPool.getConnection();
lvObjCs = (OracleCallableStatement)lvObjConn.prepareCall("{call
PROC_INS_UPD_BRANCHES_01(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
ArrayDescriptor lvObjAs = new ArrayDescriptor("ARRAY_VARCHAR2_4000",
lvObjConn);
/* ARRAY_VARCHAR2_4000 is a SQLTABLE */
ARRAY lvObjBranchId = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchId);
ARRAY lvObjBranchName = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchName);
ARRAY lvObjBranchOrder = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrBranchOrder);
ARRAY lvObjStudentsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrStudentsWeight);
ARRAY lvObjDescription = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrDescription);
ARRAY lvObjTimeValue = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrTimeValue);
ARRAY lvObjTimeUnits = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrTimeUnits);
ARRAY lvObjEditorsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrEditorsWeight);
ARRAY lvObjExpertsWeight = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrExpertsWeight);
ARRAY lvObjExpertsName = new oracle.sql.ARRAY(lvObjAs, lvObjConn,
lvStrArrExpertsName);
lvObjCs.setInt(1, lvIntMapId);
lvObjCs.setInt(2, lvIntBranchId);
lvObjCs.setInt(3, lvIntHierarchyLevel);
lvObjCs.setInt(4, lvIntRoleId);
lvObjCs.setString(5, lvStrUserId);
lvObjCs.setARRAY(6, lvObjBranchId);
lvObjCs.setARRAY(7, lvObjBranchName);
lvObjCs.setARRAY(8, lvObjBranchOrder);
lvObjCs.setARRAY(9, lvObjStudentsWeight);
lvObjCs.setARRAY(10, lvObjTimeValue);
lvObjCs.setARRAY(11, lvObjTimeUnits);
lvObjCs.setARRAY(12, lvObjDescription);
lvObjCs.setARRAY(13, lvObjEditorsWeight);
lvObjCs.setARRAY(14, lvObjExpertsWeight);
lvObjCs.setARRAY(15, lvObjExpertsName);
lvObjCs.registerOutParameter(16, Types.INTEGER);
lvObjCs.registerOutParameter(17, Types.VARCHAR);
lvObjCs.execute();
int lvIntErrorNumber = lvObjCs.getInt(16);
String lvStrErrorDescription = lvObjCs.getString(17);
if((lvIntErrorNumber % 10) == 1){
throw new AppServerException("Error Number: " + lvIntErrorNumber +
Error Description: " + lvStrErrorDescription);
Vector lvVecData = new Vector();
lvVecData.addElement(new Integer(lvIntErrorNumber));
lvVecData.addElement(lvStrErrorDescription);
return lvVecData;
}catch(Exception lvObjEx){
throw new AppServerException(lvObjEx);
}finally{
try{
if(lvObjCs != null){
lvObjCs.close();
if(lvObjConn != null){
ConnectionPool.returnConnection(lvObjConn);
}catch(Exception lvObjEx){
When this method is called from the client we get the following error:
java.lang.ClassCastException: weblogic.jdbc20.rmi.SerialCallableStatement
This occurs when we try to cast the CallableStatement to
OracleCallableStatement. Without casting to OracleCallableStatement
we cannot pass arrays as IN parameters to oracle stored procedures.
The method works well if we use the following code to obtain the
connection:
>>
private Connection getConnection() throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
DriverManager.getConnection("jdbc:oracle:thin:@sirius:1521:sirora",
"mrt3c", "mrt3c");
But the problem is, this connection does not support transactions
Please help
Similar Messages
-
Callable statement problem-very urgent
Hi Friends,
i have 2 tables, in that two tables one column have same attribute column. when i update the first table through OAF page, i wanted to effect updated value in second table of that common field also. i wrote PL/SQL Procedure and called that into OAF by using callable statements. here first time i updated in the page, updated value is effecting into the first table while second table not effected the updated value. again i am trying to update the page this time in second table effected with first time updation value,while first table updated correctly. suppose i updated again in the page this time in second table effected with second time updation value, while first table updated correctly.this process continuing...
example – I want to update forecast(this field is in two tables) value filed. Now forecast value is 10 in both tables , I updated as 20. this 20 updated value effected first table while second table forecast field is not effected.
Again I am going to update value 30 in the place of 20. this 30 updated value effected first table while second table forecast field is 20(firstupdated value) effected.
Again I am going to update value 40 in the place of 30. this 40 updated value effected first table while second table forecast field is 30(secondupdated value) effected this process continuing...
Can any one help me out this problem
This is I have written in AM-
public void Callable()
String forecast="";
String name="";
String product="";
String business="";
XXProgsVOImpl vo = getXXProgsVO1();
RowSetIterator rowsetiterator=vo.getRowSetIterator();
rowsetiterator.reset();
while(rowsetiterator.hasNext())
Row row = rowsetiterator.next();
forecast=row.getAttribute("Forcast").toString();
name=row.getAttribute("Name").toString();
product=row.getAttribute("Product").toString();
business=row.getAttribute("Business").toString();
String s="BEGIN do_update(?,?,?,?);End;";
OADBTransaction dbtrans=getOADBTransaction();
OracleCallableStatement cs=(OracleCallableStatement)dbtrans.createCallableStatement(s,4);
try
cs.setString(1, forecast);
cs.setString(2, name);
cs.setString(3, product);
cs.setString(4, business);
cs.execute();
dbtrans.commit();
cs.close();
catch(SQLException e)
System.out.println(e.getMessage());
Thanks and Regards,
vamshiHi Sumit and Thiago,
Thanks for your information, my Both VO's are coming from EO'S. but first VO I have done some calculation on columns, that calulated value parameter passing to second page. this calculated value is the database column in second table. here when i update the calculated value in updated page , i want to effect this in second page table.
do you have any work around this..
Thanks and Regards,
vamshi -
Hi All,
I have a get the data from table using CALLABLE statement.The problem is that that column datatype is CHAR.Is there any statement in java for to set
CallableStatement cstmt=null;
cstmt.setChar() ----- is it correct?Sorry for mistyping, I meant:
Oracle CHAR type is mapped to Java String.
cstmt.setString() should do. -
Statement closed when using callable statements with oracle xe
hi all, i've got this problem with oracle express edition 10g. I am using also oc4j v10.1.2.0.2. When working with a normal oracle database it was working fine (i think the code was the same, it's some time since i last tried, but you can see the code is very simple).
So i just create a callable statement like this:
CallableStatement cs = con.prepareCall(sentencia.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
and then when trying to access the statement to register an out parameter like this
cs.registerOutParameter(1, parámetros[0].getTipo());
it gives this error:
java.sql.SQLException: Statement was closed
It's puzzling me because, as i said before, i think the same code was working ok with a normal oracle database.
Any idea what can it be?
cheersAh okay, sorry I've re-read your post.
I believe you need to create a clob object that encapsulates your xml file.
I've never done this but I would image it involves creating a class that implements the clob interface and passing an instantiation of this class to the callablestatement.
Let me know how you get on. -
Problems with Callable Statement
Hi All,
I have a problem with the callable statement that contains stored procedure.Here main thing i want to know is that can a stored procedure can be used for a database like Access.Because i am using Access as a database here.In which i have created the table Students.
The table Students contains 3 fields they are name,amount & balance.
The program is compiling well but during the runtime it is showing an error:-
"Syntax error in Create Table" .
For ur reference i have posted the code:-
import java.io.*;
import java.sql.*;
public class CallStatDemo
public static void main(String arg[])
Connection con;
CallableStatement cs;
Driver dr;
String str1,str2;
int in1,in2;
double d1;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Ananth"); //the dsn name is Ananth
init(con);
if(con==null)
System.out.println("Connection not Established");
else
cs=con.prepareCall("{call Payment(?,?)}");
cs.setString(1,"Raman"); //name
cs.setString(2,"2000"); //amount
cs.execute();
catch(Exception e)
System.out.println("Error Message : "+e);
static void init(Connection con)
throws SQLException
Statement stmt = con.createStatement();
stmt.execute ("create or replace procedure Payment(name in text,amount in text)is " +
" begin"+
" update Students set balance=balance-amount where name =name;"+
"end Payment;");
stmt.close();
Thanx,
m.ananthuI have no clue if Access supports stored procedures, and this surely isn't related to JDBC at all. Did you check your Access documentation?
Your posted code does not contain any CREATE TABLE statement, so where do you get your error (which line)
Most probably Access does not support stored procedures. To verify that, you should execute your CREATE PROCEDURE statement from within Access, to verify that it is a supported statement. -
Error executing a callable statement on a pooled connection
Hi,
I have an Oracle function that returns a number:
create or replace function
S2B_STOP_STAGE (DOC_ID number, ST_ID number)
return number ...
and the following Java code:
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:madrigalPool");
String sql = "{? = call S2B_STOP_STAGE(401,1002)}";
CallableStatement stmt = conn.prepareCall(sql);
stmt.registerOutParameter(1, Types.INTEGER);
stmt.execute(sql);
res = stmt.getInt(1);
When the execute(sql) statement is executed, a SQLException is thrown:
java.sql.SQLException: ORA-01008: not all variables bound
at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:121)
Does anybody have an idea about what may be wrong? I am using Oracle
8.1.6, the thin driver classes12-81620.zip, and WebLogic 6.0 sp2.
Thanks,
VladimirI found out what was wrong. I should have used execute() instead of execute(sql)
on the callable statement...
Sorry for the problem.
Vladimir
"vladimir" <[email protected]> wrote:
>
Hi,
I have an Oracle function that returns a number:
create or replace function
S2B_STOP_STAGE (DOC_ID number, ST_ID number)
return number ...
and the following Java code:
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:madrigalPool");
String sql = "{? = call S2B_STOP_STAGE(401,1002)}";
CallableStatement stmt = conn.prepareCall(sql);
stmt.registerOutParameter(1, Types.INTEGER);
stmt.execute(sql);
res = stmt.getInt(1);
When the execute(sql) statement is executed, a SQLException is thrown:
java.sql.SQLException: ORA-01008: not all variables bound
at weblogic.jdbc.pool.PreparedStatement.execute(PreparedStatement.java:121)
Does anybody have an idea about what may be wrong? I am using Oracle
8.1.6, the thin driver classes12-81620.zip, and WebLogic 6.0 sp2.
Thanks,
Vladimir -
Please, Not getting result set from callable statement (Code posted)
I am posting some simple code which should get a ResultSet from a CallableStatement object using the executeQuery() Method.
It is returning "No RsultSet was produced"
If I modify the code and simply output the CallableableStatement using its executeUpdate() then getString() methods it works fine. Anything obviously wrong with this bit of code? Thanks.
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import db.util.query.*;
import db.util.pool.*;
public class oracle extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
Connection con = ConnectionFactory.getConnection();
CallableStatement cs = null;
ResultSet rs = null;
int intID = 1;
try{
cs = con.prepareCall("{? = call test1(?)}");
cs.registerOutParameter(1, java.sql.Types.VARCHAR);
cs.setInt(2,intID);
/*These lines work on their own
*cs.executeUpdate();
*out.println("Name is : " + cs.getString(1));
//this code is what is not working...hmm
rs = cs.executeQuery();
while(rs.next()){
out.println(rs.getString("name"));
rs.close();
cs.close();
//the rest of this works too.
ConnectionFactory.releaseConnection(con);
catch(SQLException e){
out.println(e.getMessage());
Here's the stored procedure. I'm just trying to do a simple test to return multiple rows. The table has numberous records with the same id which is being passed to the function.
create or replace function test1 ( strInputID IN testtable.id%type)
return varchar2
is
strOutputName testtable.name%type;
found_it EXCEPTION;
begin
select name into strOutputName from testtable
where id = strInputID;
raise found_it;
exception
when no_data_found
then
return null;
when found_it
then
return strOutputName;
end;I've posted the code...it's doing a select. I think the problem is that to return multiple rows I need to return a cursor. But I've run into problems with both the MS and Oracle Drivers.
All I really want to do is to query a database using a callable statement(function in oracle) which will return multiple rows which I can process. I have been trying to do this in a servlet.
I can do it successfully for one column from one row, but not multiple columns from mulitple rows.
I've been searchging for some good examples and am trying different things but can't seem to get it to work. -
Callable statement doubt-urgent
hi all,i got a problem in callable statements.i know how to pass parameters to a procedure using a callable statement.but this time i need to pass a table name as a parameter.the problem is if i get that variable as a IN parameter in the procedure then how do you put that parameter in place of table name inside the procedure.heres a example,the pocedure is in oracle
i am passing variable a from java
create or replace procedure (a in varchar2)
begin
select * from <the parameter passed through a> where <condition>
end;
how can this be done.the select statement is given only as a example.the errors in the select are not emphasized here.the focus is on the table name.if there is any other way to do this do let me know.please reply fast.this is urgent.any kind of help is welcome.bye thiyagu.In some databases the SQL used in your stored procedure can reference 'variables' that contain the values to be used at statement execution time. This will be covered in your database's SQL reference. If this is not supported by your database you will have to perform a 'switch' based on the table name passed and select the SQL statement to be executed.
-
Memory leak in Callable Statement
We are using Weblogic 6.1 and Oracle 8.1.7 for an application we are developing.
Usage of callable statement seems to be resulting an a memory leak. The program runs
in a loop and after processing 200 records, java.lang.outofMemory Exception is thrown
We are unable to figure out a reason for the same.
The code snippet is as below
try
//dbConn = ImportPODBConnect.getDBConnection(dsJNDIName, dsURL); //connect
to DB <br>
dbConn = DBConnect.getDBConnection(dsJNDIName, dsURL);
//query = POQueries.selectPO(poId); //get the required
query statement from the POQueries utility class
Print.log(" in getPO() ----> ********* before 1st stmt " + System.currentTimeMillis());
cstmt = dbConn.prepareCall("{ ? = call PO_HEADER_PROC(?)}");
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setFloat(2, poId);
// execute and retrieve the result set
cstmt.execute();
getPORs = (ResultSet)cstmt.getObject(1);
Print.log(" in getPO() ----> ********* after 1st stmt " + System.currentTimeMillis());
if (!getPORs.next()) //if nothing returned then
throw an exception
Print.log("Unable to get the required PO:" + poId);
throw new Exception("Unable to get the required PO:" + poId);
else //set all the variables
of the PO header objects from the result set
pohSl = new POHeaderSl();
pohSl.setOvUserName(getPORs.getString("OVA_USER_NAME"));
pohSl.setOvCompanyName(getPORs.getString("OVA_COMPANY_NAME"));
pohSl.setAgent(getPORs.getString("AGENT"));
pohSl.setApprovalCode(getPORs.getString("APPROVAL_CODE"));
pohSl.setBrand(getPORs.getString("BRAND"));
pohSl.setBusinessSegment(getPORs.getString("BUSINESS_SEGMENT"));
pohSl.setBusinessSubSegment(getPORs.getString("BUSINESS_SUB_SEGMENT"));
pohSl.setBuyDate(getPORs.getString("BUY_DATE"));
pohSl.setCareContentLabel(getPORs.getString("CARE_CONTENT_LABEL"));
pohSl.setCartonMarkings1(getPORs.getString("CARTON_MARKINGS_1"));
pohSl.setCartonMarkings2(getPORs.getString("CARTON_MARKINGS_2"));
pohSl.setCartonMarkings3(getPORs.getString("CARTON_MARKINGS_3"));
pohSl.setCartonMarkings4(getPORs.getString("CARTON_MARKINGS_4"));
pohSl.setComments(getPORs.getString("COMMENTS"));
pohSl.setCommissionPerUnit(getPORs.getString("COMMISSION_PER_UNIT"));
pohSl.setCompanyId(getPORs.getString("COMPANY_ID"));
pohSl.setCompulsoryString(getPORs.getString("COMPULSORY_STRING"));
pohSl.setConTimestamp(getPORs.getString("CON_TIMESTAMP"));
pohSl.setCurrency(getPORs.getString("CURRENCY"));
pohSl.setCustomerBillToNumber(getPORs.getString("CUSTOMER_BILL_TO_NUMBER"));
pohSl.setCustomerLcBank(getPORs.getString("CUSTOMER_LC_BANK"));;
pohSl.setCustomerLcDate(getPORs.getString("CUSTOMER_LC_DATE"));
pohSl.setCustomerLcExpiryDate(getPORs.getString("CUSTOMER_LC_EXPIRY_DATE"));
pohSl.setCustomerLcNumber(getPORs.getString("CUSTOMER_LC_NUMBER"));
pohSl.setCustomerPoNumber(getPORs.getString("CUSTOMER_PO_NUMBER"));
pohSl.setCustomerSaleDept(getPORs.getString("CUSTOMER_SALE_DEPT"));
pohSl.setCustomerShipToNumber(getPORs.getString("CUSTOMER_SHIP_TO_NUMBER"));
pohSl.setCustomerSo(getPORs.getString("CUSTOMER_SO"));
pohSl.setDateLastModifiedErp(getPORs.getString("DATE_LAST_MODIFIED_ERP"));
pohSl.setDateLastModifiedOv(getPORs.getString("DATE_LAST_MODIFIED_OV"));
pohSl.setDateOfActivation(getPORs.getString("DATE_OF_ACTIVATION"));
Print.log(" ******** inside getPO() ----- > ****** built Header" + System.currentTimeMillis()
if(getPORs != null)
getPORs.close();
getPORs = null;
if(cstmt != null)
Print.log("In the close");
cstmt.close();
cstmt = null;
catch (Exception e)
System.out.println(" in dataAccess.getPO() ----- > " + e.toString());
throw new Exception(e.toString()); //if there are any exceptions
then throw back the exceptions
finally //finally block to release any connections
and statement objects
if(getPORs != null)
getPORs.close();
getPORs = null;
if (pstmt!=null)
pstmt.close();
pstmt = null;
if (cstmt!=null)
cstmt.close();
cstmt = null;
if (dbConn!=null)
dbConn.close();
dbConn = null;
return poSl; //return the PO object
Can anyone help with this?hi
This may happen when you open resultset objects and not close them properly.
Try to ensure that, you should close the objects in individual try catch
blocks so that one failure will not cause other close's to be skipped.
You can try one more thing, I don't see you are using any LONG/ LONG
RAW/BLOB/CLOB columns from your code here. If the table which you are trying
to retrieve data from has this type of data you will benefit from using some
tuning parameters here and may be able to avoid out of memory exceptions,
take a look at the url,
http://e-docs.bea.com/wls/docs61/oracle/advanced.html#1158561
especially, try using,
weblobic.oci.selectBlobChunkSize and set it to something low. you can set
these properties on the connection pool.
sree
"Murali" <[email protected]> wrote in message
news:[email protected]...
>
>
We are using Weblogic 6.1 and Oracle 8.1.7 for an application we aredeveloping.
Usage of callable statement seems to be resulting an a memory leak. Theprogram runs
in a loop and after processing 200 records, java.lang.outofMemoryException is thrown
>
We are unable to figure out a reason for the same.
The code snippet is as below
try
//dbConn = ImportPODBConnect.getDBConnection(dsJNDIName, dsURL);//connect
to DB <br>
dbConn = DBConnect.getDBConnection(dsJNDIName, dsURL);
//query = POQueries.selectPO(poId); //getthe required
query statement from the POQueries utility class
Print.log(" in getPO() ----> ********* before 1st stmt " +System.currentTimeMillis());
>
cstmt = dbConn.prepareCall("{ ? = call PO_HEADER_PROC(?)}");
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setFloat(2, poId);
// execute and retrieve the result set
cstmt.execute();
getPORs = (ResultSet)cstmt.getObject(1);
Print.log(" in getPO() ----> ********* after 1st stmt " +System.currentTimeMillis());
>
if (!getPORs.next()) //if nothing returnedthen
throw an exception
Print.log("Unable to get the required PO:" + poId);
throw new Exception("Unable to get the required PO:" + poId);
else //set all thevariables
of the PO header objects from the result set
pohSl = new POHeaderSl();
pohSl.setOvUserName(getPORs.getString("OVA_USER_NAME"));
pohSl.setOvCompanyName(getPORs.getString("OVA_COMPANY_NAME"));
pohSl.setAgent(getPORs.getString("AGENT"));
pohSl.setApprovalCode(getPORs.getString("APPROVAL_CODE"));
pohSl.setBrand(getPORs.getString("BRAND"));
pohSl.setBusinessSegment(getPORs.getString("BUSINESS_SEGMENT"));
pohSl.setBusinessSubSegment(getPORs.getString("BUSINESS_SUB_SEGMENT"));
pohSl.setBuyDate(getPORs.getString("BUY_DATE"));
pohSl.setCareContentLabel(getPORs.getString("CARE_CONTENT_LABEL"));
pohSl.setCartonMarkings1(getPORs.getString("CARTON_MARKINGS_1"));
pohSl.setCartonMarkings2(getPORs.getString("CARTON_MARKINGS_2"));
pohSl.setCartonMarkings3(getPORs.getString("CARTON_MARKINGS_3"));
pohSl.setCartonMarkings4(getPORs.getString("CARTON_MARKINGS_4"));
pohSl.setComments(getPORs.getString("COMMENTS"));
pohSl.setCommissionPerUnit(getPORs.getString("COMMISSION_PER_UNIT"));
pohSl.setCompanyId(getPORs.getString("COMPANY_ID"));
pohSl.setCompulsoryString(getPORs.getString("COMPULSORY_STRING"));
pohSl.setConTimestamp(getPORs.getString("CON_TIMESTAMP"));
pohSl.setCurrency(getPORs.getString("CURRENCY"));
pohSl.setCustomerBillToNumber(getPORs.getString("CUSTOMER_BILL_TO_NUMBER"));
pohSl.setCustomerLcBank(getPORs.getString("CUSTOMER_LC_BANK"));;
pohSl.setCustomerLcDate(getPORs.getString("CUSTOMER_LC_DATE"));
pohSl.setCustomerLcExpiryDate(getPORs.getString("CUSTOMER_LC_EXPIRY_DATE"));
pohSl.setCustomerLcNumber(getPORs.getString("CUSTOMER_LC_NUMBER"));
pohSl.setCustomerPoNumber(getPORs.getString("CUSTOMER_PO_NUMBER"));
pohSl.setCustomerSaleDept(getPORs.getString("CUSTOMER_SALE_DEPT"));
pohSl.setCustomerShipToNumber(getPORs.getString("CUSTOMER_SHIP_TO_NUMBER"));
pohSl.setCustomerSo(getPORs.getString("CUSTOMER_SO"));
pohSl.setDateLastModifiedErp(getPORs.getString("DATE_LAST_MODIFIED_ERP"));
pohSl.setDateLastModifiedOv(getPORs.getString("DATE_LAST_MODIFIED_OV"));
pohSl.setDateOfActivation(getPORs.getString("DATE_OF_ACTIVATION"));
Print.log(" ******** inside getPO() ----- > ****** built Header" +System.currentTimeMillis()
if(getPORs != null)
getPORs.close();
getPORs = null;
if(cstmt != null)
Print.log("In the close");
cstmt.close();
cstmt = null;
catch (Exception e)
System.out.println(" in dataAccess.getPO() ----- > " + e.toString());
throw new Exception(e.toString()); //if there are anyexceptions
then throw back the exceptions
finally //finally block to release anyconnections
and statement objects
if(getPORs != null)
getPORs.close();
getPORs = null;
if (pstmt!=null)
pstmt.close();
pstmt = null;
if (cstmt!=null)
cstmt.close();
cstmt = null;
if (dbConn!=null)
dbConn.close();
dbConn = null;
return poSl; //return the PO object
Can anyone help with this? -
Naming the parameters of a callable statement
Hi!
I am having some kind of a problem here. I am currently working on a software with a database.OK, simple.
The problem is that we have different kind of databases (oracle, Sybase, DB2) AND different schema!
We are obviously trying to keep the persistence layer as cut from the rest as possible.
The problem is that in some cases, we may call a callable statement but the actual callable statement in the database is not the same as the one that would be called in a similar case with another schema.
Therefore, we are looking for a way to set the parameters of a callable statement by a name, not an index.
Instead of
setString(1,"aValue");
some
setString("FirstParameter", "aValue");
PLease help!
Cheers!
ChrisI think there is a driver that does that.Thanks for replying so quickly, could you tell me what
that driver would be ?Like I said I don't think it is going to help because it is for a specific data base. I you need to support more than one.
I think it is either Oracle (if you use the Oracle specific JDBC classes - cast to them) or one of the third party drivers.
>
I was thinking of the wrapper too but I, as the
(different)schemas are still changing and the callable
statement too, I think it will be very error prone
during the developpement cycle.
So I'd like to avoid to have to maintain a
"correspondance table" between each callable statement
and it's parameters...
And that is my idea. Developement cycles are always error prone so I am not sure that it matters. -
How to return Multiple ResultSets Using Callable Statement
hi everybody,
while i was working with callable statements i came across a problem of how to fetch Multiple Resultsets by means of Stored Procedures written for tables in Oracle.
If any one can help me, pls do help me with a detailed explanation, and if possible do get me a example source code too.
khumaarI have a similar problem with oracle and jdbc:
I want to send a sql query like:
sqlQuery = "select n1, n2 from table1; select n1, n2
from table2"
I used a prepared statement, but when I call
.execute(sqlQuery)
oracle doesn't like this,
can someone help on this?Try putting a begin/end around it. Play with the syntax first in sqlplus.
You do realize that you MUST extract using the syntax for extracting multiple result sets correct? It will NOT work as one result set. -
Using A callable statement in java
Hi all im trying to get results back from the database using a callable statement the problem is that it is placing / infront of single quotes.I need to get rid of this because it's not returning anything
here is my code
CallableStatement statementOne;
statementOne = ComparitiveAnalysisGUI.conn.prepareCall("{call graphProc(?,?,?,?,?,?,?)}");
statementOne.setString(1,"\"date_format(calldate, '%Y-%m-%d H:59:59'),avg(billsec)\"");
statementOne.setString(2,"Clovercdr");
statementOne.setString(3,start);
statementOne.setString(4,end);
statementOne.setString(5,"Boksburg");
statementOne.setString(6,"\"billsec > 0 and Network = " + network + "\"");
statementOne.setString(7,"\"date_format(calldate, '%Y-%m-%d %H:M:S')\"");
System.out.println(statementOne.toString());
rs = statementOne.executeQuery();
the result of the println is
com.mysql.jdbc.CallableStatement@ec4a87: CALL graphProc('"date_format(calldate, \'%Y-%m-%d %H:59:59\'),avg(billsec)"','Clovercdr','\'2006-03-14 00:00:01\'','\'2006-03-14 23:59:59\'','Boksburg','"billsec > 0 and Network = \'SAMobile\'"','"date_format(calldate, \'%Y-%m-%d %H:M:S\')"')
as you can see quite a mess please help if you can get the statement to look as follows
CALL graphProc("date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)",'Clovercdr','2006-03-14 00:00:01','2006-03-14 23:59:59','Boksburg',"billsec > 0 and Network = 'SAMobile'","date_format(calldate, '%Y-%m-%d %H:M:S')")
thanks BrianOk in order to understand why I did what I did parhaps it would be best if you saw my Stored procedure
create procedure graphProc(col varchar(100),company varchar(20),startTime datetime,endTime datetime,branchName varchar(20),andSection varchar(200),groupSec varchar(100))
BEGIN
SET @stmt := CONCAT("SELECT ",col," from ",company," where calldate between '",startTime,"' and '",endTime,"' and branchName = '",branchName,"' and ",andSection," Group by ",groupSec);
PREPARE stmt1 from @stmt;
EXECUTE stmt1;
the call is for example
call graphProc("date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)",'Clovercdr','2006-03-01 00:00:01','2006-03-14 23:59:59','Boksburg',"billsec > 0 and date_format(calldate, '%k') BETWEEN 7 AND 19 and Network = 'SAMobile'","date_format(calldate, '%Y-%m-%d %H:M:S')")//
as you can see In MySQL the "date_format(calldate, '%Y-%m-%d %H:59:59'),avg(billsec)" has to be quoted like this, so it can recognise it as a single parameter, since , '%Y-%m-%d %H:59:59' is viewed as another parameter
thaks for your reply
Brian -
Return records from Stored Procedure to Callable Statement
Hi All,
I am createing a web application to display a students score card.
I have written a stored procedure in oracle that accepts the student roll number as input and returns a set of records as output containing the students scoring back to the JSP page where it has to be put into a table format.
how do i register the output type of "records" from the stored function in oracle in the "registerOutParameter" method of the "callable" statement in the JSP page.
if not by this way is there any method using which a "stored function/procedure" returning "record(s)" to the jsp page called using "callable" statement be retrieved to be used in the page. let me know any method other that writing a query for the database in the JSP page itself.I have a question for you:
If the stored procedure is doing nothing more than generating a set of results why are you even using one?
You could create a view or write a simple query like you mentioned.
If you're intent on going the stored procedure route, then I have a suggestion. Part of the JDBC 2.0 spec allows you to basically return an object from a CallableStatement. Its a little involved but can be done. An article that I ran across a while back really helped me to figure out how to do this. There URL to it is as follows:
http://www.fawcette.com/archives/premier/mgznarch/javapro/2000/03mar00/bs0003/bs0003.asp
Pay close attention to the last section of the article: Persistence of Structured Types.
Here's some important snippets of code:
String UDT_NAME = "SCHEMA_NAME.PRODUCT_TYPE_OBJ";
cstmt.setLong(1, value1);
cstmt.setLong(2, value2);
cstmt.setLong(3, value3);
// By updating the type map in the connection object
// the Driver will be able to convert the array being returned
// into an array of LikeProductsInfo[] objects.
java.util.Map map = cstmt.getConnection().getTypeMap();
map.put(UDT_NAME, ProductTypeObject.class);
super.cstmt.registerOutParameter(4, java.sql.Types.STRUCT, UDT_NAME);
* This is the class that is being mapped to the oracle object.
* There are two methods in the SQLData interface.
public class ProductTypeObject implements java.sql.SQLData, java.io.Serializable
* Implementation of method declared in the SQLData interface. This method
* is called by the JDBC driver when mapping the UDT, SCHEMA_NAME.Product_Type_Obj,
* to this class.
* The object being returned contains a slew of objects defined as tables,
* these are retrieved as java.sql.Array objects.
public void readSQL(SQLInput stream, String typeName) throws SQLException
String[] value1 = (String[])stream.readArray().getArray();
String[] value2 = (String[])stream.readArray().getArray();
public void writeSQL(SQLOutput stream) throws SQLException
}You'll also need to create Oracles Object. The specification for mine follows:
TYPE Detail_Type IS TABLE OF VARCHAR2(1024);
TYPE Product_Type_Obj AS OBJECT (
value1 Detail_Type,
value2 Detail_Type,
value3 Detail_Type,
value4 Detail_Type,
value5 Detail_Type,
value6 Detail_Type,
value7 Detail_Type,
value8 Detail_Type);Hope this helps,
Zac -
Which version of jdbc thin driver should i use to achieve distributed transaction
with oracle 8.1.5 in weblogic 6.1 sp2
right now if iam using the driver classes provided in weblogic.jar iam gettig the
following Exception
AccountBean.ejbCreate( id = accountId, initial balance = $ 3000.0)
java.sql.SQLException: XA error: XAER_RMERR : A resource manager error has occured
in the transaction branch start(
) failed on resource 'OracleXAPool' Unexpected error during start for XAResource
'OracleXAPool': null
at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1044)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1010)
at weblogic.jdbc.jta.Connection.getXAConn(Connection.java:148)
at weblogic.jdbc.jta.Connection.prepareStatement(Connection.java:226)
at weblogic.jdbc.rmi.internal.ConnectionImpl.prepareStatement(ConnectionImpl.java:135)
at weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:76)
at examples.ejb.basic.beanManaged.AccountBean.ejbCreate(Unknown Source)
at examples.ejb.basic.beanManaged.AccountBean_g1748h_Impl.ejbCreate(AccountBean_g1748h_Impl.java:172)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:492)
at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:462)
at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:190)
at examples.ejb.basic.beanManaged.AccountBean_g1748h_HomeImpl.create(AccountBean_g1748h_HomeImpl.java:76)
at examples.ejb.basic.beanManaged.AccountBean_g1748h_HomeImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:158)
at weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:253)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:220)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy126.create(Unknown Source)
at examples.wtc.atmi.simpapp.ToupperBean.putMessage(ToupperBean.java:194)
at examples.wtc.atmi.simpapp.ToupperBean_8roqg7_EOImpl.putMessage(ToupperBean_8roqg7_EOImpl.java:284)
at examples.wtc.atmi.simpapp.ToupperBean_8roqg7_EOImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Regards
Ranga Rao
Oracle Server 8.1.5 does not provide support for 2PC.
Full XA support is provided from version 8.1.7.
Sergi
"Lawrence" <[email protected]> wrote:
>
>Ranga,
>Please use classes12.zip for this.If you still find problem, please let
>me know.
>Thanks
>Lawrence
>
>"Ranga Rao" <[email protected]> wrote:
>>
>>
>>Which version of jdbc thin driver should i use to achieve distributed transaction
>>with oracle 8.1.5 in weblogic 6.1 sp2
>>
>>right now if iam using the driver classes provided in weblogic.jar iam
>gettig
>>the
>>following Exception
>>
>>////////////////////////////////////////////////////////////////////////////////////////////
>>AccountBean.ejbCreate( id = accountId, initial balance = $ 3000.0)
>>java.sql.SQLException: XA error: XAER_RMERR : A resource manager error
>has
>>occured
>>in the transaction branch start(
>>) failed on resource 'OracleXAPool' Unexpected error during start for XAResource
>>'OracleXAPool': null
>> at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1044)
>> at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1010)
>> at weblogic.jdbc.jta.Connection.getXAConn(Connection.java:148)
>> at weblogic.jdbc.jta.Connection.prepareStatement(Connection.java:226)
>> at weblogic.jdbc.rmi.internal.ConnectionImpl.prepareStatement(ConnectionImpl.java:135)
>> at weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:76)
>> at examples.ejb.basic.beanManaged.AccountBean.ejbCreate(Unknown
>>Source)
>> at examples.ejb.basic.beanManaged.AccountBean_g1748h_Impl.ejbCreate(AccountBean_g1748h_Impl.java:172)
>> at java.lang.reflect.Method.invoke(Native Method)
>> at weblogic.ejb20.manager.DBManager.create(DBManager.java:492)
>> at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:462)
>> at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:190)
>> at examples.ejb.basic.beanManaged.AccountBean_g1748h_HomeImpl.create(AccountBean_g1748h_HomeImpl.java:76)
>> at examples.ejb.basic.beanManaged.AccountBean_g1748h_HomeImpl_WLSkel.invoke(Unknown
>>Source)
>> at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
>> at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
>> at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
>> at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:158)
>> at weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:92)
>> at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:112)
>> at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:253)
>> at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:220)
>> at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
>> at $Proxy126.create(Unknown Source)
>> at examples.wtc.atmi.simpapp.ToupperBean.putMessage(ToupperBean.java:194)
>> at examples.wtc.atmi.simpapp.ToupperBean_8roqg7_EOImpl.putMessage(ToupperBean_8roqg7_EOImpl.java:284)
>> at examples.wtc.atmi.simpapp.ToupperBean_8roqg7_EOImpl_WLSkel.invoke(Unknown
>>Source)
>> at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
>> at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
>> at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
>> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>>/////////////////////////////////////////////////////////////////////////////////
>>
>>Regards
>>Ranga Rao
>>
>>
>
-
Parameter name passed in Set Callable Statement
Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
Thanks!Is it not possible to pass parameter name in the callable statement while using Oracle drivers for jk 1.4??
Thanks!
Maybe you are looking for
-
i would like to view different materials with serial number present in my storage location how can i do this
-
Plumtree Job Dispatcher Service is giving error when i start the service
Could not start the plumtree Job Dispatcher service service on Local Computer. The service did not return an error. THis could be an internal windows rror or an internal service error. If the problem persits, contact your system administrator... Any
-
Is there a keyboard shortcut (or a custom keyboard shortcut) to close notifications that appear from iMessage, ical, etc. on a macbook pro - the notifications that appear on the top right of the macbook. For example, I do not want to go to my trackpa
-
Any technique to use two instruments vi together
hi, i am using labview to control arc monochromator and photon counter. i want to know is there any technique that i can use in lv 8, so that i dont have to control this two instrument with two differrent set of vi. That mean there should be one vi t
-
End of syncing my calendar on my own webserver?
Hi! Just updated my MacBook - and now it seems tat iCal has stopped syncing to my webDAV server.... It also seems that there are some problems by syncing to my iPhone!:( Events from the mac is synced to the iPhone - but new event on the iPhone is not