You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Arnaud Lemaitre (JIRA)" <ib...@incubator.apache.org> on 2007/06/24 19:27:26 UTC

[jira] Commented: (IBATIS-441) Multiple result sets support broken

    [ https://issues.apache.org/jira/browse/IBATIS-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12507702 ] 

Arnaud Lemaitre commented on IBATIS-441:
----------------------------------------


in SqlExecutor 
when in moveToNextResultsSafely() method , test  on

stmt.getConnection().getMetaData().supportsMultipleResultSets()    (added since IBATIS-269 )

is removed then it works perfectly so it's more a bug regarding MetaData returned. (Mysql J/Connector issue?)

Tests were done with this plateform :
Server version: 5.0.32-Debian_7etch1-log Debian etch distribution 
+ mysql-connector-java-5.0.6-bin.jar (or mysql-connector-java-5.0.5-bin.jar )

Anyway Database MetaData should be retrieved only once
 (during iBatis init stage? and probably output as well when debug turned on)
may be a warning should be thrown when Multiple resultSet is said to be not supported.

Actually i had to removed this test to suit my needs.


> Multiple result sets support broken
> -----------------------------------
>
>                 Key: IBATIS-441
>                 URL: https://issues.apache.org/jira/browse/IBATIS-441
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.3.0
>         Environment: Mysql Server version: 5.0.32-Debian_7etch1-log
> mysql-connector-java-5.0.6-bin.jar
> ibatis-2.3.0.677.jar
>            Reporter: Arnaud Lemaitre
>            Priority: Blocker
>
> the following iBATIS code can not retrieve the 2 expected result sets. plain JDBC equivalent is provided and is working properly.
> platform specific note :
> multiple queries (allowMultiQueries=true on JDBC url) is not working for Mysql server 4.0.24 (tested). apparently requires higher version > 4.1
> (following tests have been done using Mysql 5.0.32) 
> Here is my Code (for test purpose) :
> ...
> 		List results = null;
> 		SqlMapClient sqlMap = IbatisUtil.getSqlMapInstance();
> 		try{
> 			results = sqlMap.queryForList( "test" );
> 		}
> 		catch( SQLException sqle ) {
> 			throw CoreException.wrap( sqle );
> 		}
> 		
> 		final Logger logger = Logger.getLogger( MyCLass.class );
> 		
> 		logger.info ( "results.size() = " + results.size() );	
> ...
> mySqlMap.xml :
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
> <sqlMap namespace = "myNamespace">
>     <select id = "test" resultClass = "int, int">
>         <![CDATA[
>         select 1+1; select 2+2
>         ]]>
>     </select>
> </sqlMap>
> My iBATIS Config :
> ( i've set allowMultiQueries to true, when set to false (default) i've Got sql syntax errors... 
> <sqlMapConfig>
>     <settings
>         cacheModelsEnabled = "true"
>         enhancementEnabled = "true"
>         lazyLoadingEnabled = "true"
>         maxRequests = "32"
>         maxSessions = "10"
>         maxTransactions = "5"
>         useStatementNamespaces = "false"/>
>     <transactionManager type = "JDBC">
>         <dataSource type = "SIMPLE">
>             <property name = "JDBC.Driver" value = "com.mysql.jdbc.Driver"/>
>             <property name = "JDBC.ConnectionURL" value = "jdbc:mysql://dev:3306/myDatabase?autoReconnect=true&amp;allowMultiQueries=true&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8"/>
>             <property name = "JDBC.Username" value = "myUsername"/>
>             <property name = "JDBC.Password" value = " myPassword"/>
>         </dataSource>
>     </transactionManager>
>     <sqlMap resource = "com/x/y/z/mySqlMap.xml"/> </sqlMapConfig>
> Log4j output :
> DEBUG TP-Processor3 java.sql.Connection - {conn-100000} Connection
> DEBUG TP-Processor3 java.sql.Connection - {conn-100000} Preparing Statement:                   select 1+1; select 2+2              
> DEBUG TP-Processor3 java.sql.PreparedStatement - {pstm-100001} Executing Statement:                   select 1+1; select 2+2              
> DEBUG TP-Processor3 java.sql.PreparedStatement - {pstm-100001} Parameters: [] DEBUG TP-Processor3 java.sql.PreparedStatement - {pstm-100001} Types: [] DEBUG TP-Processor3 java.sql.ResultSet - {rset-100002} ResultSet DEBUG TP-Processor3 java.sql.ResultSet - {rset-100002} Header: [1+1] DEBUG TP-Processor3 java.sql.ResultSet - {rset-100002} Result: [2] DEBUG TP-Processor3 com.ibatis.common.jdbc.SimpleDataSource - Returned connection 1511627065 to pool.
> INFO TP-Processor3 com.x.y.MyCLass - results.size() = 1
> Here is the test :
> package com.test;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.Statement;
> public class test {
> 	public static void main( String[] args ) {
> 		new test( args );
> 	}
> public void testJDBCConnection() throws Exception
> 	{
> 		Class.forName( "com.mysql.jdbc.Driver" );
> 		
> 		String url = "jdbc:mysql://myHost:3306/myDatabase?autoReconnect=true&allowMultiQueries=true&characterEncoding=UTF-8&characterSetResults=UTF-8";
> 		
> 		Connection conn = DriverManager.getConnection( url, "myDatabase", "myPassword" );
> 			
> 		try
> 		{			
> 			String sqlString = "SELECT 1+1; SELECT 2+2; SELECT 3+3";
> 			System.out.println("Before executing");
> 			
> 			
> 			Statement stmt = conn.createStatement();
> 			stmt.execute( sqlString );
> 			for (;;) {
> 				int updateCount = stmt.getUpdateCount();
> 				if (updateCount >= 0) {
> // report rows affected...
> 				}
> 				else {
> 					ResultSet rs = stmt.getResultSet();
> 					if (rs == null)
> 					break;
> 					if ( rs.next() )
> 						System.out.println( "result :" + rs.getInt(1) ); // process resultset ....
> 				}
> 				stmt.getMoreResults();
> 			}
> 									
> 			System.out.println("After executing");
> 		}
> 		catch (Exception e)
> 		{
> 			System.out.println("Exception: " + e);
> 		}
> 		
> 	}
> public test( String[] args ) { 
> 	try
> 	{			
> 	testJDBCConnection(); 
> 	}
> 	catch (Exception e)
> 	{
> 		System.out.println("Exception: " + e);
> 	}
> }
> }
> And the output :
> Before executing
> result :2
> result :4
> result :6
> After executing

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.