package org.nhooo.example.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.DatabaseMetaData; import java.sql.SQLException; public class SystemFunction { private static final String URL = "jdbc:mysql://localhost/nhooo"; private static final String USERNAME = "root"; private static final String PASSWORD = ""; public static void main(String[] args) { try (Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD)) { DatabaseMetaData meta = connection.getMetaData(); // 获取数据库支持的系统功能 String[] functions = meta.getSystemFunctions().split(",\\s*"); for (String function : functions) { System.out.println("Function = " + function); } } catch (SQLException e) { e.printStackTrace(); } } }
这是MySQL数据库支持的系统功能。
Function = DATABASE Function = USER Function = SYSTEM_USER Function = SESSION_USER Function = PASSWORD Function = ENCRYPT Function = LAST_INSERT_ID Function = VERSION
Maven依赖
<!-- https://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.17</version> </dependency>