// Path: src/main/java/fm/liu/timo/mysql/PreparedStatement.java
// public class PreparedStatement {
// 
//     private long     id;
//     private int      columnsNumber;
//     private int      parametersNumber;
//     private int[]    parametersType;
//     private String[] statements;
//     private boolean  endsWithQuestionMark;
// 
//     public PreparedStatement(long id, String statement) {
//         this.id = id;
//         if (statement.endsWith("?")) {
//             endsWithQuestionMark = true;
//         }
//         this.statements = statement.split("\\?");
//         this.parametersNumber = endsWithQuestionMark ? statements.length : statements.length + 1;
//         if (!statement.contains("?")) {
//             this.parametersNumber = 0;
//         }
//         this.parametersType = new int[parametersNumber];
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     public int getColumnsNumber() {
//         return columnsNumber;
//     }
// 
//     public int getParametersNumber() {
//         return parametersNumber;
//     }
// 
//     public int[] getParametersType() {
//         return parametersType;
//     }
// 
//     public String[] getStatements() {
//         return statements;
//     }
// 
//     public boolean isEndsWithQuestionMark() {
//         return endsWithQuestionMark;
//     }
// 
// }
// 
// Path: src/main/java/fm/liu/timo/mysql/packet/PreparedOkPacket.java
// public class PreparedOkPacket extends ResultSetPacket {
// 
//     public byte flag;
//     public long statementId;
//     public int  columnsNumber;
//     public int  parametersNumber;
//     public byte filler;
//     public int  warningCount;
// 
//     public PreparedOkPacket() {
//         this.flag = 0;
//         this.filler = 0;
//     }
// 
//     @Override
//     public int calcPacketSize() {
//         return 12;
//     }
// 
//     @Override
//     protected String getPacketInfo() {
//         return "MySQL PreparedOk Packet";
//     }
// 
//     @Override
//     protected void writeBody(ByteBuffer buffer) {
//         buffer.put(flag);
//         BufferUtil.writeUB4(buffer, statementId);
//         BufferUtil.writeUB2(buffer, columnsNumber);
//         BufferUtil.writeUB2(buffer, parametersNumber);
//         buffer.put(filler);
//         BufferUtil.writeUB2(buffer, warningCount);
//     }
// 
//     @Override
//     protected void readBody(MySQLMessage mm) {
//         throw new RuntimeException("readBody for Reply323Packet not implement!");
//     }
// 
// }


import java.nio.ByteBuffer;
import fm.liu.timo.mysql.PreparedStatement;
import fm.liu.timo.mysql.packet.EOFPacket;
import fm.liu.timo.mysql.packet.FieldPacket;
import fm.liu.timo.mysql.packet.PreparedOkPacket;
import fm.liu.timo.net.connection.FrontendConnection;
/*
 * Copyright 1999-2012 Alibaba Group.
 * 
 * Licensed 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 fm.liu.timo.server.response;


/**
 * @author xianmao.hexm 2012-8-28
 */
public class PreparedStmtResponse {

    public static void response(PreparedStatement pstmt, FrontendConnection c) {
        byte packetId = 0;

        // write preparedOk packet
// Path: src/main/java/fm/liu/timo/mysql/PreparedStatement.java
// public class PreparedStatement {
// 
//     private long     id;
//     private int      columnsNumber;
//     private int      parametersNumber;
//     private int[]    parametersType;
//     private String[] statements;
//     private boolean  endsWithQuestionMark;
// 
//     public PreparedStatement(long id, String statement) {
//         this.id = id;
//         if (statement.endsWith("?")) {
//             endsWithQuestionMark = true;
//         }
//         this.statements = statement.split("\\?");
//         this.parametersNumber = endsWithQuestionMark ? statements.length : statements.length + 1;
//         if (!statement.contains("?")) {
//             this.parametersNumber = 0;
//         }
//         this.parametersType = new int[parametersNumber];
//     }
// 
//     public long getId() {
//         return id;
//     }
// 
//     public int getColumnsNumber() {
//         return columnsNumber;
//     }
// 
//     public int getParametersNumber() {
//         return parametersNumber;
//     }
// 
//     public int[] getParametersType() {
//         return parametersType;
//     }
// 
//     public String[] getStatements() {
//         return statements;
//     }
// 
//     public boolean isEndsWithQuestionMark() {
//         return endsWithQuestionMark;
//     }
// 
// }
// 
// Path: src/main/java/fm/liu/timo/mysql/packet/PreparedOkPacket.java
// public class PreparedOkPacket extends ResultSetPacket {
// 
//     public byte flag;
//     public long statementId;
//     public int  columnsNumber;
//     public int  parametersNumber;
//     public byte filler;
//     public int  warningCount;
// 
//     public PreparedOkPacket() {
//         this.flag = 0;
//         this.filler = 0;
//     }
// 
//     @Override
//     public int calcPacketSize() {
//         return 12;
//     }
// 
//     @Override
//     protected String getPacketInfo() {
//         return "MySQL PreparedOk Packet";
//     }
// 
//     @Override
//     protected void writeBody(ByteBuffer buffer) {
//         buffer.put(flag);
//         BufferUtil.writeUB4(buffer, statementId);
//         BufferUtil.writeUB2(buffer, columnsNumber);
//         BufferUtil.writeUB2(buffer, parametersNumber);
//         buffer.put(filler);
//         BufferUtil.writeUB2(buffer, warningCount);
//     }
// 
//     @Override
//     protected void readBody(MySQLMessage mm) {
//         throw new RuntimeException("readBody for Reply323Packet not implement!");
//     }
// 
// }


// Path: src/main/java/fm/liu/timo/server/response/PreparedStmtResponse.java
import java.nio.ByteBuffer;
import fm.liu.timo.mysql.PreparedStatement;
import fm.liu.timo.mysql.packet.EOFPacket;
import fm.liu.timo.mysql.packet.FieldPacket;
import fm.liu.timo.mysql.packet.PreparedOkPacket;
import fm.liu.timo.net.connection.FrontendConnection;

/*
 * Copyright 1999-2012 Alibaba Group.
 * 
 * Licensed 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 fm.liu.timo.server.response;


/**
 * @author xianmao.hexm 2012-8-28
 */
public class PreparedStmtResponse {

    public static void response(PreparedStatement pstmt, FrontendConnection c) {
        byte packetId = 0;

        // write preparedOk packet
        PreparedOkPacket preparedOk = new PreparedOkPacket();