Changeset 69 for trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Timestamp:
- 05/03/16 15:17:36 (9 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/IResultStorage.java
r68 r69 4 4 5 5 public void addResult(ExperimentResult result); 6 7 public boolean containsResult(String experimentName, String productName); 6 8 } -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/MySQLResultStorage.java
r68 r69 4 4 import java.sql.Connection; 5 5 import java.sql.DriverManager; 6 import java.sql.ResultSet; 6 7 import java.sql.SQLException; 7 8 import java.sql.Statement; … … 34 35 35 36 public void addResult(ExperimentResult result) { 36 Statement stmt;37 try {38 stmt = con.createStatement();39 }40 catch (SQLException e) {41 Console.printerr("Problem with MySQL connection: ");42 Console.printerr("SQLException: " + e.getMessage());43 Console.printerr("SQLState: " + e.getSQLState());44 Console.printerr("VendorError: " + e.getErrorCode());45 return;46 }47 37 StringBuilder sql = new StringBuilder(); 48 38 sql.append("INSERT INTO crosspare.results VALUES (NULL,"); … … 72 62 sql.append(result.getTn()+","); 73 63 sql.append(result.getFp()+");"); 64 65 Statement stmt; 74 66 try { 67 stmt = con.createStatement(); 75 68 stmt.executeUpdate(sql.toString().replace("NaN", "NULL")); 76 69 } … … 84 77 } 85 78 86 //public boolean containsResult(String configurationName, String productName, String classifier); 79 @Override 80 public boolean containsResult(String experimentName, String productName) { 81 String sql = "SELECT COUNT(*) as cnt FROM crosspare.results WHERE configurationName=\'" + experimentName + "\' AND productName=\'" + productName + "\';"; 82 Statement stmt; 83 boolean contained = false; 84 try { 85 stmt = con.createStatement(); 86 ResultSet results = stmt.executeQuery(sql); 87 results.next(); 88 int count = results.getInt("cnt"); 89 contained = count>0; 90 } 91 catch (SQLException e) { 92 Console.printerr("Problem with MySQL connection: \n"); 93 Console.printerr("SQLException: " + e.getMessage() + "\n"); 94 Console.printerr("SQLState: " + e.getSQLState() + "\n"); 95 Console.printerr("VendorError: " + e.getErrorCode() + "\n"); 96 } 97 return contained; 98 } 87 99 }
Note: See TracChangeset
for help on using the changeset viewer.