ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Zeitz" <carsten.ze...@gmx.de>
Subject Re: Problem inserting many rows
Date Tue, 17 Oct 2006 06:58:22 GMT
Hi,

I found the problem myself. The iBATIS transaction manager uses a throttle for the opened
transactions. This throttle is limited to 32. Each beginTransaction() increments a counter,
an if the limit is reached, no more transactions can be startet. A simple commitTransaction()
does not decrement the counter. The endTransaction() finally solves this problem.

Carsten


-------- Original-Nachricht --------
Datum: Mon, 16 Oct 2006 22:46:02 +0200
Von: "Carsten Zeitz" <carsten.zeitz@gmx.de>
An: user-java@ibatis.apache.org
Betreff: Problem inserting many rows

> Hi,
> 
> these are my first steps using iBATIS. I'd like to use it in an
> application to write incoming messages to a MySQL database. I just make a simple test
> to check the performance. I use a loop to insert 2000 message objects. The
> result: It inserts 10, then waits, insert another 10, waits, ... and after
> 32 message it hangs up.
> 
> Now where is my problem ???
> 
> Here my configuration:
> 
> <sqlMapConfig>
> 
>  	<properties resource="etc/database.properties"/>
> 
>   	<transactionManager type="JDBC">
>     	<dataSource type="SIMPLE">
> 	      	<property value="${driver}" name="JDBC.Driver"/>
> 	      	<property value="${url}" name="JDBC.ConnectionURL"/>
> 	  	<property value="${username}" name="JDBC.Username"/>
> 	    	<property value="${password}" name="JDBC.Password"/>
> 		</dataSource>
>   	</transactionManager>
> 
>   	<sqlMap resource="etc/Message.xml"/>
> 
> </sqlMapConfig>
> 
> <sqlMap namespace="Message">
>   	<typeAlias alias="Message" type="Message"/>
> 
>   	<insert id="insertMessage" parameterClass="Message">
>     		INSERT INTO messages ( timeStamp, ip, text )
>     		VALUES ( #timeStamp#, #ip#, #text# )
>   	</insert>
> 
> </sqlMap>
> 
> 
> Reader reader = Resources.getResourceAsReader("etc/ibatis-config.xml");
> SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
> 			
> Message tMessage = new Message();
> 
> for( int i = 0; i < 2000; i++ )
> {
> 	sqlmap.startTransaction();
> 	sqlmap.insert("insertMessage", tMessage );
> 	System.out.println("Insert " + i);
> 	sqlmap.commitTransaction();
> }
> 
> 
> I hope you can help me!
> 
> Thanks a lot,
> Carsten
> 
> 
> -- 
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Mime
View raw message