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;
 
   54             StringBuilder connectionURL = 
new StringBuilder();
 
   55             connectionURL.append(JDBC_BASE_URI);
 
   56             connectionURL.append(filename);
 
   57             Class.forName(JDBC_DRIVER);
 
   58             conn = DriverManager.getConnection(connectionURL.toString());
 
   61             statement = conn.createStatement();
 
   62             resultSet = statement.executeQuery(
"SELECT count(*) AS count FROM hashes");
 
   63             if (resultSet.next()) {
 
   64                 totalHashes = resultSet.getLong(
"count");
 
   67                 throw new TskCoreException(
"Error getting hash count from hash set " + filename);
 
   71             resultSet = statement.executeQuery(
"SELECT md5 FROM hashes");
 
   74         } 
catch (ClassNotFoundException | SQLException ex) {
 
   75             throw new TskCoreException(
"Error opening/reading hash set " + filename, ex);
 
   90             if (resultSet.next()) {
 
   91                 byte[] hashBytes = resultSet.getBytes(
"md5");
 
   92                 StringBuilder sb = 
new StringBuilder();
 
   93                 for (byte b : hashBytes) {
 
   94                     sb.append(String.format(
"%02x", b));
 
   97                 if (sb.toString().length() != 32) {
 
   98                     throw new TskCoreException(
"Hash has incorrect length: " + sb.toString());
 
  102                 return sb.toString();
 
  104                 throw new TskCoreException(
"Could not read expected number of hashes from hash set " + filename);
 
  106         } 
catch (SQLException ex) {
 
  107             throw new TskCoreException(
"Error reading hash from result set for hash set " + filename, ex);
 
  118         return (totalHashesRead >= totalHashes);
 
  136         if (statement != null) {
 
  139             } 
catch (SQLException ex) {
 
  144         if (resultSet != null) {
 
  147             } 
catch (SQLException ex) {
 
  155             } 
catch (SQLException ex) {
 
final String JDBC_BASE_URI
long getExpectedHashCount()
synchronized static Logger getLogger(String name)