Oubenal Mohcine
Oubenal Mohcine

Reputation: 491

how to get the storage engine using jdbc

Is there a way to get the storage engine of a MySql table using JDBC. I already use metadata to get other table information like columns names, types, primary key , indexes ... but didn't find how o get the engine

Upvotes: 2

Views: 492

Answers (2)

Oubenal Mohcine
Oubenal Mohcine

Reputation: 491

Statement stmt = connection.createStatement(); 
stmt = connection.createStatement(); 
ResultSet rs = stmt.executeQuery("select engine from information_schema.tables where table_name='" + tableName + "';");
rs.next(); 
System.out.println(rs.getString(1));

Upvotes: 1

nosid
nosid

Reputation: 50054

You can use the information_schema to get the engine type, e.g.:

SELECT ENGINE
FROM information_schema.tables
WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='foobar';

Upvotes: 2

Related Questions