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");
}
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");
}
Aggregations