2012-06-04 16 views

回答

1
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)); 
2

您可以使用information_schema來獲取引擎類型,例如:

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

感謝使用它,並且它適合於我的代碼>未使用的TABLE_SCHEMA = DATABASE(),因爲我通過連接連接到我的數據庫。 –

+0

我用過這個: Statement stmt = connection.createStatement(); stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(「從information_schema.tables中選擇引擎,其中table_name ='」+ tableName +「';」); rs.next(); System.out.println(rs.getString(1)); –