在实现JDBC时如何显示存储引擎-MySQL CONNECTION查询?
使用SELECTENGINE显示存储引擎名称。让我们首先创建一个表-
create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int, -> CountryName varchar(20) -> );
这是使用JDBC获取存储引擎的Java代码-
示例
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class GetTheStorageEngine {
public static void main(String[] args) {
String hostURL = "jdbc:mysql://localhost:3306/web?useSSL=false";
Connection con = null;
Statement stmt = null;
try {
con = DriverManager.getConnection(hostURL, "root", "123456");
stmt = con.createStatement();
String yourTablename = "DemoTable";
ResultSet resultSet = stmt.executeQuery("select engine from information_schema.tables where table_name='" + yourTablename + "';");
resultSet.next();
System.out.println("The engine is=" + resultSet.getString(1));
}
catch (Exception e) {
e.printStackTrace();
}
}
}输出结果
这将产生以下输出-
The storage engine is=InnoDB
热门推荐
10 妹妹生日祝福语简短唯美
11 老师对学校祝福语简短
12 娃娃考试祝福语幽默简短
13 离校退群祝福语简短
14 医政科祝福语简短
15 早晨好正能量祝福语简短
16 早安祝福语大全简短励志
17 圣诞饭店祝福语大全简短
18 微信晚上祝福语简短