1 6 package org.logicalcobwebs.proxool; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import java.sql.Connection ; 12 import java.sql.DriverManager ; 13 import java.sql.SQLException ; 14 import java.sql.Statement ; 15 import java.util.Properties ; 16 17 25 public class ProxyConnectionTest extends AbstractProxoolTest { 26 27 private static final Log LOG = LogFactory.getLog(ProxyConnectionTest.class); 28 29 public ProxyConnectionTest(String alias) { 30 super(alias); 31 } 32 33 38 public void testCloseStatement() throws Exception { 39 40 String testName = "closeStatement"; 41 String alias = testName; 42 43 String url = TestHelper.buildProxoolUrl(alias, 44 TestConstants.HYPERSONIC_DRIVER, 45 TestConstants.HYPERSONIC_TEST_URL); 46 Properties info = new Properties (); 47 info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); 48 info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); 49 ProxoolFacade.registerConnectionPool(url, info); 50 51 Connection c = DriverManager.getConnection(url); 52 Statement s = c.createStatement(); 53 try { 54 s.execute("drop table foo"); 55 } catch (SQLException e) { 56 LOG.debug("Ignoring excepted exception", e); 58 } finally { 59 c.close(); 65 } 66 67 c = DriverManager.getConnection(url); 68 Statement s2 = c.createStatement(); 69 try { 70 s2.execute("drop table foo"); 71 } catch (SQLException e) { 72 LOG.debug("Excepted exception", e); 74 } finally { 75 if (s2 != null) { 76 s2.close(); 77 } 78 c.close(); 81 } 82 83 } 84 85 } 86 87 88 | Popular Tags |