19 package org.sleuthkit.autopsy.modules.hashdatabase;
 
   21 import java.sql.Connection;
 
   22 import java.sql.DriverManager;
 
   23 import java.sql.ResultSet;
 
   24 import java.sql.SQLException;
 
   25 import java.sql.Statement;
 
   26 import java.util.logging.Level;
 
   55             StringBuilder connectionURL = 
new StringBuilder();
 
   56             connectionURL.append(JDBC_BASE_URI);
 
   57             connectionURL.append(filename);
 
   58             Class.forName(JDBC_DRIVER);
 
   59             conn = DriverManager.getConnection(connectionURL.toString());
 
   62             statement = conn.createStatement();
 
   63             resultSet = statement.executeQuery(
"SELECT count(*) AS count FROM hashes");
 
   64             if (resultSet.next()) {
 
   65                 totalHashes = resultSet.getLong(
"count");
 
   68                 throw new TskCoreException(
"Error getting hash count from hash set " + filename);
 
   72             resultSet = statement.executeQuery(
"SELECT h.md5 as md5, " + 
 
   73                 " (SELECT group_concat(c.comment, ' ') FROM comments c WHERE h.id = c.hash_id) as comment " + 
 
   77         } 
catch (ClassNotFoundException | SQLException ex) {
 
   78             throw new TskCoreException(
"Error opening/reading hash set " + filename, ex);
 
   99             if (resultSet.next()) {
 
  100                 byte[] hashBytes = resultSet.getBytes(
"md5");
 
  101                 StringBuilder sb = 
new StringBuilder();
 
  102                 for (byte b : hashBytes) {
 
  103                     sb.append(String.format(
"%02x", b));
 
  106                 if (sb.toString().length() != 32) {
 
  107                     throw new TskCoreException(
"Hash has incorrect length: " + sb.toString());
 
  110                 String md5Hash = sb.toString();
 
  111                 String comment = resultSet.getString(
"comment");
 
  113                 return new HashEntry(null, md5Hash, null, null, comment);
 
  115                 throw new TskCoreException(
"Could not read expected number of hashes from hash set " + filename);
 
  117         } 
catch (SQLException ex) {
 
  118             throw new TskCoreException(
"Error opening/reading hash set " + filename, ex);
 
  129         return (totalHashesRead >= totalHashes);
 
  147         if (statement != null) {
 
  150             } 
catch (SQLException ex) {
 
  155         if (resultSet != null) {
 
  158             } 
catch (SQLException ex) {
 
  166             } 
catch (SQLException ex) {
 
final String JDBC_BASE_URI
long getExpectedHashCount()
synchronized static Logger getLogger(String name)
HashEntry getNextHashEntry()