From: | "Francesco Storti" <francesco(dot)storti(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Cc: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Problem calling stored function |
Date: | 2008-01-18 11:35:12 |
Message-ID: | bf6786b40801180335v741f75d9gc3ced6504b4f38b8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
2008/1/17, Tom Lane tgl(at)sss(dot)pgh(dot)pa(dot)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;
*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);
}
*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)
errore = e;
*else
*
errore = *new* Exception ("Error in executing stored procedures for minute:
"+ min +" - "+e.getMessage());
con.rollback();
}
*finally* {
*try* {
*if* (cs != *null*)
cs.close();
}
*catch* (SQLException e) {}
cs = *null*;
*try* {
*if* (con != *null*)
con.close();
}
*catch* (SQLException e) {}
con = *null*;
}
*if* (errore != *null*)
*throw* errore;
*else
*
*return* result;
}
From | Date | Subject | |
---|---|---|---|
Next Message | tivvpgsqljdbc | 2008-01-18 11:40:57 | Re: Problem calling stored function |
Previous Message | M.Khaled | 2008-01-18 07:53:10 | Can not access the public schema |