2012-06-04 17 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)); –