Commit 44dfee4e by Patryk Czarnik

Poprawka w CustomerDAO

parent 1f54b347
...@@ -54,7 +54,7 @@ public class CustomerDAO { ...@@ -54,7 +54,7 @@ public class CustomerDAO {
private Customer customerFromRS(ResultSet rs) throws SQLException { private Customer customerFromRS(ResultSet rs) throws SQLException {
return new Customer( return new Customer(
rs.getString("customer_email"), rs.getString("customer_email"),
rs.getString("customer_name"), rs.getString("name"),
rs.getString("phone_number"), rs.getString("phone_number"),
rs.getString("address"), rs.getString("address"),
rs.getString("postal_code"), rs.getString("postal_code"),
...@@ -64,7 +64,7 @@ public class CustomerDAO { ...@@ -64,7 +64,7 @@ public class CustomerDAO {
public void insert(Customer customer) throws DBException { public void insert(Customer customer) throws DBException {
// używać gdy obiekt ma wpisane ID (tu: email) // używać gdy obiekt ma wpisane ID (tu: email)
final String sql = "INSERT INTO customers(" final String sql = "INSERT INTO customers("
+ "customer_email, customer_name, phone_number, address, postal_code, city)" + "customer_email, name, phone_number, address, postal_code, city)"
+ " VALUES (?, ?, ?, ?, ?, ?)"; + " VALUES (?, ?, ?, ?, ?, ?)";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getEmail()); stmt.setString(1, customer.getEmail());
...@@ -81,7 +81,7 @@ public class CustomerDAO { ...@@ -81,7 +81,7 @@ public class CustomerDAO {
public boolean update(Customer customer) throws DBException { public boolean update(Customer customer) throws DBException {
final String sql = "UPDATE customers SET " final String sql = "UPDATE customers SET "
+ " customer_name=?, phone_number=?, address=?, postal_code=?, city=?" + " name=?, phone_number=?, address=?, postal_code=?, city=?"
+ " WHERE customer_email = ?"; + " WHERE customer_email = ?";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getName()); stmt.setString(1, customer.getName());
......
...@@ -54,7 +54,7 @@ public class CustomerDAO { ...@@ -54,7 +54,7 @@ public class CustomerDAO {
private Customer customerFromRS(ResultSet rs) throws SQLException { private Customer customerFromRS(ResultSet rs) throws SQLException {
return new Customer( return new Customer(
rs.getString("customer_email"), rs.getString("customer_email"),
rs.getString("customer_name"), rs.getString("name"),
rs.getString("phone_number"), rs.getString("phone_number"),
rs.getString("address"), rs.getString("address"),
rs.getString("postal_code"), rs.getString("postal_code"),
...@@ -64,7 +64,7 @@ public class CustomerDAO { ...@@ -64,7 +64,7 @@ public class CustomerDAO {
public void insert(Customer customer) throws DBException { public void insert(Customer customer) throws DBException {
// używać gdy obiekt ma wpisane ID (tu: email) // używać gdy obiekt ma wpisane ID (tu: email)
final String sql = "INSERT INTO customers(" final String sql = "INSERT INTO customers("
+ "customer_email, customer_name, phone_number, address, postal_code, city)" + "customer_email, name, phone_number, address, postal_code, city)"
+ " VALUES (?, ?, ?, ?, ?, ?)"; + " VALUES (?, ?, ?, ?, ?, ?)";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getEmail()); stmt.setString(1, customer.getEmail());
...@@ -81,7 +81,7 @@ public class CustomerDAO { ...@@ -81,7 +81,7 @@ public class CustomerDAO {
public boolean update(Customer customer) throws DBException { public boolean update(Customer customer) throws DBException {
final String sql = "UPDATE customers SET " final String sql = "UPDATE customers SET "
+ " customer_name=?, phone_number=?, address=?, postal_code=?, city=?" + " name=?, phone_number=?, address=?, postal_code=?, city=?"
+ " WHERE customer_email = ?"; + " WHERE customer_email = ?";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getName()); stmt.setString(1, customer.getName());
......
...@@ -54,7 +54,7 @@ public class CustomerDAO { ...@@ -54,7 +54,7 @@ public class CustomerDAO {
private Customer customerFromRS(ResultSet rs) throws SQLException { private Customer customerFromRS(ResultSet rs) throws SQLException {
return new Customer( return new Customer(
rs.getString("customer_email"), rs.getString("customer_email"),
rs.getString("customer_name"), rs.getString("name"),
rs.getString("phone_number"), rs.getString("phone_number"),
rs.getString("address"), rs.getString("address"),
rs.getString("postal_code"), rs.getString("postal_code"),
...@@ -64,7 +64,7 @@ public class CustomerDAO { ...@@ -64,7 +64,7 @@ public class CustomerDAO {
public void insert(Customer customer) throws DBException { public void insert(Customer customer) throws DBException {
// używać gdy obiekt ma wpisane ID (tu: email) // używać gdy obiekt ma wpisane ID (tu: email)
final String sql = "INSERT INTO customers(" final String sql = "INSERT INTO customers("
+ "customer_email, customer_name, phone_number, address, postal_code, city)" + "customer_email, name, phone_number, address, postal_code, city)"
+ " VALUES (?, ?, ?, ?, ?, ?)"; + " VALUES (?, ?, ?, ?, ?, ?)";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getEmail()); stmt.setString(1, customer.getEmail());
...@@ -81,7 +81,7 @@ public class CustomerDAO { ...@@ -81,7 +81,7 @@ public class CustomerDAO {
public boolean update(Customer customer) throws DBException { public boolean update(Customer customer) throws DBException {
final String sql = "UPDATE customers SET " final String sql = "UPDATE customers SET "
+ " customer_name=?, phone_number=?, address=?, postal_code=?, city=?" + " name=?, phone_number=?, address=?, postal_code=?, city=?"
+ " WHERE customer_email = ?"; + " WHERE customer_email = ?";
try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) { try(PreparedStatement stmt = db.getSqlConnection().prepareStatement(sql)) {
stmt.setString(1, customer.getName()); stmt.setString(1, customer.getName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment