@Test public void testListDataSourceDefs() throws Exception { List<SQLDataSourceDef> defList = JDBCUtils.listDatasourceDefs(); assertEquals(defList.size(), 0); }
public static List<SQLDataSourceDef> listDatasourceDefs() { List<SQLDataSourceDef> result = new ArrayList<>(); String[] namespaces = {"java:comp/env/jdbc/", "java:jboss/datasources/"}; for (String namespace : namespaces) { try { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(namespace); while (list.hasMoreElements()) { NameClassPair next = list.next(); String name = next.getName(); String jndiPath = namespace + name; SQLDataSourceDef dsDef = new SQLDataSourceDef(jndiPath, name); result.add(dsDef); } } catch (NamingException e) { log.warn("JNDI namespace {} error: {}", namespace, e.getMessage()); } } return result; }
JDBCUtils { public static List<SQLDataSourceDef> listDatasourceDefs() { List<SQLDataSourceDef> result = new ArrayList<>(); String[] namespaces = {"java:comp/env/jdbc/", "java:jboss/datasources/"}; for (String namespace : namespaces) { try { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(namespace); while (list.hasMoreElements()) { NameClassPair next = list.next(); String name = next.getName(); String jndiPath = namespace + name; SQLDataSourceDef dsDef = new SQLDataSourceDef(jndiPath, name); result.add(dsDef); } } catch (NamingException e) { log.warn("JNDI namespace {} error: {}", namespace, e.getMessage()); } } return result; } }
JDBCUtils { public static List<SQLDataSourceDef> listDatasourceDefs() { List<SQLDataSourceDef> result = new ArrayList<>(); String[] namespaces = {"java:comp/env/jdbc/", "java:jboss/datasources/"}; for (String namespace : namespaces) { try { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(namespace); while (list.hasMoreElements()) { NameClassPair next = list.next(); String name = next.getName(); String jndiPath = namespace + name; SQLDataSourceDef dsDef = new SQLDataSourceDef(jndiPath, name); result.add(dsDef); } } catch (NamingException e) { log.warn("JNDI namespace {} error: {}", namespace, e.getMessage()); } } return result; }  }
JDBCUtils { public static List<SQLDataSourceDef> listDatasourceDefs() { List<SQLDataSourceDef> result = new ArrayList<>(); String[] namespaces = {"java:comp/env/jdbc/", "java:jboss/datasources/"}; for (String namespace : namespaces) { try { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(namespace); while (list.hasMoreElements()) { NameClassPair next = list.next(); String name = next.getName(); String jndiPath = namespace + name; SQLDataSourceDef dsDef = new SQLDataSourceDef(jndiPath, name); result.add(dsDef); } } catch (NamingException e) { log.warn("JNDI namespace {} error: {}", namespace, e.getMessage()); } } return result; }  static List<SQLDataSourceDef> listDatasourceDefs(); static void execute(Connection connection, String sql); static T metadata(Connection connection, String sql, Function<ResultSetMetaData, T> callback); static ResultSetHandler executeQuery(Connection connection, String sql); static Dialect dialect(Connection connection); static Dialect dialect(String url, int majorVersion); static Dialect dialect(String dbName); static List<Column> getColumns(ResultSet resultSet, String[] exclude); static String fixCase(Connection connection, String id); static List<String> getWordsBetweenQuotes(String s); static String changeCaseExcludeQuotes(String s, boolean upper); static ColumnType calculateType(int sqlDataType); static String clobToString(Clob value); }
JDBCUtils { public static List<SQLDataSourceDef> listDatasourceDefs() { List<SQLDataSourceDef> result = new ArrayList<>(); String[] namespaces = {"java:comp/env/jdbc/", "java:jboss/datasources/"}; for (String namespace : namespaces) { try { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> list = ctx.list(namespace); while (list.hasMoreElements()) { NameClassPair next = list.next(); String name = next.getName(); String jndiPath = namespace + name; SQLDataSourceDef dsDef = new SQLDataSourceDef(jndiPath, name); result.add(dsDef); } } catch (NamingException e) { log.warn("JNDI namespace {} error: {}", namespace, e.getMessage()); } } return result; }  static List<SQLDataSourceDef> listDatasourceDefs(); static void execute(Connection connection, String sql); static T metadata(Connection connection, String sql, Function<ResultSetMetaData, T> callback); static ResultSetHandler executeQuery(Connection connection, String sql); static Dialect dialect(Connection connection); static Dialect dialect(String url, int majorVersion); static Dialect dialect(String dbName); static List<Column> getColumns(ResultSet resultSet, String[] exclude); static String fixCase(Connection connection, String id); static List<String> getWordsBetweenQuotes(String s); static String changeCaseExcludeQuotes(String s, boolean upper); static ColumnType calculateType(int sqlDataType); static String clobToString(Clob value); static final Dialect DEFAULT; static final Dialect H2; static final Dialect MYSQL; static final Dialect POSTGRES; static final Dialect ORACLE; static final Dialect ORACLE_LEGACY; static final Dialect SQLSERVER; static final Dialect DB2; static final Dialect SYBASE_ASE; static final Dialect MONETDB; static final String[] QUOTES; }