We have a Database in Sybase, which we access from a Java server.
Access to the DB was made directly through the Sybase driver, using DriverManager
. It was working correctly, we were able to call our stored procedures.
Recently, we are migrating to an application server (on JBoss 5), and the calls to the database are now made through a JNDI connector, using a DataSource
:
Properties ppt = new Properties();
ppt.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
ppt.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
ppt.put("java.naming.provider.url", "jdbc/sybase");
InitialContext ctx = new InitialContext(ppt);
DataSource ds = (DataSource) ctx.lookup(AConfig.getInstance().getDatasourceJndiName());
Connection conn = ds.getConnection();
(The DataSource is configured using the basic settings, from the JBoss example)
However, in this setting, several procedures are failing, with this error:
"Stored procedure '**' may be run only in unchained transaction mode."
or this kind, for other cases (with the failing command changing):
TRUNCATE TABLE command not allowed within multi-statement transaction
From what I found on Internet, it looks like something in the JBoss or the connector is opening a transaction itself, causing these errors. As such, the diverse solutions I could find for these particular problems are too localized, and it seems like a bigger issue.
Is there a way to prevent this behaviour (assuming that this is the actual problem)?
My knowledge in this particular field is quite thin, this is new to me. As such, there are probably important details missing to this description. Please indicate me how I can improve this question, what details I can add, if necessary.