Search in sources :

Example 1 with CaHasProfileType

use of org.xipki.ca.dbtool.jaxb.ca.CaHasProfileType in project xipki by xipki.

the class CaConfigurationDbExporter method exportCaHasProfile.

// method exportScep
private void exportCaHasProfile(CAConfigurationType caconf) throws DataAccessException {
    System.out.println("exporting table CA_HAS_PROFILE");
    CaHasProfiles caHasProfiles = new CaHasProfiles();
    final String sql = "SELECT CA_ID,PROFILE_ID FROM CA_HAS_PROFILE";
    Statement stmt = null;
    ResultSet rs = null;
    try {
        stmt = createStatement();
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            CaHasProfileType caHasProfile = new CaHasProfileType();
            caHasProfile.setCaId(rs.getInt("CA_ID"));
            caHasProfile.setProfileId(rs.getInt("PROFILE_ID"));
            caHasProfiles.getCaHasProfile().add(caHasProfile);
        }
    } catch (SQLException ex) {
        throw translate(sql, ex);
    } finally {
        releaseResources(stmt, rs);
    }
    caconf.setCaHasProfiles(caHasProfiles);
    System.out.println(" exported table CA_HAS_PROFILE");
}
Also used : CaHasProfileType(org.xipki.ca.dbtool.jaxb.ca.CaHasProfileType) SQLException(java.sql.SQLException) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) CaHasProfiles(org.xipki.ca.dbtool.jaxb.ca.CAConfigurationType.CaHasProfiles)

Example 2 with CaHasProfileType

use of org.xipki.ca.dbtool.jaxb.ca.CaHasProfileType in project xipki by xipki.

the class CaConfigurationDbImporter method importCaHasCertprofile.

// method importCaHasPublisher
private void importCaHasCertprofile(CaHasProfiles caHasCertprofiles) throws DataAccessException {
    System.out.println("importing table CA_HAS_PROFILE");
    final String sql = "INSERT INTO CA_HAS_PROFILE (CA_ID,PROFILE_ID) VALUES (?,?)";
    PreparedStatement ps = prepareStatement(sql);
    try {
        for (CaHasProfileType entry : caHasCertprofiles.getCaHasProfile()) {
            try {
                ps.setInt(1, entry.getCaId());
                ps.setInt(2, entry.getProfileId());
                ps.executeUpdate();
            } catch (SQLException ex) {
                System.err.println("could not import CA_HAS_PROFILE with CA_ID=" + entry.getCaId() + " and PROFILE_ID=" + entry.getProfileId());
                throw translate(sql, ex);
            }
        }
    } finally {
        releaseResources(ps, null);
    }
    System.out.println(" imported table CA_HAS_PROFILE");
}
Also used : CaHasProfileType(org.xipki.ca.dbtool.jaxb.ca.CaHasProfileType) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement)

Aggregations

SQLException (java.sql.SQLException)2 CaHasProfileType (org.xipki.ca.dbtool.jaxb.ca.CaHasProfileType)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 CaHasProfiles (org.xipki.ca.dbtool.jaxb.ca.CAConfigurationType.CaHasProfiles)1