This is the relevant piece of code:
cStmt = conn.prepareCall( "{ call getResults(
? ) }" );
cStmt.setInt(1, surID);
rs = cStmt.executeQuery();
everything upto this point is ok i.e. I have the connection etc
The error is :
Stored procedure 'dbo.getResults' may be run only in unchained transaction
mode. The 'SET CHAINED OFF' command will cause the current session to use
unchained transaction mode.
To overcome this I put the following piece of code before calling the above SP:
CallableStatement aStmt = conn.prepareCall( "{ call sp_procxmode
getResults, anymode }" );
aStmt.execute();
This gives the error
The specified object 'getResults' is not found in database 'abc'.
Check sysobjects to make sure you own the object.
Obviously I do not own the object since I am just a user
So - how do I call 'set chained off' from within jdbc code?
Thanks,
Anand
"Anand Hirekatur" <anand.h...@ucop.edu> wrote in message news:3B2572AC...@ucop.edu...
"Nick Elson" <nick....@sybase.com> wrote in message news:C76zvav...@forums.sybase.com...
Also when I run the actual SP by not using Connection Pooling but by using DriverManager and loading the driver class it executes just fine. We are using a J2EE based app server.
Thanks,
Anand
Nick Elson wrote:
Obviously I didn't read through that whole thread. You should probably just run that from OpenClient ISQLonce and not try to do it from within a middle tier design.This execute mode is a permanent flag (unless you changeit later) and you should only need to set it once from theASE management tools (ISQL or Sybase Central). If you really must do this from withing your Java code thenmake sure you specify the database and owner on thatstored procedure; as in: CallableStatement aStmt = conn.prepareCall( "{ call sp_procxmode abc.dbo.getResults, anymode }" );It is just possible the account used in the connection pool is eitherconnecting to the wrong database (abc), or has been switched tousing a different databasse (on a different connection use) oryou cannot see dbo objects (for some unknown strange reasons). Watch out for connection pools and playing with ASE things likeconnection options, permissions, execute/transaction modesset users, setting rols and switching databases. Then nextuser of the connection can get a nasty surprise. So if youexpect to be exposed to these variables, you may want toenforce 'your' own defaults on every use."Nick Elson" <nick....@sybase.com> wrote in message news:C76zvav...@forums.sybase.com...This is simple an ASE procedure attribute problem. All stored procedures are flagged with a Procedure Execute Modewhich is unchainced by default. So when you create you stored procedures they are flagged in such a way thatwill throw this errorr if you are running in chained mode. A lot of our products managed transactions using chained mode and that can be a problem with somesproc designs. By running sp_procxmode <proc_name>, "chained"or sp_procxmode <proc_name>, "anymode" you can avoid this message. I usually suggest people use "anymode"(because "chained" can break other existing applicatons). CAVEAT: Any mode change may impact how the procedure needs to be coded."Anand Hirekatur" <anand.h...@ucop.edu> wrote in message news:3B2572AC...@ucop.edu...Also I am using Connection Pooling. If I run this code without connection pooling i.e I load the driver etc this code runs fine.
"Anand Hirekatur" <anand.h...@ucop.edu> wrote in message news:3B266514...@ucop.edu...
From a traditional JDBC app using jConnect toggling
Connection.setAutoCommit()
will result in the backend receiving set chained on/off.
from jConnect.
The sprocs will pick up their mode by the state of the session
that they were created in. As Nick points out, in many cases
you can simply have the dba issue sp_procxmode to change under
what scenarios the sproc can run.
Note that occasionally this might require logic changes to
the sproc to get the desired results.
Lance