
jtopenlite.com.ibm.jtopenlite.database.jdbc.JDBCResultSetMetaData Maven / Gradle / Ivy
///////////////////////////////////////////////////////////////////////////////
//
// JTOpenLite
//
// Filename: JDBCResultSetMetaData.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 2011-2012 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.jtopenlite.database.jdbc;
import com.ibm.jtopenlite.database.*;
import java.sql.*;
import java.util.Calendar;
public class JDBCResultSetMetaData implements ResultSetMetaData, DatabaseDescribeCallback
{
private Column[] columns_;
private int offset_;
private String catalog_;
final int serverCCSID_;
private final Calendar calendar_;
public JDBCResultSetMetaData(int serverCCSID, Calendar calendarUsedForConversions, String catalog)
{
serverCCSID_ = serverCCSID;
calendar_ = calendarUsedForConversions;
catalog_ = catalog;
}
public void resultSetDescription(int numFields, int dateFormat, int timeFormat, int dateSeparator, int timeSeparator, int recordSize)
{
columns_ = new Column[numFields];
for (int i=0; icolumn), and returns that same object
* on the next call to ResultSet.getDate(column) if the value returned from the database is identical.
* This also works for repeated calls to ResultSet.getDate(column) when the ResultSet has not changed rows.
**/
public void setUseDateCache(int column, boolean b)
{
Column c = getColumn(column-1);
c.setUseDateCache(b);
}
/**
* You know you want this, if you're going to be calling getDate() a lot.
**/
public void setUseDateCache(String column, boolean b)
{
Column c = getColumn(column);
c.setUseDateCache(b);
}
/**
* Caches the last Time returned by ResultSet.getTime(column), and returns that same object
* on the next call to ResultSet.getTime(column) if the value returned from the database is identical.
* This also works for repeated calls to ResultSet.getTime(column) when the ResultSet has not changed rows.
**/
public void setUseTimeCache(int column, boolean b)
{
Column c = getColumn(column-1);
c.setUseTimeCache(b);
}
/**
* You know you want this, if you're going to be calling getTime() a lot.
**/
public void setUseTimeCache(String column, boolean b)
{
Column c = getColumn(column);
c.setUseTimeCache(b);
}
/**
* Caches all unique Strings returned by ResultSet.getString(column). Any subsequent call to
* ResultSet.getString(column) will attempt to return a previously cached object if the value
* returned from the database matches something in the cache. This also works for repeated calls to ResultSet.getString(column)
* when the ResultSet has not changed rows. Note this will cache *ALL* Strings for this column, so unless you know your
* column values will only ever be a finite set, you should also call {@link #setCacheLastOnly setCacheLastOnly()} and use an ORDER BY clause.
**/
public void setUseStringCache(int column, boolean b)
{
Column c = getColumn(column-1);
c.setUseStringCache(b);
}
/**
* You know you want this, if you're going to be calling getString() a lot.
**/
public void setUseStringCache(String column, boolean b)
{
Column c = getColumn(column);
c.setUseStringCache(b);
}
/**
* Caches the last String returned by ResultSet.getString(column), and returns that same object
* on the next call to ResultSet.getString(column) if the value returned from the database is identical.
* This also works for repeated calls to ResultSet.getString(column) when the ResultSet has not changed rows.
* This setting only takes effect if {@link #setUseStringCache setUseStringCache()} was called with a value of true
* for this column.
**/
public void setCacheLastOnly(int column, boolean b)
{
Column c = getColumn(column-1);
c.setCacheLastOnly(b);
}
/**
* You know you want this, if you're going to be calling getString() a lot.
**/
public void setCacheLastOnly(String column, boolean b)
{
Column c = getColumn(column);
c.setCacheLastOnly(b);
}
Column getColumn(int fieldIndex)
{
return columns_[fieldIndex];
}
Column getColumn(String name)
{
for (int i=0; i columns_.length)) {
JDBCError.throwSQLException(JDBCError.EXC_DESCRIPTOR_INDEX_INVALID);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy