Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [JDBC] Problem calling stored function

From: Francesco Storti <francesco.storti(at)gmail.com>
Date: Fri Jan 18 2008 - 06:35:12 EST


2008/1/17, Tom Lane tgl@sss.pgh.pa.us:

>
> Should work.  Maybe you're rolling back the transaction later, or
> something like that?
>
>                        regards, tom lane
>

Thank for the answer first ;)
I use rollback only if throwed an SQL exception. Here is my code:

*

public* *static* *int* ExecSP(DBParameters dbp, *int* min) *throws*Exception{

CallableStatement cs = *null*;

Connection con = *null*;

Exception errore = *null*;

*int* result =0;

Do you need help?X

*boolean* someError = *false*;

*try* {

con = DBUtils.*connect*(dbp);

cs = con.prepareCall("{? = call comp(?)}");

cs.registerOutParameter(1, Types.*INTEGER*);

cs.setInt(2, min);

cs.execute();

result = cs.getInt(1);

Do you need more help?X

}

*catch* (SQLException e) {

errore = *new* Exception (""+e.getErrorCode()+": "+

"Error in executing stored procedures for minute: "+ min +" - "+ e.getMessage());

con.rollback();

}

*catch* (Exception e) {

*if* (someError)

Can we help you?X

errore = e;

*else
*

errore = *new* Exception ("Error in executing stored procedures for minute: "+ min +" - "+e.getMessage());

con.rollback();

}

*finally* {

*try* {

*if* (cs != *null*)

Can't find what you're looking for?X

cs.close();

}

*catch* (SQLException e) {}

cs = *null*;

*try* {

*if* (con != *null*)

con.close();

}

Don't know where to look next?X

*catch* (SQLException e) {}

con = *null*;

}

*if* (errore != *null*)

*throw* errore;

*else
*

*return* result;

} Received on Fri Jan 18 06:36:58 2008

Confused? Frustrated?X

This archive was generated by hypermail 2.1.8 : Wed Jun 18 2008 - 23:43:05 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library