@Test public void testParseConnectionInfo() throws SQLException { Connection conn = createSystemThinDriverConnection(); OracleDriverConnectionInfo info = OracleSpecifics.parseConnectionInfo(conn, TestHelpers.createDummyMessages()); AssertJUnit.assertNotNull(info); String user = TEST_PROPS.getStringProperty("thin.user"); String passwordString = TEST_PROPS.getStringProperty("thin.password"); OracleDriverConnectionInfo newInfo = new OracleDriverConnectionInfo.Builder().setvalues(info).setUser(user).setPassword( new GuardedString(passwordString.toCharArray())).build(); Connection conn1 = OracleSpecifics.createThinDriverConnection(newInfo, TestHelpers .createDummyMessages()); Assert.assertNotNull(conn1); conn1.close(); conn.close(); }
static OracleDriverConnectionInfo parseConnectionInfo(Connection conn, ConnectorMessages connectorMessages) { OracleDriverConnectionInfo.Builder builder = new OracleDriverConnectionInfo.Builder(); try { DatabaseMetaData metaData = conn.getMetaData(); String url = metaData.getURL(); String user = metaData.getUserName(); builder.setUrl(url); builder.setUser(user); Class<?> oraClazz = null; final String oracleConnectionClassName = "oracle.jdbc.OracleConnection"; try { oraClazz = Class.forName(oracleConnectionClassName); } catch (ClassNotFoundException e) { } if (oraClazz != null && oraClazz.isInstance(conn)) { builder.setDriver(THIN_AND_OCI_DRIVER_CLASSNAME); } if (builder.getDriver() == null) { List<Driver> drivers = Collections.list(DriverManager.getDrivers()); for (Driver driver : drivers) { if (driver.acceptsURL(url)) { if (builder.getDriver() != null) { throw new ConnectorException( MessageFormat .format("We cannot determine driver from connection. These two drivers [{0}] accept connection url [{1}]", Arrays.asList(builder.getDriver(), driver .getClass().getName()), url)); } builder.setDriver(driver.getClass().getName()); } } } if (builder.getDriver() == null) { throw new ConnectorException( MessageFormat .format("Cannot determine driver classname from connection. No driver accepts url [{0}]", url)); } return builder.build(); } catch (SQLException e) { throw new ConnectorException(connectorMessages.format(MSG_ORACLE_PCI_CANNOT_GET_INFO, null), e); } }
OracleSpecifics { static OracleDriverConnectionInfo parseConnectionInfo(Connection conn, ConnectorMessages connectorMessages) { OracleDriverConnectionInfo.Builder builder = new OracleDriverConnectionInfo.Builder(); try { DatabaseMetaData metaData = conn.getMetaData(); String url = metaData.getURL(); String user = metaData.getUserName(); builder.setUrl(url); builder.setUser(user); Class<?> oraClazz = null; final String oracleConnectionClassName = "oracle.jdbc.OracleConnection"; try { oraClazz = Class.forName(oracleConnectionClassName); } catch (ClassNotFoundException e) { } if (oraClazz != null && oraClazz.isInstance(conn)) { builder.setDriver(THIN_AND_OCI_DRIVER_CLASSNAME); } if (builder.getDriver() == null) { List<Driver> drivers = Collections.list(DriverManager.getDrivers()); for (Driver driver : drivers) { if (driver.acceptsURL(url)) { if (builder.getDriver() != null) { throw new ConnectorException( MessageFormat .format("We cannot determine driver from connection. These two drivers [{0}] accept connection url [{1}]", Arrays.asList(builder.getDriver(), driver .getClass().getName()), url)); } builder.setDriver(driver.getClass().getName()); } } } if (builder.getDriver() == null) { throw new ConnectorException( MessageFormat .format("Cannot determine driver classname from connection. No driver accepts url [{0}]", url)); } return builder.build(); } catch (SQLException e) { throw new ConnectorException(connectorMessages.format(MSG_ORACLE_PCI_CANNOT_GET_INFO, null), e); } } }
OracleSpecifics { static OracleDriverConnectionInfo parseConnectionInfo(Connection conn, ConnectorMessages connectorMessages) { OracleDriverConnectionInfo.Builder builder = new OracleDriverConnectionInfo.Builder(); try { DatabaseMetaData metaData = conn.getMetaData(); String url = metaData.getURL(); String user = metaData.getUserName(); builder.setUrl(url); builder.setUser(user); Class<?> oraClazz = null; final String oracleConnectionClassName = "oracle.jdbc.OracleConnection"; try { oraClazz = Class.forName(oracleConnectionClassName); } catch (ClassNotFoundException e) { } if (oraClazz != null && oraClazz.isInstance(conn)) { builder.setDriver(THIN_AND_OCI_DRIVER_CLASSNAME); } if (builder.getDriver() == null) { List<Driver> drivers = Collections.list(DriverManager.getDrivers()); for (Driver driver : drivers) { if (driver.acceptsURL(url)) { if (builder.getDriver() != null) { throw new ConnectorException( MessageFormat .format("We cannot determine driver from connection. These two drivers [{0}] accept connection url [{1}]", Arrays.asList(builder.getDriver(), driver .getClass().getName()), url)); } builder.setDriver(driver.getClass().getName()); } } } if (builder.getDriver() == null) { throw new ConnectorException( MessageFormat .format("Cannot determine driver classname from connection. No driver accepts url [{0}]", url)); } return builder.build(); } catch (SQLException e) { throw new ConnectorException(connectorMessages.format(MSG_ORACLE_PCI_CANNOT_GET_INFO, null), e); } } private  OracleSpecifics(); }
OracleSpecifics { static OracleDriverConnectionInfo parseConnectionInfo(Connection conn, ConnectorMessages connectorMessages) { OracleDriverConnectionInfo.Builder builder = new OracleDriverConnectionInfo.Builder(); try { DatabaseMetaData metaData = conn.getMetaData(); String url = metaData.getURL(); String user = metaData.getUserName(); builder.setUrl(url); builder.setUser(user); Class<?> oraClazz = null; final String oracleConnectionClassName = "oracle.jdbc.OracleConnection"; try { oraClazz = Class.forName(oracleConnectionClassName); } catch (ClassNotFoundException e) { } if (oraClazz != null && oraClazz.isInstance(conn)) { builder.setDriver(THIN_AND_OCI_DRIVER_CLASSNAME); } if (builder.getDriver() == null) { List<Driver> drivers = Collections.list(DriverManager.getDrivers()); for (Driver driver : drivers) { if (driver.acceptsURL(url)) { if (builder.getDriver() != null) { throw new ConnectorException( MessageFormat .format("We cannot determine driver from connection. These two drivers [{0}] accept connection url [{1}]", Arrays.asList(builder.getDriver(), driver .getClass().getName()), url)); } builder.setDriver(driver.getClass().getName()); } } } if (builder.getDriver() == null) { throw new ConnectorException( MessageFormat .format("Cannot determine driver classname from connection. No driver accepts url [{0}]", url)); } return builder.build(); } catch (SQLException e) { throw new ConnectorException(connectorMessages.format(MSG_ORACLE_PCI_CANNOT_GET_INFO, null), e); } } private  OracleSpecifics();  }
OracleSpecifics { static OracleDriverConnectionInfo parseConnectionInfo(Connection conn, ConnectorMessages connectorMessages) { OracleDriverConnectionInfo.Builder builder = new OracleDriverConnectionInfo.Builder(); try { DatabaseMetaData metaData = conn.getMetaData(); String url = metaData.getURL(); String user = metaData.getUserName(); builder.setUrl(url); builder.setUser(user); Class<?> oraClazz = null; final String oracleConnectionClassName = "oracle.jdbc.OracleConnection"; try { oraClazz = Class.forName(oracleConnectionClassName); } catch (ClassNotFoundException e) { } if (oraClazz != null && oraClazz.isInstance(conn)) { builder.setDriver(THIN_AND_OCI_DRIVER_CLASSNAME); } if (builder.getDriver() == null) { List<Driver> drivers = Collections.list(DriverManager.getDrivers()); for (Driver driver : drivers) { if (driver.acceptsURL(url)) { if (builder.getDriver() != null) { throw new ConnectorException( MessageFormat .format("We cannot determine driver from connection. These two drivers [{0}] accept connection url [{1}]", Arrays.asList(builder.getDriver(), driver .getClass().getName()), url)); } builder.setDriver(driver.getClass().getName()); } } } if (builder.getDriver() == null) { throw new ConnectorException( MessageFormat .format("Cannot determine driver classname from connection. No driver accepts url [{0}]", url)); } return builder.build(); } catch (SQLException e) { throw new ConnectorException(connectorMessages.format(MSG_ORACLE_PCI_CANNOT_GET_INFO, null), e); } } private  OracleSpecifics();   }