ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Sybase OEM
Date Sat, 12 Apr 2008 12:12:19 GMT
I think your last option is not that bad - it centralizes the initialization
of the Connection.

Another option with iBATIS is to implement your own transaction manager.
Write a class that subclasses the current transaction manager you are using
and override the getConnection() method.  Look in the package
com.ibatis.sqlmap.engine.transaction and subpackages to see the code for the
iBATIS supplied transaction managers.  In the overridden method, initialize
the connection before returning it.

In your sqlMapConfig.xml file, you can specify your new transaction manager:

<transactionManager type="com.mycompany.MyTransactionManager">

For example,

public class MyTransactionManager extends JdbcTransaction {

  public Connection getConnection() throws SQLException,
TransactionException {
    Connection conn = super.getConnection();
    Statement stmt = conn.createStatement();
    stmt.execute("set temporary ....");
    return conn;

Jeff Butler

On Sat, Apr 12, 2008 at 6:20 AM, Alex Perez <quimicefa@gmail.com> wrote:

> Hi All,
> I'm trying to adapt an existing application running with ibatis, to work
> with sybase.
> To write the sqlpmaps, I've just rewrited the SQL server 2000 ones, and
> just worked ok. The tests were done with Sybase ASA 9.x (the "enterprie
> version").
> The problem begins when trying to get it working with Sybase OEM, that
> it's the same databae enginte, but ready to embed into applications. My
> company has a OEM contract to use this engine as an embedded database in our
> products. But (and here starts the nightmare), due to some license
> restrictions it's mandatory send a sentence each time you start a connection
> database like:
> SET TEMPORARY OPTION connection_authentication="XXXXXXXXXXXXX" [really a
> very large string]
> Otherwise you'll only be able to send select statements to the database,
> and get disconnected after 10 seconds aprox.
> The first attempt was, in my sybase-database.properties, put a jdbc url:
> jdbc:sybase:localhost:port?ServiceName=database_name?sqlinitstring="set
> temporary ........"
> But I get an exception due to the driver. It seems like the jdbc url
> cannot be longer than 253 chars, and the auth_string is about 500 chars
> long.
> Also I 've tried to send this "set option" trought an ibatis "update"
> statements, like an stored procedure, but unsuccessfully.
> The last test to get it working, was:
> In this code:
> http://www.mirthproject.org/fisheye/browse/Mirth/tags/1.7.0/server/src/com/webreach/mirth/server/util/SqlConfig.java?r=2754
> after the .buildSqlMapClient() call, doing a (in pseudo-code)
> conn = sqlMap.getDatasource().getConnection();
> Statement stmt = conn.createStatement();
> stmt.execute("set temporary ....");
> stmt.commit();
> To try to bypass Ibatis layer [yes, it's horrible]
> Could anyone help me to figure out how can I send the "set temporary
> option ..." for every connection created to the database ?
> thanks in advance.
> --
> 3rd Law of Computing:
> Anything that can go wrSegmentation fault -- core dumped.

View raw message