What Are a Database's SQL Keywords? in JDBC

In GUI database applications, if you are forming a SQL query at runtime, then you might need the database’s SQL keywords. DatabaseMetaData provides the getSQLKeywords() method for getting the database’s SQL keywords. This method retrieves a comma-separated list of all of the database’s SQL keywords but excludes SQL-92 keywords. The return type of this method is not very useful, because once the client receives the result as a String, it has to be tokenized to find the actual keywords. Our solution returns this as a java.util.List, where each element will be a keyword. You can try the following two solutions for this problem. The first solution returns the list of SQL keywords as a java.util.List object, where each element is a SQL keyword(as a String object). The second solution returns the result as XML.

Solution 1: Returns the SQL Keywords as a List

MySQL Client Code Using getSQLKeywords()

This code is the same for the Oracle client:

Output:MySQL Database

Output:Oracle Database

Solution 2: Returns the SQL Keywords as XML

Client Code:MySQL Database

This code is the same for the Oracle client:

Output:MySQL Database

Output:Oracle Database



All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JDBC Topics