My MYSQL-Table has got 3 tables.
I can't get the given examples working.
In Java, using java.sql.*
, I would like to know how much space is left in my entire database, for the space is very limited.
Here is my approach:
// this.conn = DriverManager.getConnection("jdbc:mysql://......");
public long remainingSpace() {
String sql = "SELECT table_schema AS \"Database\", "
+ "ROUND(SUM(data_length + index_length) / 1024, 2) AS \"Size (KB)\" "
+ "FROM information_schema.TABLES GROUP BY table_schema;";
ResultSet rs;
PreparedStatement prpSttm = this.conn.prepareStatement(sql);
rs = prpSttm.executeQuery();
rs.next();
long remainingSpace = rs.getInt("Size (KB)");
return remainingSpace;
}
This returns 9
(KB).
phpMyAdmin instead tells me there is 64 KiB
of data in one of my tables:
How can I get the correct size in Java?