18 package com.mysql.clusterj.jdbc;
 
   20 import java.math.BigDecimal;
 
   22 import java.sql.SQLException;
 
   24 import java.sql.Timestamp;
 
   25 import java.util.Calendar;
 
   26 import java.util.HashMap;
 
   29 import com.mysql.clusterj.core.spi.SessionSPI;
 
   30 import com.mysql.clusterj.core.store.ResultData;
 
   31 import com.mysql.clusterj.core.util.I18NHelper;
 
   32 import com.mysql.clusterj.core.util.Logger;
 
   33 import com.mysql.clusterj.core.util.LoggerFactoryService;
 
   53     private int[] columnIndexToFieldNumberMap;
 
   55     private Map<String, Integer> columnNameToFieldNumberMap = 
new HashMap<String, Integer>();
 
   57     private boolean autotransaction = 
true;
 
   60             Map<String, Integer> columnNameToFieldNumberMap, 
SessionSPI session) {
 
   61         this.columnIndexToFieldNumberMap = columnIndexToFieldNumberMap;
 
   62         this.columnNameToFieldNumberMap = columnNameToFieldNumberMap;
 
   63         this.resultData = resultData;
 
   64         this.session = session;
 
   68     public boolean reallyResult() {
 
   73     public boolean next() {
 
   74         boolean hasNext = resultData.next();
 
   77         if (autotransaction & !hasNext) {
 
   78             session.endAutoTransaction();
 
   79             autotransaction = 
false;
 
   81         if (logger.isDetailEnabled()) logger.detail(
"ResultSetInternalMethods.next returned: " + hasNext);
 
   86     public long getUpdateID() {
 
   91     public boolean getBoolean(
int columnIndex) 
throws SQLException {
 
   92         boolean result = resultData.getBoolean(columnIndexToFieldNumberMap[columnIndex]);
 
   97     public boolean getBoolean(
String columnName) 
throws SQLException {
 
   98         boolean result = resultData.getBoolean(getFieldNumberForColumnName(columnName));
 
  103     public byte getByte(
int columnIndex) 
throws SQLException {
 
  104         byte result = resultData.getByte(columnIndexToFieldNumberMap[columnIndex]);
 
  109     public byte getByte(
String columnName) 
throws SQLException {
 
  110         byte result = resultData.getByte(getFieldNumberForColumnName(columnName));
 
  115     public byte[] getBytes(
int columnIndex) 
throws SQLException {
 
  116         byte[] result = resultData.getBytes(columnIndexToFieldNumberMap[columnIndex]);
 
  121     public byte[] getBytes(
String columnName) 
throws SQLException {
 
  122         byte[] result = resultData.getBytes(getFieldNumberForColumnName(columnName));
 
  127     public Date getDate(
int columnIndex) 
throws SQLException {
 
  128         throw new SQLException(local.
message(
"ERR_Should_Not_Occur"));
 
  132     public Date getDate(
String columnName) 
throws SQLException {
 
  133         throw new SQLException(local.
message(
"ERR_Should_Not_Occur"));
 
  137     public Date getDate(
int columnIndex, Calendar cal) 
throws SQLException {
 
  138         throw new SQLException(local.
message(
"ERR_Should_Not_Occur"));
 
  142     public Date getDate(
String columnName, Calendar cal) 
throws SQLException {
 
  143         throw new SQLException(local.
message(
"ERR_Should_Not_Occur"));
 
  147     public double getDouble(
int columnIndex) 
throws SQLException {
 
  148         double result = resultData.getDouble(columnIndexToFieldNumberMap[columnIndex]);
 
  153     public double getDouble(
String columnName) 
throws SQLException {
 
  154         double result = resultData.getDouble(getFieldNumberForColumnName(columnName));
 
  159     public float getFloat(
int columnIndex) 
throws SQLException {
 
  160         float result = resultData.getFloat(columnIndexToFieldNumberMap[columnIndex]);
 
  165     public float getFloat(
String columnName) 
throws SQLException {
 
  166         float result = resultData.getFloat(getFieldNumberForColumnName(columnName));
 
  171     public long getLong(
int columnIndex) 
throws SQLException {
 
  172         long result = resultData.getLong(columnIndexToFieldNumberMap[columnIndex]);
 
  177     public long getLong(
String columnName) 
throws SQLException {
 
  178         long result = resultData.getLong(getFieldNumberForColumnName(columnName));
 
  183     public int getInt(
int columnIndex) 
throws SQLException {
 
  184         int result = resultData.getInt(columnIndexToFieldNumberMap[columnIndex]);
 
  189     public int getInt(
String columnName) 
throws SQLException {
 
  190         int result = resultData.getInt(getFieldNumberForColumnName(columnName));
 
  195     public short getShort(
int columnIndex) 
throws SQLException {
 
  196         short result = resultData.getShort(columnIndexToFieldNumberMap[columnIndex]);
 
  201     public short getShort(
String columnName) 
throws SQLException {
 
  202         short result = resultData.getShort(getFieldNumberForColumnName(columnName));
 
  207     public String getString(
int columnIndex) 
throws SQLException {
 
  208         String result = resultData.getString(columnIndexToFieldNumberMap[columnIndex]);
 
  213     public String getString(
String columnName) 
throws SQLException {
 
  214         String result = resultData.getString(getFieldNumberForColumnName(columnName));
 
  219     public Time getTime(
int columnIndex) 
throws SQLException {
 
  220         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  224     public Time getTime(
String columnName) 
throws SQLException {
 
  225         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  229     public Time getTime(
int columnIndex, Calendar cal) 
throws SQLException {
 
  230         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  234     public Time getTime(
String columnName, Calendar cal) 
throws SQLException {
 
  235         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  239     public Timestamp getTimestamp(
int columnIndex) 
throws SQLException {
 
  240         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  244     public Timestamp getTimestamp(
String columnName) 
throws SQLException {
 
  245         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  249     public Timestamp getTimestamp(
int columnIndex, Calendar cal) 
throws SQLException {
 
  250         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  254     public Timestamp getTimestamp(
String columnName, Calendar cal) 
throws SQLException {
 
  255         throw new SQLException(local.
message(
"ERR_Should_Not_Occur")); 
 
  259     public BigDecimal getBigDecimal(
int columnIndex) 
throws SQLException {
 
  260         BigDecimal result = resultData.getDecimal(columnIndexToFieldNumberMap[columnIndex]);
 
  265     public BigDecimal getBigDecimal(
String columnName) 
throws SQLException {
 
  266         BigDecimal result = resultData.getDecimal(getFieldNumberForColumnName(columnName));
 
  271     public void realClose(
boolean arg0) 
throws SQLException {
 
  273         if (autotransaction) {
 
  274             session.endAutoTransaction();
 
  275             autotransaction = 
false;
 
  279     private int getFieldNumberForColumnName(
String columnName) 
throws SQLException {
 
  280         Integer fieldNumber = columnNameToFieldNumberMap.get(columnName);
 
  281         if (fieldNumber != null) {
 
  282             return fieldNumber.intValue();
 
  284         throw new SQLException(local.
message(
"ERR_Column_Name_Not_In_Result", columnName));