Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display the storage engine while implementing JDBC - MySQL CONNECTION query?
Use SELECT ENGINE to display the storage engine name. Let us first create a table −
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)
Here is the Java code to get the storage engine using JDBC −
Example
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();
}
}
}
Output
This will produce the following output −
The storage engine is=InnoDB
Advertisements