@Test public void testUserExist() throws SQLException { String user = "testUser"; boolean userExist = userReader.userExist(user); final String formatUserName = cfg.getCSSetup().formatToken(USER, user); if (userExist) { SQLUtil.executeUpdateStatement(conn, "drop user " + formatUserName + " cascade"); assertFalse("User should not exist after delete", userReader.userExist(user)); } else { SQLUtil.executeUpdateStatement(conn, "create user " + formatUserName + " identified by password"); assertTrue("User should exist after create", userReader.userExist(user)); SQLUtil.executeUpdateStatement(conn, "drop user " + formatUserName + " cascade"); assertFalse("User should not exist after delete", userReader.userExist(user)); } }
boolean userExist(String user) { String query = "select 1 from DBA_USERS where USERNAME = ?"; PreparedStatement st = null; ResultSet rs = null; try { st = adminConn.prepareStatement(query); st.setString(1, user); rs = st.executeQuery(); return rs.next(); } catch (SQLException e) { throw new ConnectorException(cm.format(MSG_ERROR_TEST_USER_EXISTENCE, null), e); } finally { SQLUtil.closeQuietly(rs); SQLUtil.closeQuietly(st); } }
OracleUserReader { boolean userExist(String user) { String query = "select 1 from DBA_USERS where USERNAME = ?"; PreparedStatement st = null; ResultSet rs = null; try { st = adminConn.prepareStatement(query); st.setString(1, user); rs = st.executeQuery(); return rs.next(); } catch (SQLException e) { throw new ConnectorException(cm.format(MSG_ERROR_TEST_USER_EXISTENCE, null), e); } finally { SQLUtil.closeQuietly(rs); SQLUtil.closeQuietly(st); } } }
OracleUserReader { boolean userExist(String user) { String query = "select 1 from DBA_USERS where USERNAME = ?"; PreparedStatement st = null; ResultSet rs = null; try { st = adminConn.prepareStatement(query); st.setString(1, user); rs = st.executeQuery(); return rs.next(); } catch (SQLException e) { throw new ConnectorException(cm.format(MSG_ERROR_TEST_USER_EXISTENCE, null), e); } finally { SQLUtil.closeQuietly(rs); SQLUtil.closeQuietly(st); } } OracleUserReader(Connection adminConn, ConnectorMessages cm); }
OracleUserReader { boolean userExist(String user) { String query = "select 1 from DBA_USERS where USERNAME = ?"; PreparedStatement st = null; ResultSet rs = null; try { st = adminConn.prepareStatement(query); st.setString(1, user); rs = st.executeQuery(); return rs.next(); } catch (SQLException e) { throw new ConnectorException(cm.format(MSG_ERROR_TEST_USER_EXISTENCE, null), e); } finally { SQLUtil.closeQuietly(rs); SQLUtil.closeQuietly(st); } } OracleUserReader(Connection adminConn, ConnectorMessages cm);  }
OracleUserReader { boolean userExist(String user) { String query = "select 1 from DBA_USERS where USERNAME = ?"; PreparedStatement st = null; ResultSet rs = null; try { st = adminConn.prepareStatement(query); st.setString(1, user); rs = st.executeQuery(); return rs.next(); } catch (SQLException e) { throw new ConnectorException(cm.format(MSG_ERROR_TEST_USER_EXISTENCE, null), e); } finally { SQLUtil.closeQuietly(rs); SQLUtil.closeQuietly(st); } } OracleUserReader(Connection adminConn, ConnectorMessages cm);   }