List of usage examples for java.sql DatabaseMetaData getSystemFunctions
String getSystemFunctions() throws SQLException;
From source file:org.apache.zeppelin.mysql.SqlCompleter.java
public static Set<String> getSqlKeywordsCompletions(Connection connection) throws IOException, SQLException { // Add the default SQL completions String keywords = new BufferedReader( new InputStreamReader(SqlCompleter.class.getResourceAsStream("/ansi.sql.keywords"))).readLine(); DatabaseMetaData metaData = connection.getMetaData(); // Add the driver specific SQL completions String driverSpecificKeywords = "/" + metaData.getDriverName().replace(" ", "-").toLowerCase() + "-sql.keywords"; logger.info("JDBC DriverName:" + driverSpecificKeywords); if (SqlCompleter.class.getResource(driverSpecificKeywords) != null) { String driverKeywords = new BufferedReader( new InputStreamReader(SqlCompleter.class.getResourceAsStream(driverSpecificKeywords))) .readLine();/* w ww .j a v a2s . co m*/ keywords += "," + driverKeywords.toUpperCase(); } Set<String> completions = new TreeSet<>(); // Add the keywords from the current JDBC connection try { keywords += "," + metaData.getSQLKeywords(); } catch (Exception e) { logger.debug("fail to get SQL key words from database metadata: " + e, e); } try { keywords += "," + metaData.getStringFunctions(); } catch (Exception e) { logger.debug("fail to get string function names from database metadata: " + e, e); } try { keywords += "," + metaData.getNumericFunctions(); } catch (Exception e) { logger.debug("fail to get numeric function names from database metadata: " + e, e); } try { keywords += "," + metaData.getSystemFunctions(); } catch (Exception e) { logger.debug("fail to get system function names from database metadata: " + e, e); } try { keywords += "," + metaData.getTimeDateFunctions(); } catch (Exception e) { logger.debug("fail to get time date function names from database metadata: " + e, e); } // Also allow lower-case versions of all the keywords keywords += "," + keywords.toLowerCase(); StringTokenizer tok = new StringTokenizer(keywords, ", "); while (tok.hasMoreTokens()) { completions.add(tok.nextToken()); } return completions; }
From source file:org.apache.zeppelin.postgresql.SqlCompleter.java
public static Set<String> getSqlKeywordsCompletions(Connection connection) throws IOException, SQLException { // Add the default SQL completions String keywords = new BufferedReader( new InputStreamReader(SqlCompleter.class.getResourceAsStream("/ansi.sql.keywords"))).readLine(); DatabaseMetaData metaData = connection.getMetaData(); // Add the driver specific SQL completions String driverSpecificKeywords = "/" + metaData.getDriverName().replace(" ", "-").toLowerCase() + "-sql.keywords"; logger.info("JDBC DriverName:" + driverSpecificKeywords); if (SqlCompleter.class.getResource(driverSpecificKeywords) != null) { String driverKeywords = new BufferedReader( new InputStreamReader(SqlCompleter.class.getResourceAsStream(driverSpecificKeywords))) .readLine();/* ww w . j a v a2s . c om*/ keywords += "," + driverKeywords.toUpperCase(); } Set<String> completions = new TreeSet<String>(); // Add the keywords from the current JDBC connection try { keywords += "," + metaData.getSQLKeywords(); } catch (Exception e) { logger.debug("fail to get SQL key words from database metadata: " + e, e); } try { keywords += "," + metaData.getStringFunctions(); } catch (Exception e) { logger.debug("fail to get string function names from database metadata: " + e, e); } try { keywords += "," + metaData.getNumericFunctions(); } catch (Exception e) { logger.debug("fail to get numeric function names from database metadata: " + e, e); } try { keywords += "," + metaData.getSystemFunctions(); } catch (Exception e) { logger.debug("fail to get system function names from database metadata: " + e, e); } try { keywords += "," + metaData.getTimeDateFunctions(); } catch (Exception e) { logger.debug("fail to get time date function names from database metadata: " + e, e); } // Also allow lower-case versions of all the keywords keywords += "," + keywords.toLowerCase(); StringTokenizer tok = new StringTokenizer(keywords, ", "); while (tok.hasMoreTokens()) { completions.add(tok.nextToken()); } return completions; }
From source file:org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils.java
private List<String> getAllDBFuctions(DatabaseMetaData dbMetadata) { List<String> functionlist = new ArrayList<String>(); if (dbMetadata == null) { return functionlist; }//from w ww. ja v a2 s. c o m try { final String CommaSplit = ",\\s*"; //$NON-NLS-1$ String[] systemFunctions = null; if (dbMetadata.getSystemFunctions() != null) { systemFunctions = dbMetadata.getSystemFunctions().split(CommaSplit); } String[] numericFunctions = null; if (dbMetadata.getNumericFunctions() != null) { numericFunctions = dbMetadata.getNumericFunctions().split(CommaSplit); } String[] stringFunctions = null; if (dbMetadata.getStringFunctions() != null) { stringFunctions = dbMetadata.getStringFunctions().split(CommaSplit); } String[] timeFunctions = null; if (dbMetadata.getTimeDateFunctions() != null) { timeFunctions = dbMetadata.getTimeDateFunctions().split(CommaSplit); } convertFunctions2Array(functionlist, systemFunctions); convertFunctions2Array(functionlist, numericFunctions); convertFunctions2Array(functionlist, stringFunctions); convertFunctions2Array(functionlist, timeFunctions); } catch (SQLException e) { ExceptionHandler.process(e); } return functionlist; }