현재 SQL 서버에서 프로 시저를 호출하고 있습니다. 나는이 두 가지의 DTO를 사용하고"명세서가 결과 집합을 반환하지 않았습니다"Java에서 프로 시저를 호출하는 중
@Override
public String savePersonalData(PersonalDataDto personalDataDto) throws SQLException {
String output = "";
Connection conn = null;
Statement sta = null;
String errorClassAndMethod = getErrorContainingClassAndMethod();
try {
Gson gson = new GsonBuilder().create();
String json = gson.toJson(personalDataDto);
org.json.JSONObject jsonInput = new org.json.JSONObject(json);
conn = createConnection(jsonInput);
sta = conn.createStatement();
String SPsql = "EXEC SP_UpdateAdvisoryBoxPersonalData ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?";
PreparedStatement ps = conn.prepareStatement(SPsql);
// ps.setEscapeProcessing(true);
System.out.println(personalDataDto);
ps.setString(1, personalDataDto.getClientId());
ps.setString(2, personalDataDto.getDivisionId());
ps.setString(3, personalDataDto.getClientRoleId());
ps.setString(4, personalDataDto.getUserID());
ps.setString(5, personalDataDto.getUserLoginDetailId());
ps.setString(6, personalDataDto.getPersonalData().getAnv_Om_PlaatsGeboorte());
ps.setString(7, personalDataDto.getPersonalData().getNaw_Om_Postcode());
ps.setString(8, personalDataDto.getPersonalData().getNaw_Om_Voorletters());
ps.setString(9, personalDataDto.getPersonalData().getNaw_Om_Naam());
ps.setDate(10, personalDataDto.getPersonalData().getAnv_Dt_Geboorte());
ps.setString(11, personalDataDto.getPersonalData().getAnv_Om_Email());
ps.setString(12, personalDataDto.getPersonalData().getAnv_Om_TelefoonPrive());
ps.setString(13, personalDataDto.getPersonalData().getAnv_Om_TelefoonWerk());
ps.setString(14, personalDataDto.getPersonalData().getNaw_Om_Voornamen());
ps.setString(15, personalDataDto.getPersonalData().getNaw_om_iban());
ps.setString(16, personalDataDto.getPersonalData().getAnv_Om_LegitimatieAfgifte());
ps.setInt(17, personalDataDto.getPersonalData().getNaw_Id());
ps.setString(18, personalDataDto.getPersonalData().getNaw_Nr_Huis());
// ps.setInt(19, personalDataDto.getPersonalData().getNaw_Id());
ps.setString(19, personalDataDto.getPersonalData().getNaw_Om_Straat());
ps.setString(20, personalDataDto.getPersonalData().getAnv_Om_TelefoonMobiel());
ps.setString(21, personalDataDto.getPersonalData().getAnv_Cd_Nationaliteit());
ResultSet rs = ps.executeQuery();
/*boolean gotResults = ps.execute();
ResultSet rs = null;
if(!gotResults){
System.out.println("No results returned");
} else {
rs = ps.getResultSet();
System.out.println(rs.getMetaData());
}*/
} catch (Exception e) {
e.printStackTrace();
String errorMessageAndClassWithMethod = getErrorContainingClassAndMethod();
throw new SpringAppRuntimeException(errorMessageAndClassWithMethod + e.toString());
} finally {
if (sta != null) {
conn.close();
}
if (conn != null) {
conn.close();
}
}
return output;
}
:
여기 내 방법입니다.
public class PersonalDataDto {
private String nawId;
private String serverName;
private String userName;
private String password;
private String databaseName;
private String clientId;
private String divisionId;
private String clientRoleId;
private String userID;
private String userLoginDetailId;
private PersonalDataInfoDto personalData;
// getters and setters for all
}
다음 하나가 PersonalDataInfoDto이며 같은 것입니다 : PersonalDataDto 같은입니다
public class PersonalDataInfoDto {
private String anv_Om_TelefoonMobiel;
private int naw_Id;
private String anv_Om_TelefoonPrive;
private String anv_Om_LegitimatieAfgifte;
private int advisoryBoxContactRefID;
private String naw_Om_Straat;
private String naw_Om_Postcode;
private String anv_Om_Email;
private String naw_Nr_Huis;
private String naw_Om_Voorletters;
private String anv_Om_TelefoonWerk;
private String naw_Om_Voornamen;
private Date anv_Dt_Geboorte;
private String naw_om_iban;
private String anv_Om_PlaatsGeboorte;
private String naw_Om_Naam;
private String anv_Cd_Nationaliteit;
// getters and setters for all
}
오류입니다 : 내가 코드를 변경할 사항
com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
는/입력이를 얻을 수 절차에서 결과 세트? 메소드에서했던 것처럼 java를 통해 호출하는 동안 프로 시저에 무언가를 추가해야합니까?
PRINT를 주석 처리하고 출력하는 필드에 몇 가지 이름을 지정하십시오. res_set으로 '삽입 된 연락처'를 선택하십시오. – sepupic