@Override
    public Map findRecordById(String table, String pkField, Object keyValue,
            boolean closeConnection) throws SQLException, Exception {
        Statement statement = null;
        ResultSet resultSet = null;
        ResultSetMetaData metaData = null;
        final Map record = new HashMap();

        try {
            statement = dbConnection.createStatement();
            String sql2;

            if (keyValue instanceof String) {
                sql2 = "= '" + keyValue + "'";
            } else {
                sql2 = "=" + keyValue;
            }

            final String sql = "SELECT * FROM " + table + " WHERE " + pkField + sql2;
            resultSet = statement.executeQuery(sql);
            metaData = resultSet.getMetaData();
            metaData.getColumnCount();
            final int fields = metaData.getColumnCount();
            // Retrieve the raw data from the ResultSet and copy the values into a Map
            // with the keys being the column names of the table.
            if (resultSet.next()) {
                for (int i = 1; i <= fields; i++) {
                    record.put(metaData.getColumnName(i), resultSet.getObject(i));
                }
            }

        } catch (SQLException sql) {
            throw new SQLException(SQL_ERR);
        } catch (Exception e) {
            throw new Exception(e.getLocalizedMessage());
        } finally {
            try {
                statement.close();
                if (closeConnection) {
                    dbConnection.close();
                }
            } catch (SQLException e) {
                throw e;
            } // end try
        } // end finally

        return record;
    }