// Path: src/main/java/com/treasuredata/jdbc/command/CommandContext.java
// public class CommandContext
// {
// 
//     public int queryTimeout = 0; // seconds
// 
//     public String sql;
// 
//     public TDResultSetBase resultSet;
// 
//     public CommandContext()
//     {
//     }
// }
// 
// Path: src/main/java/com/treasuredata/jdbc/command/CommandExecutor.java
// public class CommandExecutor
//         implements Constants
// {
//     private static final Logger LOG = Logger.getLogger(CommandExecutor.class.getName());
// 
//     private ClientAPI api;
// 
//     public CommandExecutor(ClientAPI api)
//     {
//         this.api = api;
//     }
// 
//     public ClientAPI getAPI()
//     {
//         return api;
//     }
// 
//     public synchronized void execute(CommandContext context)
//             throws SQLException
//     {
//         String sql = context.sql;
//         try {
//             if (sql.toUpperCase().equals("SELECT 1")) {
//                 context.resultSet = new TDResultSetSelectOne(api);
//             }
//             else {
//                 context.resultSet = api.select(context.sql, context.queryTimeout);
//             }
//         }
//         catch (ClientException e) {
//             throw new SQLException(e);
//         }
//     }
// 
//     public static class TDResultSetSelectOne
//             extends TDResultSetBase
//     {
//         private ClientAPI api;
// 
//         private int rowsFetched = 0;
// 
//         private Unpacker fetchedRows;
// 
//         private Iterator<Value> fetchedRowsItr;
// 
//         public TDResultSetSelectOne(ClientAPI api)
//         {
//             this.api = api;
//         }
// 
//         @Override
//         public boolean next()
//                 throws SQLException
//         {
//             try {
//                 if (fetchedRows == null) {
//                     fetchedRows = fetchRows();
//                     fetchedRowsItr = fetchedRows.iterator();
//                 }
// 
//                 if (!fetchedRowsItr.hasNext()) {
//                     return false;
//                 }
// 
//                 ArrayValue vs = (ArrayValue) fetchedRowsItr.next();
//                 row = new ArrayList<Object>(vs.size());
//                 for (int i = 0; i < vs.size(); i++) {
//                     row.add(i, vs.get(i));
//                 }
//                 rowsFetched++;
//             }
//             catch (Exception e) {
//                 throw new SQLException("Error retrieving next row", e);
//             }
//             // NOTE: fetchOne dosn't throw new SQLException("Method not supported").
//             return true;
//         }
// 
//         @Override
//         public void close()
//                 throws SQLException
//         {
//             // do nothing
//         }
// 
//         @Override
//         public ResultSetMetaData getMetaData()
//                 throws SQLException
//         {
//             return api.getMetaDataWithSelect1();
//         }
// 
//         private Unpacker fetchRows()
//                 throws SQLException
//         {
//             try {
//                 MessagePack msgpack = new MessagePack();
//                 ByteArrayOutputStream out = new ByteArrayOutputStream();
//                 Packer packer = msgpack.createPacker(out);
//                 List<Integer> src = new ArrayList<Integer>();
//                 src.add(1);
//                 packer.write(src);
//                 byte[] bytes = out.toByteArray();
//                 ByteArrayInputStream in = new ByteArrayInputStream(bytes);
//                 Unpacker unpacker = msgpack.createUnpacker(in);
//                 return unpacker;
//             }
//             catch (IOException e) {
//                 throw new SQLException(e);
//             }
//         }
//     }
// }


import com.treasuredata.jdbc.command.CommandContext;
import com.treasuredata.jdbc.command.CommandExecutor;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.treasuredata.jdbc;



public abstract class TDStatementBase
        implements Statement
{

    protected TDConnection conn;

// Path: src/main/java/com/treasuredata/jdbc/command/CommandContext.java
// public class CommandContext
// {
// 
//     public int queryTimeout = 0; // seconds
// 
//     public String sql;
// 
//     public TDResultSetBase resultSet;
// 
//     public CommandContext()
//     {
//     }
// }
// 
// Path: src/main/java/com/treasuredata/jdbc/command/CommandExecutor.java
// public class CommandExecutor
//         implements Constants
// {
//     private static final Logger LOG = Logger.getLogger(CommandExecutor.class.getName());
// 
//     private ClientAPI api;
// 
//     public CommandExecutor(ClientAPI api)
//     {
//         this.api = api;
//     }
// 
//     public ClientAPI getAPI()
//     {
//         return api;
//     }
// 
//     public synchronized void execute(CommandContext context)
//             throws SQLException
//     {
//         String sql = context.sql;
//         try {
//             if (sql.toUpperCase().equals("SELECT 1")) {
//                 context.resultSet = new TDResultSetSelectOne(api);
//             }
//             else {
//                 context.resultSet = api.select(context.sql, context.queryTimeout);
//             }
//         }
//         catch (ClientException e) {
//             throw new SQLException(e);
//         }
//     }
// 
//     public static class TDResultSetSelectOne
//             extends TDResultSetBase
//     {
//         private ClientAPI api;
// 
//         private int rowsFetched = 0;
// 
//         private Unpacker fetchedRows;
// 
//         private Iterator<Value> fetchedRowsItr;
// 
//         public TDResultSetSelectOne(ClientAPI api)
//         {
//             this.api = api;
//         }
// 
//         @Override
//         public boolean next()
//                 throws SQLException
//         {
//             try {
//                 if (fetchedRows == null) {
//                     fetchedRows = fetchRows();
//                     fetchedRowsItr = fetchedRows.iterator();
//                 }
// 
//                 if (!fetchedRowsItr.hasNext()) {
//                     return false;
//                 }
// 
//                 ArrayValue vs = (ArrayValue) fetchedRowsItr.next();
//                 row = new ArrayList<Object>(vs.size());
//                 for (int i = 0; i < vs.size(); i++) {
//                     row.add(i, vs.get(i));
//                 }
//                 rowsFetched++;
//             }
//             catch (Exception e) {
//                 throw new SQLException("Error retrieving next row", e);
//             }
//             // NOTE: fetchOne dosn't throw new SQLException("Method not supported").
//             return true;
//         }
// 
//         @Override
//         public void close()
//                 throws SQLException
//         {
//             // do nothing
//         }
// 
//         @Override
//         public ResultSetMetaData getMetaData()
//                 throws SQLException
//         {
//             return api.getMetaDataWithSelect1();
//         }
// 
//         private Unpacker fetchRows()
//                 throws SQLException
//         {
//             try {
//                 MessagePack msgpack = new MessagePack();
//                 ByteArrayOutputStream out = new ByteArrayOutputStream();
//                 Packer packer = msgpack.createPacker(out);
//                 List<Integer> src = new ArrayList<Integer>();
//                 src.add(1);
//                 packer.write(src);
//                 byte[] bytes = out.toByteArray();
//                 ByteArrayInputStream in = new ByteArrayInputStream(bytes);
//                 Unpacker unpacker = msgpack.createUnpacker(in);
//                 return unpacker;
//             }
//             catch (IOException e) {
//                 throw new SQLException(e);
//             }
//         }
//     }
// }


// Path: src/main/java/com/treasuredata/jdbc/TDStatementBase.java
import com.treasuredata.jdbc.command.CommandContext;
import com.treasuredata.jdbc.command.CommandExecutor;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.treasuredata.jdbc;



public abstract class TDStatementBase
        implements Statement
{

    protected TDConnection conn;

    protected CommandExecutor exec;