📄 jdbchelper.java
字号:
/**
* Return a copy of myself without a database connection.
* Because there will not be a database connection, it will be considered
* to be outside of a transaction.
*
* @return a clone of this 'Object'
*/
public Object clone()
throws CloneNotSupportedException
{
JDBCHelper clone = (JDBCHelper) super.clone();
// Clear out data specific to the source object.
clone.i_statement = null;
clone.i_resultSet = null;
clone.i_connection = null;
// These probably aren't necessary, but are for completeness
clone.i_sqlString = "";
clone.i_columnName = "";
clone.i_columnIndex = 0;
clone.i_serialNum = ++s_instanceCount;
// clone will not be in pool, flag appropriately.
clone.i_inPool = false;
// clone will not even have a connection, so won't be inside a trans.
clone.i_isInsideTransaction = false;
return clone;
}
/* ============== Column Value Accessors ================= */
/**
* Get whatever type of object is in the given column.
* If the column has a null, this will return false.
* @param column a value of type 'String'
* @return a value of type 'Object'
*/
public Object getObject(String column)
throws SQLException
{
i_columnName = column;
Object returnValue = i_resultSet.getObject(column);
i_columnName = "";
return returnValue;
}
/**
* Get whatever type of object is in the given column.
* If the column has a null, this will return false.
* @param column a value of type 'int'
* @return a value of type 'Object'
*/
public Object getObject(int column)
throws SQLException
{
i_columnIndex = column;
Object returnValue = i_resultSet.getObject(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getBoolean() method on the ResultSet.
* If the column has a null, this will return false.
* @param column a value of type 'String'
* @return a value of type 'boolean'
* @exception SQLException if column is not found
*/
public boolean getboolean(String column)
throws SQLException
{
i_columnName = column;
boolean returnValue = i_resultSet.getBoolean(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getboolean() method on the ResultSet.
* If the column has a null, this will return false.
* @param column a value of type 'int'
* @return a value of type 'boolean'
* @exception SQLException if column is not found
*/
public boolean getboolean(int column)
throws SQLException
{
i_columnIndex = column;
boolean returnValue = i_resultSet.getBoolean(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getBoolean() method on the ResultSet and wraps the boolean in
* a Boolean. If the column has a null, this will return false.
* (This used to return null if the JDBC driver did, but each JDBC driver
* behaves a little differently, so this equalizes that)
* @param column a value of type 'String'
* @return a value of type 'Boolean'
* @exception SQLException if column is not found
*/
public Boolean getBoolean(String column)
throws SQLException
{
i_columnName = column;
Boolean returnValue = new Boolean(i_resultSet.getBoolean(column));
if (returnValue == null)
{
returnValue = Boolean.FALSE;
}
i_columnName = "";
return returnValue;
}
/**
* Calls the getBoolean() method on the ResultSet and wraps the boolean in
* a Boolean. If the column has a null, this will return false.
* (This used to return null if the JDBC driver did, but each JDBC driver
* behaves a little differently, so this equalizes that)
* @param column a value of type 'int'
* @return a value of type 'Boolean'
* @exception SQLException if column is not found
*/
public Boolean getBoolean(int column)
throws SQLException
{
i_columnIndex = column;
Boolean returnValue = new Boolean(i_resultSet.getBoolean(column));
if (returnValue == null)
{
returnValue = Boolean.FALSE;
}
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getBoolean() method on the ResultSet and wraps the boolean in
* a Boolean. If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'Boolean', or null.
* @exception SQLException if column is not found
*/
public Boolean getNullableBoolean(String column)
throws SQLException
{
i_columnName = column;
Boolean returnValue = new Boolean(i_resultSet.getBoolean(column));
if (i_resultSet.wasNull())
{
returnValue = null;
}
i_columnName = "";
return returnValue;
}
/**
* Calls the getBoolean() method on the ResultSet and wraps the boolean in
* a Boolean. If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'Boolean', or null.
* @exception SQLException if column is not found
*/
public Boolean getNullableBoolean(int column)
throws SQLException
{
i_columnIndex = column;
Boolean returnValue = new Boolean(i_resultSet.getBoolean(column));
if (i_resultSet.wasNull())
{
returnValue = null;
}
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getString() method on the ResultSet and trims the result.
* If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'String'
* @exception SQLException if column is not found
* @see #getRawString
*/
public String getString(String column)
throws SQLException
{
String result = this.getRawString(column);
if (result != null)
{
result = result.trim();
}
return result;
}
/**
* Calls the getString() method on the ResultSet and trims the result.
* If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'String'
* @exception SQLException if column is not found
* @see #getRawString
*/
public String getString(int column)
throws SQLException
{
String result = this.getRawString(column);
if (result != null)
{
result = result.trim();
}
return result;
}
/**
* Calls the getString() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'String'
* @exception SQLException if column is not found
*/
public String getRawString(String column)
throws SQLException
{
i_columnName = column;
String returnValue = i_resultSet.getString(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getString() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'String'
* @exception SQLException if column is not found
*/
public String getRawString(int column)
throws SQLException
{
i_columnIndex = column;
String returnValue = i_resultSet.getString(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getTimestamp() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'Date'
* @exception SQLException if column is not found
*/
public Timestamp getTimestamp(String column)
throws SQLException
{
i_columnName = column;
Timestamp returnValue = i_resultSet.getTimestamp(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getTimestamp() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'java.sql.Date'
* @exception SQLException if column is not found
*/
public Timestamp getTimestamp(int column)
throws SQLException
{
i_columnIndex = column;
Timestamp returnValue = i_resultSet.getTimestamp(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getDate() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'java.sql.Date'
* @exception SQLException if column is not found
*/
public Date getDate(String column)
throws SQLException
{
i_columnName = column;
Date returnValue = i_resultSet.getDate(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getDate() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'java.sql.Date'
* @exception SQLException if column is not found
*/
public Date getDate(int column)
throws SQLException
{
i_columnIndex = column;
Date returnValue = i_resultSet.getDate(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getTime() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'String'
* @return a value of type 'java.sql.Time'
* @exception SQLException if column is not found
*/
public Time getTime(String column)
throws SQLException
{
i_columnName = column;
Time returnValue = i_resultSet.getTime(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getTime() method on the ResultSet.
* If the column has a null, this will return a null.
* @param column a value of type 'int'
* @return a value of type 'java.sql.Time'
* @exception SQLException if column is not found
*/
public Time getTime(int column)
throws SQLException
{
i_columnIndex = column;
Time returnValue = i_resultSet.getTime(column);
i_columnIndex = 0;
return returnValue;
}
/**
* Calls the getInt() method on the ResultSet and wraps the resulting int
* in an Integer. If database has a null, null is returned.
* @param column a value of type 'String'
* @return a value of type 'Integer'
* @exception SQLException if column is not found
*/
public Integer getInteger(String column)
throws SQLException
{
i_columnName = column;
Integer returnValue = new Integer(i_resultSet.getInt(column));
i_columnName = "";
if (i_resultSet.wasNull())
{
returnValue = null;
}
return returnValue;
}
/**
* Calls the getInt() method on the ResultSet and wraps the resulting int
* in an Integer. If database has a null, null is returned.
* @param column a value of type 'int'
* @return a value of type 'Integer'
* @exception SQLException if column is not found
*/
public Integer getInteger(int column)
throws SQLException
{
i_columnIndex = column;
Integer returnValue = new Integer(i_resultSet.getInt(column));
i_columnIndex = 0;
if (i_resultSet.wasNull())
{
returnValue = null;
}
return returnValue;
}
/**
* Calls the getLong() method on the ResultSet and wraps the resulting
* long in a Long. If database has a null, null is returned.
* @param column a value of type 'String'
* @return a value of type 'Long'
* @exception SQLException if column is not found
*/
public Long getLong(String column)
throws SQLException
{
i_columnName = column;
Long returnValue = new Long(i_resultSet.getLong(column));
i_columnName = "";
if (i_resultSet.wasNull())
{
returnValue = null;
}
return returnValue;
}
/**
* Calls the getLong() method on the ResultSet and wraps the resulting
* long in a Long. If database has a null, null is returned.
* @param column a value of type 'int'
* @return a value of type 'Long'
* @exception SQLException if column is not found
*/
public Long getLong(int column)
throws SQLException
{
i_columnIndex = column;
Long returnValue = new Long(i_resultSet.getLong(column));
i_columnIndex = 0;
if (i_resultSet.wasNull())
{
returnValue = null;
}
return returnValue;
}
/**
* Calls the getInt() method on the ResultSet.
* If the column has a null, this will return a zero.
* @param column a value of type 'String'
* @return a value of type 'int'
* @exception SQLException if column is not found
*/
public int getint(String column)
throws SQLException
{
i_columnName = column;
int returnValue = i_resultSet.getInt(column);
i_columnName = "";
return returnValue;
}
/**
* Calls the getInt() method on the ResultSet.
* If the column has a null, this will return a zero.
* @param column a value of type 'int'
* @return a value of type 'int'
* @exception SQLException if column is not found
*/
public int getint(int column)
throws SQLException
{
i_columnIndex = column;
int returnValue = i_resultSet.getInt(column);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -