Skip to content

Commit

Permalink
java pizza project #2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
biblelamp committed Jul 1, 2024
1 parent 51c4b8c commit 9891b92
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pizza.repository.db;

import pizza.domain.Customer;
import pizza.domain.ExtComponent;
import pizza.repository.CrudRepository;

Expand Down Expand Up @@ -70,7 +71,19 @@ public ExtComponent save(ExtComponent component) {

@Override
public ExtComponent findById(Integer id) {
return null;
ExtComponent component = null;
try (Connection connection = DriverManager.getConnection(dbName);
PreparedStatement ps = connection.prepareStatement(SQL_FIND_BY_ID)) {
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
component = new ExtComponent(rs.getString("name"), rs.getInt("price"));
component.setId(rs.getInt("id"));
}
return component;
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

@Override
Expand Down

0 comments on commit 9891b92

Please sign in to comment.