mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	mike beachy's patch for statement handling
This commit is contained in:
		@@ -12,7 +12,7 @@ import java.lang.reflect.*;
 | 
				
			|||||||
 * @see ConnectionPool
 | 
					 * @see ConnectionPool
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Aaron Mulder (ammulder@chariotsolutions.com)
 | 
					 * @author Aaron Mulder (ammulder@chariotsolutions.com)
 | 
				
			||||||
 * @version $Revision: 1.4 $
 | 
					 * @version $Revision: 1.5 $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class PooledConnectionImpl implements PooledConnection
 | 
					public class PooledConnectionImpl implements PooledConnection
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -204,8 +204,15 @@ public class PooledConnectionImpl implements PooledConnection
 | 
				
			|||||||
						return Boolean.FALSE;
 | 
											return Boolean.FALSE;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					                                try
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
                                    return method.invoke(con, args);
 | 
					                                    return method.invoke(con, args);
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					                                catch (InvocationTargetException e)
 | 
				
			||||||
 | 
					                                {
 | 
				
			||||||
 | 
					                                    throw e.getTargetException();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			// All the rest is from the Connection interface
 | 
								// All the rest is from the Connection interface
 | 
				
			||||||
			if (method.getName().equals("isClosed"))
 | 
								if (method.getName().equals("isClosed"))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -354,9 +361,16 @@ public class PooledConnectionImpl implements PooledConnection
 | 
				
			|||||||
                return con.getProxy(); // the proxied connection, not a physical connection
 | 
					                return con.getProxy(); // the proxied connection, not a physical connection
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try 
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    return method.invoke(st, args);
 | 
					                    return method.invoke(st, args);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                catch (InvocationTargetException e)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    throw e.getTargetException();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ import java.sql.*;
 | 
				
			|||||||
 * interface to the PooledConnection is through the CPDS.
 | 
					 * interface to the PooledConnection is through the CPDS.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @author Aaron Mulder (ammulder@chariotsolutions.com)
 | 
					 * @author Aaron Mulder (ammulder@chariotsolutions.com)
 | 
				
			||||||
 * @version $Revision: 1.4 $
 | 
					 * @version $Revision: 1.5 $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ConnectionPoolTest extends BaseDataSourceTest
 | 
					public class ConnectionPoolTest extends BaseDataSourceTest
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -359,6 +359,70 @@ public class ConnectionPoolTest extends BaseDataSourceTest
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Ensures that the Statement proxy generated by the Connection handle
 | 
				
			||||||
 | 
					     * throws the correct kind of exception.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void testStatementProxy() {
 | 
				
			||||||
 | 
					            Statement s = null;
 | 
				
			||||||
 | 
					            try 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    PooledConnection pc = getPooledConnection();
 | 
				
			||||||
 | 
					                    Connection con = pc.getConnection();
 | 
				
			||||||
 | 
					                    s = con.createStatement();
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					            catch (SQLException e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    fail(e.getMessage());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            try 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    s.executeQuery("SELECT * FROM THIS_TABLE_SHOULD_NOT_EXIST");
 | 
				
			||||||
 | 
					                    fail("An SQL exception was not thrown that should have been");
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					            catch (SQLException e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    ; // This is the expected and correct path
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    fail("bad exception; was expecting SQLException, not" +
 | 
				
			||||||
 | 
					                         e.getClass().getName());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Ensures that the Statement proxy generated by the Connection handle
 | 
				
			||||||
 | 
					     * throws the correct kind of exception.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void testStatementProxy() {
 | 
				
			||||||
 | 
					            Statement s = null;
 | 
				
			||||||
 | 
					            try 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    PooledConnection pc = getPooledConnection();
 | 
				
			||||||
 | 
					                    Connection con = pc.getConnection();
 | 
				
			||||||
 | 
					                    s = con.createStatement();
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					            catch (SQLException e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    fail(e.getMessage());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            try 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    s.executeQuery("SELECT * FROM THIS_TABLE_SHOULD_NOT_EXIST");
 | 
				
			||||||
 | 
					                    fail("An SQL exception was not thrown that should have been");
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					            catch (SQLException e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    ; // This is the expected and correct path
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e) 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                    fail("bad exception; was expecting SQLException, not" +
 | 
				
			||||||
 | 
					                         e.getClass().getName());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Ensures that a prepared statement generated by a proxied connection
 | 
					     * Ensures that a prepared statement generated by a proxied connection
 | 
				
			||||||
     * returns the proxied connection from getConnection() [not the physical
 | 
					     * returns the proxied connection from getConnection() [not the physical
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user