Jeff Butler | 12 Apr 14:15 2008
Picon

Re: Sybase OEM

I have that *not quite* right - you need to also override the TransactionConfig and specify *that* class in the SqlMapConfig.xml file.
 
Jeff Butler


 
On Sat, Apr 12, 2008 at 7:12 AM, Jeff Butler <jeffgbutler <at> gmail.com> wrote:
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">
  ...
</transactionManager>
 
For example,
 
public class MyTransactionManager extends JdbcTransaction {
 
  <at> Override
  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 <at> 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.


Larry Meadors | 12 Apr 15:15 2008
Picon

Re: Problem in resultMap:Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed

This looks like a DB2 issue, you may want to search for that error
string (HY010), I think that's probably going to get you a solution
quickest.

Larry

Harvey Kim | 12 Apr 21:49 2008

Re: groupby x out of memory

Yeap, that's what I ended up doing.  I used subsequent selects to get
the list and that seem to have solved the problem.  Although, I did get
out of memory with using RowHandler even after I got rid of the groupBy
but that only happened once (out of thousands of runs as oppose to
happening everytime with groupBy).  So I can't be 100% positive that
just using the RowHandler (without the groupby) will cause memory
problem since I haven't been really able to reproduce it except seeing
the available memory decreasing slowly with every call to the
rowhandler.  And based on what people are saying, I'm starting to feel
little more relieved and confident that it was strictly a groupBy
problem and the RowHandler itself isn't the cause.  Any other reassuring
experience and supporting comments will be greatly appreciated since I
did see it happen once :).

On Fri, 11 Apr 2008 22:50:33 -0600, "Clinton Begin"
<clinton.begin <at> gmail.com> said:
> OOOOOHHHHHH!!!!..... now this makes sense.....  I misunderstood the
> original
> issue.
> 
> My apologies.  Yes, now it's clear.  The internal tracking of the row IDs
> will cause an out of memory exception to occur (as you know, it is a
> hashmap).
> 
> Unfortunately there's no practical solution to this.  For groupBy to
> work,
> it has to track the IDs, and really, for groupby to be effective, the end
> result set should end up in memory to avoid handling partial data.  I'll
> have to check, but I'm not even sure the rows would be processed in the
> correct order for the rowhandler to work with groupby.  For example, if
> there's 100 records between the parent object and a child element in the
> collection, the parent may have already been passed back to the
> rowhandler
> before all the children are loaded.
> 
> These features are fundamentally incompatible.  There's no magic solution
> for it unfortunately.  Your best bet is to flatten the object hierarchy
> for
> this process to avoid the need for groupby. You'll have the same problem
> if
> you tried to mimick this behavior with JDBC or any other toolset (other
> than
> something that simply used a subsequent select to load children).
> 
> Cheers,
> Clinton
> 
> 
> 
> 
> On Fri, Apr 11, 2008 at 11:57 AM, Harvey Kim <cashtag <at> fastmail.fm> wrote:
> 
> > Is the app running for days/years or is the query running for
> > days/years?  If the query returns 24 million rows, I get out of error
> > memory every single time.  In theory, no query should really take days
> > to return but we just happen to run into this case because our DBA
> > forgot to put the index on the tables :-).  After the indexing, the
> > analyzing, paralleling, ... the query came back much much faster.  But
> > it also ran out of memory much much faster.  I think it's the function
> > of how many rows get processed on a single query - not really how long
> > the apps been running.  And I doubt there are many application out there
> > that returns 24 millions rows on a single query where each object
> > returned can be thousands of bytes.  Or maybe there are... If there are,
> > I'd love to hear if there were memory leak problems on their app.
> >
> > I'm just guessing here but internally, doesn't groupBy allocate HashMap
> > to keep track of what it is grouping?
> >
> > On Fri, 11 Apr 2008 11:42:10 -0600, "Clinton Begin"
> > <clinton.begin <at> gmail.com> said:
> > > I can't imagine why that would happen.  If this was a bug, I would think
> > > far
> > > more people would be experiencing it.  I have apps that have run for
> > > months,
> > > and in some cases years, without running out of memory.  GroupBy doesn't
> > > do
> > > anything special really.  It just skips duplicate rows for a parent
> > > class.
> > >
> > > Try iBATIS 2.3.1.  If there is a problem, it might have to do with
> > > session/transaction management.  2.3.1 improves the handling of such.
> > >
> > > Clinton
> > >
> > > On Fri, Apr 11, 2008 at 10:10 AM, Harvey Kim <cashtag <at> fastmail.fm>
> > wrote:
> > >
> > > > If you use groupBy, you will eventually run out of memory.  Few months
> > > > ago, I e-mailed a sample program which showed my application doing
> > > > absolute nothing except issuing a ibatis query.  It was using
> > > > queryWithRowHandler.  Literally, all it did was call
> > > > "queryWithRowHandler" and my rowHanlder did absolutely nothing.
> > > > Literally this:
> > > >
> > > > public class IbatisDownloadThread implements Runnable, Serializable,
> > > > RowHandler
> > > > {
> > > >  private SqlMapClient sqlMapClient = null;
> > > >
> > > >  public void run()
> > > >  {
> > > >      try
> > > >      {
> > > >        sqlMapClient = BaseDAO.getSqlMapClient();
> > > >        sqlMapClient.queryWithRowHandler("getIdList", queryDto, this);
> > > >     }
> > > >  }
> > > >
> > > >  public void handleRow()
> > > >  {
> > > >  }
> > > > }
> > > >
> > > > The above code eventually gets "Out of Memory" error and the query is
> > > > using a groupBy.  When I took out the "groupBy", it went MUCH MUCH
> > MUCH
> > > > longer.  But even that ran out of memory after few hours of running.
> > > > However, once I converted everything to a JDBC loop, "Out of Memory"
> > > > error went away.  When I examined the available memory at runtime, I
> > > > could see the available memory decreasing with every call to
> > > > "handleRow()".  With JDBC, I examined the heap size inside the loop
> > and
> > > > it held steady for hours and finished without a problem.
> > > >
> > > > The moral of the story - you could probably get away with ibatis if
> > you
> > > > take out the groupBy (that was my quick fix).  I took out the groupBy
> > > > and simply issued another ibatis command to get the list inside
> > > > "handleRow()".  That was my quick fix and it is probably sufficient
> > for
> > > > now.
> > > >
> > > > You can still run out of memory if you use "queryWithRowHandler" but
> > > > highly unlikely unless you have an application like mine which could
> > > > have a thread running for days.  But to be really safe, you have to go
> > > > back to JDBC.  Since I was on a tight deadline, I didn't bother going
> > > > through the ibatis code but I may do that one of these days because it
> > > > is a wonderful tool.
> > > >
> > > >
> > > > On Tue, 8 Apr 2008 12:27:29 -0700 (PDT), "Carlos de Luna Saenz"
> > > > <cdelunasaenz <at> yahoo.com.mx> said:
> > > > > It seems like there is not enough data in your mail...
> > > > > what data base are you accessing? how are you dealing with it
> > > > (DataSource
> > > > > is JDBC or via the App Server) your class is keeping the data for
> > any
> > > > > reason (maybe in a session or application bean)? what's the App
> > Server?
> > > > > etc, etc... if i were you i should look all that kind of variables
> > and
> > > > > monitor with a profiler to see if there's somehint wrong with the
> > query,
> > > > > the server, the managed memory, or all of the above.
> > > > > Greetings
> > > > > Carlos de Luna
> > > > >
> > > > > ----- Mensaje original ----
> > > > > De: Fernando Simonetti <fernando <at> cosipa.com.br>
> > > > > Para: "user-java <at> ibatis.apache.org" <user-java <at> ibatis.apache.org>
> > > > > Enviado: martes, 8 de abril, 2008 7:51:26
> > > > > Asunto: groupby x out of memory
> > > > >
> > > > > Eventually my aplication server is going down by "Out of Memory".
> > > > > Analizing
> > > > > de heap dumping, it's point for the same class allocating 600 Mb.
> > > > >
> > > > > This event can occur 3 hours or 3 days after I restart my server.
> > This
> > > > > class
> > > > > is used thounsands times in the period. Monitoring the memory of the
> > > > > server,
> > > > > I could see 300MB to 700MB of memory been allocated in  3 minutes.
> > It
> > > > > hapens
> > > > > eventualy but not in a determined period.
> > > > >
> > > > > The unique diference for this class for others, is the groupby
> > clause in
> > > > > Ibatis. First I thouth it could be a cartesian product, but I ran
> > the
> > > > > query
> > > > > without parameters and found nothing.
> > > > >
> > > > > I going to implement this class without groupby clause, but first I
> > > > would
> > > > > like to see if there are other options.
> > > > >
> > > > >
> > > > > thanks,
> > > > > Fernando
> > > > >
> > > > >
> > > > >
> > > >
> > ____________________________________________________________________________________
> > > > > ¡Capacidad ilimitada de almacenamiento en tu correo!
> > > > > No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
> > > > > http://correo.espanol.yahoo.com/
> > > > >
> > > >
> > > > --
> > > > http://www.fastmail.fm - Accessible with your email software
> > > >                          or over the web
> > > >
> > > >
> >
> > --
> > http://www.fastmail.fm - mmm... Fastmail...
> >
> >

--

-- 
http://www.fastmail.fm - Send your email first class

nepalon | 13 Apr 05:47 2008

Re: Problem in resultMap:Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed


The DB i using is SQL Server2005.The error string(HY010) means "Invalid
state, the ResultSet object is closed".Somebody says this error cause by
using miscrosoft sql server driver,but I using jtds as my dirver.

Larry Meadors wrote:
> 
> This looks like a DB2 issue, you may want to search for that error
> string (HY010), I think that's probably going to get you a solution
> quickest.
> 
> Larry
> 
> 

--

-- 
View this message in context: http://www.nabble.com/Problem-in-resultMap%3ACause%3A-java.sql.SQLException%3A-Invalid-state%2C-the-ResultSet-object-is-closed-tp16624071p16656703.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

Jeff Butler | 13 Apr 16:41 2008
Picon

Re: Problem in resultMap:Cause: java.sql.SQLException: Invalid state, the ResultSet object is closed

I once had a similar problem with DB2.  The problem was that the DB was configured to allow only one open ResultSet per connection.
 
With your query, you will have more than one open ResultSet - so make sure your DB is configured to allow this.
 
Jeff Butler

On Sat, Apr 12, 2008 at 10:47 PM, nepalon <inepalon <at> 163.com> wrote:

The DB i using is SQL Server2005.The error string(HY010) means "Invalid
state, the ResultSet object is closed".Somebody says this error cause by
using miscrosoft sql server driver,but I using jtds as my dirver.

Larry Meadors wrote:
>
> This looks like a DB2 issue, you may want to search for that error
> string (HY010), I think that's probably going to get you a solution
> quickest.
>
> Larry
>
>

--
View this message in context: http://www.nabble.com/Problem-in-resultMap%3ACause%3A-java.sql.SQLException%3A-Invalid-state%2C-the-ResultSet-object-is-closed-tp16624071p16656703.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Zoran Avtarovski | 14 Apr 06:05 2008

[ABATOR]: Question and feedback

I used Abator for the time last week on a small project that I was trying to get out the door in hurry.

First impressions are great, it helped me the base code  out in no time flat and allowed me to focus on the stuff that needed it. This is a great tool Jeff.

I have a couple of questions / suggestions:

  1. Is there any way of easily changing the code templates to modify the generated code? Not only the java code, but things like the sqlmap xml files.
  2. Can I manually specify foreign key relationships? I couldn’t find any information about this, but it would be great if I could specify any relationships and their type (eg 1:1, 1:n ) which would allow abator to generate some boilerplate code.
  3. Related to the previous point I’d like to be able to specify an alias for a table (eg Table Users as U) and then the associated ByExample model would use that alias in the generated code (eg where U.name = ‘x’). The big advantage will be extending the ByExample  to easily cater to foreign key relationships

I don’t want to come across as the sort of person who’s complaining about the lack of features in an OS product. I think it’s great and I’d love to help where I can. I didn’t want to charge off making changes without getting a feel for what the roadmap for abator is and what others are already doing.

Is there a contributors guide to the code? It would be nice to have an overview of what’s happening where.

Z.
Alex Perez | 14 Apr 12:15 2008
Picon

Re: Sybase OEM


Thanks Jeff,

I've extended from JDBCTransaction and JDBCTransactionConfig and it worked perfectly!


2008/4/12, Jeff Butler <jeffgbutler <at> gmail.com>:
I have that *not quite* right - you need to also override the TransactionConfig and specify *that* class in the SqlMapConfig.xml file.
 
Jeff Butler


 
On Sat, Apr 12, 2008 at 7:12 AM, Jeff Butler <jeffgbutler <at> gmail.com> wrote:
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">
  ...
</transactionManager>
 
For example,
 
public class MyTransactionManager extends JdbcTransaction {
 
  <at> Override
  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 <at> 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.





--
3rd Law of Computing:
Anything that can go wrSegmentation fault -- core dumped.
Radoslaw Zmuda | 14 Apr 15:14 2008
Picon

IBatis+teradata

Hi All,

The scenario of my problem is as follows:
- I've tried to prevent my app against SQL injection, so I changed  a '$' signs into '#' signs in xml files where value of parameters are added
- the problem was solved but there appears another one: problem with Date object insertion.
  Previously (when '$' signs where present) the Date object was converted into String in my code, so into statement was placed i.e.'2008-14-03' and the fields was correctly placed on Teradata db (db field types of Date)
- After changing into '#' signs I get the following message from terradata jdbc driver :
com.ncr.teradata.jdbc_4.util

.JDBCException: [NCR] [Teradata DBMS] : Invalid date supplied for TABLE_NAME.DATE_FIELD_NAME.

It is no matter if Date is converted into String or it is pure Date object.

I'm guessing that IBatis converts Date into yyyy-mm-dd hh:mm:ss format and this looks like DateTime type rather than Date for teradata.
So my question is: is there any possibility to reconfigure default format for IBatis date or if there is any other soluition to this problem.

Here is piece of code from which insertion starts:

// insert
        QueryParams qp = newQP(gtd);
        setUpdates(qp, gtd, row, true, true);
        getSqlMapClientTemplate().insert(makeName("insert"), qp);

Best Regards,
Radek
Brandon Goodin | 14 Apr 15:23 2008
Picon

Re: IBatis+teradata

iBATIS uses straight jdbc underneath. If the field in your database is a varchar and the bean property is a Date object it will be up to the jdbc driver to perform the conversion.  You can make sure that iBATIS is using the proper PreparedStatement calls if you explicitly specify the type of the bean property and database column.

Brandon Goodin

On Mon, Apr 14, 2008 at 8:14 AM, Radoslaw Zmuda <radek.zmuda <at> gmail.com> wrote:
Hi All,

The scenario of my problem is as follows:
- I've tried to prevent my app against SQL injection, so I changed  a '$' signs into '#' signs in xml files where value of parameters are added
- the problem was solved but there appears another one: problem with Date object insertion.
  Previously (when '$' signs where present) the Date object was converted into String in my code, so into statement was placed i.e.'2008-14-03' and the fields was correctly placed on Teradata db (db field types of Date)
- After changing into '#' signs I get the following message from terradata jdbc driver :
com.ncr.teradata.jdbc_4.util
.JDBCException: [NCR] [Teradata DBMS] : Invalid date supplied for TABLE_NAME.DATE_FIELD_NAME.

It is no matter if Date is converted into String or it is pure Date object.

I'm guessing that IBatis converts Date into yyyy-mm-dd hh:mm:ss format and this looks like DateTime type rather than Date for teradata.
So my question is: is there any possibility to reconfigure default format for IBatis date or if there is any other soluition to this problem.

Here is piece of code from which insertion starts:

// insert
        QueryParams qp = newQP(gtd);
        setUpdates(qp, gtd, row, true, true);
        getSqlMapClientTemplate().insert(makeName("insert"), qp);

Best Regards,
Radek

kiran vuppla | 14 Apr 16:09 2008
Picon

Reading xml file


I have an xml file and want to store in to an IBatis object. Please let me know if any one has any solution to write the SQL.

XML FILE:

<content>
  <talent>
    <image>/images/test1.gif</image>
    <imageAltText>testImageAltText</imageAltText>
    <links>
    <link>/urls/link1.html</link>
    <text>link1</text>
    </links>
    <links>
    <link>/urls/link2.html</link>
    <text>link2</text>
    </links>
   </talent>
  <talent>
    <image>/images/test2.gif</image>
    <imageAltText>testImageAltText2</imageAltText>
    <links>
    <link>/urls/link3.html</link>
    <text>link3</text>
    </links>
    <links>
    <link>/urls/link4.html</link>
    <text>link4</text>
    </links>
   </talent>
  </content>

IBATIS RESULT MUST BE:

   <resultMap class="com.test.domain.MainModule" id="MainModuleResultObject" groupBy="id">
    <result property="modules" resultMap="module.ModuleResults"/>
   </resultMap>

   <resultMap class="com.test.domain.Module" id="ModuleResults" groupBy="id">
      <result pro perty="id" column="ID"/>
       <result property="titleImageURL" column="IMG_URL"/>
       <result property="titleImageAltText" column="IMG_ALT_TEXT"/>
       <result property="moduleElements" resultMap="module.ModuleElementResult"/>      
    </resultMap>

   <resultMap class="com.test.domain.ModuleElement" id="ModuleElementResult">
            <result property="link" column="LINK"/>
            <result property="text" column="TEXT"/>
    </resultMap>

 If some one can help me out in writing SQL to return the result in the above format that would be grateful.

 Thanks in advance for your time.
 Kiran

 


Gmane