SELECT ENGINE을 사용하여 스토리지 엔진 이름을 표시합니다. 먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int, -> CountryName varchar(20) -> ); Query OK, 0 rows affected (0.63 sec)
다음은 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