String query = "SELECT date_birth FROM teachers WHERE id_teacher = 2";
ConnectionDB connectionDB = new ConnectionDB();
Connection connection = connectionDB.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement(query);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
Optional<Date> date = Optional.ofNullable(resultSet.getDate("date_birth"));
}
} catch (SQLException e) {
e.printStackTrace();
}