// TODO public int insertCert(ApkBean apk) { int ret = -1; for (CertBean cert : apk.certs) { try { PreparedStatement pstmt = null; String marketUpdateQuery = "INSERT INTO cert " + "(issuer,certhash,certBrief)" + " VALUES(?, ?,?) "; pstmt = (PreparedStatement) conn.prepareStatement(marketUpdateQuery); pstmt.setString( 1, ((X509Certificate) cert.certificate).getIssuerX500Principal().toString()); pstmt.setString(2, cert.certificateHash); pstmt.setString(3, apk.certInfo()); pstmt.executeUpdate(); ret = 0; } catch (SQLException e) { if (e.getErrorCode() == 1062) { return 0; } e.printStackTrace(); ret = -2; } } return ret; }
public ApkBean[] getDiffApks() { ArrayList<ApkBean> diffApk = new ArrayList<ApkBean>(); String[] marketNames = getMarketNames(); for (String marketName : marketNames) { String query = String.format(DIFF_APK_QUERY, marketName, marketName); PreparedStatement pstmt; try { pstmt = (PreparedStatement) conn.prepareStatement(query); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { ApkBean apk = new ApkBean(); apk.packageName = String.valueOf(rs.getString("package_name")); apk.marketBean.marketName = "Gfan"; diffApk.add(apk); } } catch (SQLException e) { e.printStackTrace(); } } return diffApk.toArray(new ApkBean[diffApk.size()]); }