// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
//     public SimpleAffableQueryDbException(String message) {
//         super(message);
//     }
// 
//     public SimpleAffableQueryDbException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
//     public SimpleAffableUpdateDbException(String message) {
//         super(message);
//     }
// 
//     public SimpleAffableUpdateDbException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }
// 
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection()  {
//     if (dataSource == null) {
//         dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
//     }
// 
//     try {
//         return dataSource.getConnection();
//     } catch (SQLException e) {
//         throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
//     }
// 
// }


import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
        "FROM " +
            "customer_order co";

    private static final String FIND_BY_CUSTOMER_ID_SQL =
        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
        "FROM " +
            "customer_order co " +
        "WHERE " +
            "co.customer_id = ?";

    private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
            "FROM " +
            "customer_order co " +
            "WHERE " +
            "co.customer_order_id = ?";

    @Override
    public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
        try (PreparedStatement statement =
                 connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
            statement.setInt(1, amount);
            statement.setLong(2, customerId);
            statement.setInt(3, confirmationNumber);
            int affected = statement.executeUpdate();
            if (affected != 1) {
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
//     public SimpleAffableQueryDbException(String message) {
//         super(message);
//     }
// 
//     public SimpleAffableQueryDbException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
//     public SimpleAffableUpdateDbException(String message) {
//         super(message);
//     }
// 
//     public SimpleAffableUpdateDbException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }
// 
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection()  {
//     if (dataSource == null) {
//         dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
//     }
// 
//     try {
//         return dataSource.getConnection();
//     } catch (SQLException e) {
//         throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
//     }
// 
// }


// Path: src/main/java/business/order/CustomerOrderDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;

        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
        "FROM " +
            "customer_order co";

    private static final String FIND_BY_CUSTOMER_ID_SQL =
        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
        "FROM " +
            "customer_order co " +
        "WHERE " +
            "co.customer_id = ?";

    private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
        "SELECT " +
            "co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
            "FROM " +
            "customer_order co " +
            "WHERE " +
            "co.customer_order_id = ?";

    @Override
    public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
        try (PreparedStatement statement =
                 connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
            statement.setInt(1, amount);
            statement.setLong(2, customerId);
            statement.setInt(3, confirmationNumber);
            int affected = statement.executeUpdate();
            if (affected != 1) {
                throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "