mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-26 17:35:49 +00:00
⚗️ add types
This commit is contained in:
parent
00b0bb10bd
commit
44ce24ee0c
1 changed files with 7 additions and 3 deletions
|
@ -4,7 +4,11 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -40,10 +44,10 @@ class RecordsTransferController {
|
||||||
* @throws IllegalArgumentException when the patient does not exist
|
* @throws IllegalArgumentException when the patient does not exist
|
||||||
*/
|
*/
|
||||||
private void validatePatientId(final String patientId) throws SQLException {
|
private void validatePatientId(final String patientId) throws SQLException {
|
||||||
final var connection = dataSource.getConnection();
|
final Connection connection = dataSource.getConnection();
|
||||||
final var statement = connection.prepareStatement("SELECT * FROM patients WHERE id = ?");
|
final PreparedStatement statement = connection.prepareStatement("SELECT * FROM patients WHERE id = ?");
|
||||||
statement.setString(1, patientId);
|
statement.setString(1, patientId);
|
||||||
final var rs = statement.executeQuery();
|
final ResultSet rs = statement.executeQuery();
|
||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
throw new IllegalArgumentException("Patient with id " + patientId + " does not exist");
|
throw new IllegalArgumentException("Patient with id " + patientId + " does not exist");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue