Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Stored procedure 'xxx' may be run only in unchained transaction mode." error when calling a procedure from a DataSource, in an EJB context
    primarykey
    data
    text
    <p>We have a Database in Sybase, which we access from a Java server.</p> <p>Access to the DB was made directly through the Sybase driver, using <code>DriverManager</code>. It was working correctly, we were able to call our stored procedures.</p> <p>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 <code>DataSource</code>: </p> <pre><code>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(); </code></pre> <p><em>(The DataSource is configured using the basic settings, from the <a href="http://community.jboss.org/wiki/SetUpASybaseDatasource" rel="nofollow">JBoss example</a>)</em></p> <p>However, in this setting, several procedures are failing, with this error: </p> <blockquote> <p>"Stored procedure '<strong>**</strong>' may be run only in unchained transaction mode."</p> </blockquote> <p>or this kind, for other cases (with the failing command changing): </p> <blockquote> <p>TRUNCATE TABLE command not allowed within multi-statement transaction</p> </blockquote> <p>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.</p> <p>Is there a way to prevent this behaviour (assuming that this is the actual problem)?</p> <hr> <p><em>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.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COWhat are you using for transaction management? I assume you're initiating a txn from a stateless session bean? This message usually occurs because of a third party setting an auto-commit property and/or the SET CHAINED setting on the DB
      singulars
    2. CO@karianna - the datasource is initialized in an init servlet, and the calls after are made from stateless beans indeed. I don't see though what can set these properties, which is why I assumed it was a setting in JBoss. I don't see any other "third party" in this context.
      singulars
    3. COI would strongly recommend altering your code/architecture so that it can utilise the power of JBoss's connection pooling, data sources etc. The actual code change will be quite small (it's still a JNDI lookup) and you'll be able to define whether you are using 2-phase XA, local or no transaction datasources (you define those in the *-ds.xml file). See http://community.jboss.org/wiki/configdatasources for a starting point. You probably also then need to (via EJB3 annotations I'm guessing) hook into Jboss's Txn manager.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload