commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (DBCP-461) Prepared statements are not cached with XA
Date Thu, 26 Jul 2018 02:26:00 GMT

     [ https://issues.apache.org/jira/browse/DBCP-461?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gary Gregory updated DBCP-461:
------------------------------
    Description: 
Prepared statements are not getting cached when I use XA datasource. 
 Please find the below program :

{code:java}
    public static void main(String[] args) throws Exception {
        final TransactionManager transactionManager = TransactionManagerFactory.getTransactionManager();
        final PoolProperties poolProperties = new PoolProperties();

        SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
        dataSource.setUser("sa");
        dataSource.setPassword("$9Lserver");
        dataSource.setURL("jdbc:sqlserver://sdwivedi63ks022:1433;sendStringParametersAsUnicode=false");
        dataSource.setDatabaseName("himalaya");
        poolProperties.setDataSource(dataSource);

        final String jdbcInterceptors = "org.apache.tomcat.jdbc.pool.interceptor.StatementCache(prepared=true,callable=true)";
        poolProperties.setJdbcInterceptors(jdbcInterceptors);
        final org.apache.tomcat.jdbc.pool.DataSource pooledOracleDatasource = new org.apache.tomcat.jdbc.pool.XADataSource(poolProperties);
        final javax.sql.DataSource oracleDataSource = new org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource(pooledOracleDatasource,
transactionManager,
                TransactionProvider.getTransactionSynchronizationRegistry());
        Connection connection = oracleDataSource.getConnection();
        for (int i = 0; i < 50; i++) {
            PreparedStatement preparedStatement = connection.prepareStatement("insert
into MyTableNew values (" + i + ")");
            System.out.println(preparedStatement.getClass().getName());
            preparedStatement.execute();
            preparedStatement.close();
        }

        connection.close();
    }
{code}

If I run the above program, the output I see is:
 com.sun.proxy.$Proxy11

If I just change the above program to use XA datasource, i.e.
 Change the following line
 SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
 To
 SQLServerXADataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerXADataSource();
 The output is :
 com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement

  was:
Prepared statements are not getting cached when I use XA datasource. 
Please find the below program :

public static void main(String[] args) throws Exception 
	{
		final TransactionManager transactionManager = TransactionManagerFactory
				.getTransactionManager();
		final PoolProperties poolProperties = new PoolProperties();
		
		SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
		dataSource.setUser("sa");
		dataSource.setPassword("$9Lserver");
		dataSource.setURL("jdbc:sqlserver://sdwivedi63ks022:1433;sendStringParametersAsUnicode=false");
		dataSource.setDatabaseName("himalaya");
		poolProperties.setDataSource(dataSource);
		
		final String jdbcInterceptors = "org.apache.tomcat.jdbc.pool.interceptor.StatementCache(prepared=true,callable=true)";
		poolProperties.setJdbcInterceptors(jdbcInterceptors);
		final org.apache.tomcat.jdbc.pool.DataSource pooledOracleDatasource = new org.apache.tomcat.jdbc.pool.XADataSource(
				poolProperties);
		final javax.sql.DataSource oracleDataSource = new org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource(
				pooledOracleDatasource, transactionManager,
				TransactionProvider.getTransactionSynchronizationRegistry());
		Connection connection = oracleDataSource.getConnection();
		for(int i=0; i<50; i++)
		{
			PreparedStatement preparedStatement = connection.prepareStatement("insert into MyTableNew
values (" + i + ")");
			System.out.println(preparedStatement.getClass().getName());
			preparedStatement.execute();
			preparedStatement.close();
		}
		connection.close();
	}

If I run the above program, the output I see is:
	com.sun.proxy.$Proxy11

If I just change the above program to use XA datasource, i.e.
Change the following line
		SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
				To
		SQLServerXADataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerXADataSource();
The output is :
	com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement




> Prepared statements are not cached with XA
> ------------------------------------------
>
>                 Key: DBCP-461
>                 URL: https://issues.apache.org/jira/browse/DBCP-461
>             Project: Commons DBCP
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: TomEE Version : Apache Tomcat Version 7.0.63
>            Reporter: Sailaja
>            Priority: Major
>
> Prepared statements are not getting cached when I use XA datasource. 
>  Please find the below program :
> {code:java}
>     public static void main(String[] args) throws Exception {
>         final TransactionManager transactionManager = TransactionManagerFactory.getTransactionManager();
>         final PoolProperties poolProperties = new PoolProperties();
>         SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
>         dataSource.setUser("sa");
>         dataSource.setPassword("$9Lserver");
>         dataSource.setURL("jdbc:sqlserver://sdwivedi63ks022:1433;sendStringParametersAsUnicode=false");
>         dataSource.setDatabaseName("himalaya");
>         poolProperties.setDataSource(dataSource);
>         final String jdbcInterceptors = "org.apache.tomcat.jdbc.pool.interceptor.StatementCache(prepared=true,callable=true)";
>         poolProperties.setJdbcInterceptors(jdbcInterceptors);
>         final org.apache.tomcat.jdbc.pool.DataSource pooledOracleDatasource =
new org.apache.tomcat.jdbc.pool.XADataSource(poolProperties);
>         final javax.sql.DataSource oracleDataSource = new org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource(pooledOracleDatasource,
transactionManager,
>                 TransactionProvider.getTransactionSynchronizationRegistry());
>         Connection connection = oracleDataSource.getConnection();
>         for (int i = 0; i < 50; i++) {
>             PreparedStatement preparedStatement = connection.prepareStatement("insert
into MyTableNew values (" + i + ")");
>             System.out.println(preparedStatement.getClass().getName());
>             preparedStatement.execute();
>             preparedStatement.close();
>         }
>         connection.close();
>     }
> {code}
> If I run the above program, the output I see is:
>  com.sun.proxy.$Proxy11
> If I just change the above program to use XA datasource, i.e.
>  Change the following line
>  SQLServerDataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerDataSource();
>  To
>  SQLServerXADataSource dataSource = new com.microsoft.sqlserver.jdbc.SQLServerXADataSource();
>  The output is :
>  com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message