Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) implementation of size() for mysql

theli7646849241d2
diff --git a/source/dbtest.java b/source/dbtest.java
index 7a0db4a2d..4fa6bc065 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -417,7 +417,27 @@ final class dbTable implements kelondroIndex {
}
public int size() {
- return 0; // *** SQL IMPLEMENTATION NEEDED ***
+ int size = -1;
+ try {
+ String sqlQuery = new String
+ (
+ "SELECT count(value) from test"
+ );
+
+ PreparedStatement sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);
+ ResultSet result = sqlStatement.executeQuery();
+
+ while (result.next()) {
+ size = result.getInt(1);
+ }
+
+ result.close();
+ sqlStatement.close();
+
+ return size;
+ } catch (Exception e) {
+ return -1;
+ }
}
public kelondroRow row() {