-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSQLKeywords.java
50 lines (40 loc) · 1.31 KB
/
SQLKeywords.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.jayden.study.metadata;
import com.jayden.study.utils.JdbcUtils;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
* Get all SQL Keywords
*
* @author jayden-lee
*/
public class SQLKeywords {
private static final String url = "jdbc:mysql://localhost:3306/mysql";
private static final String user = "user";
private static final String password = "password";
private static Connection connection;
public static void main(String[] args) {
try {
connection = JdbcUtils.getConnection(url, user, password);
printSQLKeywords(JdbcUtils.getDatabaseMetaData(connection));
} catch (Exception e) {
e.printStackTrace();
} finally {
JdbcUtils.closeConnection(connection);
}
}
/**
* Print SQL Keywords
*
* @param databaseMetaData DatabaseMetaData
* @throws SQLException
*/
private static void printSQLKeywords(DatabaseMetaData databaseMetaData) throws SQLException {
String sqlKeywords = databaseMetaData.getSQLKeywords();
String[] arrSqlKeywords = sqlKeywords.split(",");
System.out.println("##SQL Keywords##\n");
for(String sqlKeyword : arrSqlKeywords) {
System.out.println(sqlKeyword);
}
}
}