Methods Summary |
---|
public synchronized void | clearWarnings()
warnings = null;
|
public void | close()Closes the result set.
synchronized( rows ) {
while( !complete ) {
try {
rows.wait();
}
catch( InterruptedException e ) {
}
}
if( !meta_set && field_info != null ) {
field_info.close();
}
input = null;
}
|
public synchronized int | findColumn(java.lang.String name)
Integer num;
if( column_map == null ) {
ResultSetMetaData meta;
int maxi;
// Thanks to Joern Kellermann for this fix
meta = getMetaData();
column_map = new Hashtable(maxi = meta.getColumnCount());
for(int i=1; i<=maxi; i++) {
column_map.put(meta.getColumnName(i), new Integer(i));
}
}
num = (Integer)column_map.get(name);
if( num == null ) {
throw new SQLException("Invalid column name: " + name);
}
return num.intValue();
|
public synchronized java.io.InputStream | getAsciiStream(java.lang.String cname)For performance reasons, you should get values by column
number when at all possible.
return getAsciiStream(findColumn(cname));
|
public synchronized java.io.InputStream | getAsciiStream(int column)
getColumn(column);
return new MsqlAsciiInputStream(last_column);
|
public synchronized java.math.BigDecimal | getBigDecimal(java.lang.String cname, int scale)
return getBigDecimal(findColumn(cname), scale);
|
public synchronized java.math.BigDecimal | getBigDecimal(int column, int scale)
String tmp = getString(column);
if( tmp == null ) {
return new BigDecimal(new BigInteger("0"), scale);
}
else {
return new BigDecimal(new BigInteger(tmp), scale);
}
|
public synchronized java.io.InputStream | getBinaryStream(java.lang.String cname)
return getBinaryStream(findColumn(cname));
|
public synchronized java.io.InputStream | getBinaryStream(int column)
getColumn(column);
return new ByteArrayInputStream(last_column);
|
public synchronized boolean | getBoolean(java.lang.String cname)
return getBoolean(findColumn(cname));
|
public synchronized boolean | getBoolean(int column)
getColumn(column);
if( wasNull() ) {
return false;
}
if( last_column.length == 0 ) {
return false;
}
else if( last_column[0] == '0" || last_column[0] == '\0" ) {
return false;
}
else {
return true;
}
|
public synchronized byte | getByte(java.lang.String cname)
return getByte(findColumn(cname));
|
public synchronized byte | getByte(int column)
getColumn(column);
if( wasNull() ) {
return (byte)0;
}
else {
return last_column[0];
}
|
public synchronized byte[] | getBytes(java.lang.String cname)
return getBytes(findColumn(cname));
|
public synchronized byte[] | getBytes(int column)
getColumn(column);
return last_column;
|
private synchronized void | getColumn(int column)
try {
last_column = current_row_data[column-1];
}
catch( Exception e ) {
if( current_row_data == null ) {
throw new MsqlException("-1:Result set positioned before " +
"first row.");
}
throw new MsqlException(e);
}
|
public java.lang.String | getCursorName()
throw new SQLException("mSQL does not support cursors.");
|
public synchronized java.sql.Date | getDate(java.lang.String cname)
return getDate(findColumn(cname));
|
public synchronized java.sql.Date | getDate(int column)
long time = getTimeAsLong(column);
if( wasNull() ) {
return null;
}
else {
return new Date(time);
}
|
public synchronized double | getDouble(java.lang.String cname)
return getDouble(findColumn(cname));
|
public synchronized double | getDouble(int column)
String tmp = getString(column);
if( tmp == null ) return 0;
try {
return Double.valueOf(tmp).doubleValue();
}
catch( NumberFormatException e ) {
throw new MsqlException(e);
}
|
public synchronized float | getFloat(java.lang.String cname)
return getFloat(findColumn(cname));
|
public synchronized float | getFloat(int column)
String tmp = getString(column);
if( tmp == null ) {
return 0;
}
try {
return Float.valueOf(tmp).floatValue();
}
catch( NumberFormatException e ) {
throw new MsqlException(e);
}
|
public synchronized int | getInt(java.lang.String cname)
return getInt(findColumn(cname));
|
public synchronized int | getInt(int column)
String tmp = getString(column);
if( tmp == null ) {
return 0;
}
try {
return Integer.parseInt(tmp);
}
catch( NumberFormatException e ) {
throw new MsqlException(e);
}
|
public synchronized long | getLong(java.lang.String cname)
return getLong(findColumn(cname));
|
public synchronized long | getLong(int column)
String tmp = getString(column);
if( tmp == null ) {
return 0;
}
try {
return Long.parseLong(tmp);
}
catch( NumberFormatException e ) {
throw new MsqlException(e);
}
|
public java.sql.ResultSetMetaData | getMetaData()
ResultSetMetaData meta;
synchronized( this ) {
if( meta_data != null ) {
return meta_data;
}
}
synchronized( rows ) {
while( field_info == null ) {
try {
rows.wait();
}
catch( InterruptedException e ) {
if( field_info == null ) {
throw new MsqlException(e);
}
}
}
meta = new MsqlResultSetMetaData(field_info);
}
synchronized( this ) {
meta_data = meta;
}
return meta_data;
|
public synchronized java.lang.Object | getObject(java.lang.String cname)
return getObject(findColumn(cname));
|
public synchronized java.lang.Object | getObject(int column)
ResultSetMetaData meta = getMetaData();
int type = meta.getColumnType(column);
switch(type) {
case Types.BIT:
return new Boolean(getBoolean(column));
case Types.TINYINT:
return new Character((char)getInt(column));
case Types.SMALLINT:
return new Integer(getShort(column));
case Types.INTEGER:
return new Integer(getInt(column));
case Types.BIGINT:
return new Long(getLong(column));
case Types.FLOAT:
return new Float(getFloat(column));
case Types.REAL:
return new Float(getFloat(column));
case Types.DOUBLE:
return new Double(getDouble(column));
case Types.NUMERIC:
return getBigDecimal(column, 0);
case Types.DECIMAL:
return getBigDecimal(column, 0);
case Types.CHAR:
return getString(column);
case Types.VARCHAR:
return getString(column);
case Types.LONGVARCHAR:
return getString(column);
case Types.DATE:
return getDate(column);
case Types.TIME:
return getTime(column);
case Types.TIMESTAMP:
return getTimestamp(column);
case Types.BINARY:
return getBytes(column);
case Types.VARBINARY:
return getBytes(column);
case Types.LONGVARBINARY:
return getBytes(column);
default:
return getString(column);
}
|
private byte[][] | getRow(int row)
if( row < 0 ) {
throw new SQLException("Attempt to access a non-existent row.");
}
synchronized( rows ) {
if( read_exception != null ) {
throw read_exception;
}
while( rows.size() <= row ) {
if( complete ) {
throw new SQLException("Attempt to access a " +
"non-existent row.");
}
else {
try {
rows.wait();
}
catch( InterruptedException e ) {
throw new MsqlException(e);
}
}
}
}
return (byte[][])rows.elementAt(row);
|
public synchronized short | getShort(java.lang.String cname)
return getShort(findColumn(cname));
|
public synchronized short | getShort(int column)
String tmp = getString(column);
if( tmp == null ) {
return 0;
}
try {
return (short)Short.parseShort(tmp);
}
catch( NumberFormatException e ) {
throw new MsqlException(e);
}
|
MsqlStatement | getStatement()
return statement;
|
public synchronized java.lang.String | getString(java.lang.String cname)
return getString(findColumn(cname));
|
public synchronized java.lang.String | getString(int column)
getColumn(column);
if( wasNull() ) {
return null;
}
else {
try {
return new String(last_column, "8859_9");
}
catch( UnsupportedEncodingException e ) {
throw new MsqlException(e);
}
}
|
public synchronized java.sql.Time | getTime(java.lang.String cname)
return getTime(findColumn(cname));
|
public synchronized java.sql.Time | getTime(int column)
long time = getTimeAsLong(column);
if( wasNull() ) {
return null;
}
else {
return new Time(time);
}
|
private long | getTimeAsLong(int column)
String tmp = getString(column);
if( tmp == null ) {
return 0;
}
try {
return Long.parseLong(tmp);
}
catch( NumberFormatException e ) {
try {
SimpleDateFormat format;
java.util.Date date;
format = new SimpleDateFormat("EEE MMM dd hh:mm:ss z yyyy");
date = format.parse(tmp, new ParsePosition(0));
return date.getTime();
}
catch( Exception real_e ) {
throw new SQLException("Invalid date format.");
}
}
|
public synchronized java.sql.Timestamp | getTimestamp(java.lang.String cname)
return getTimestamp(findColumn(cname));
|
public synchronized java.sql.Timestamp | getTimestamp(int column)
long time = getTimeAsLong(column);
if( wasNull() ) {
return null;
}
else {
return new Timestamp(time);
}
|
public synchronized java.io.InputStream | getUnicodeStream(java.lang.String cname)
return getUnicodeStream(findColumn(cname));
|
public synchronized java.io.InputStream | getUnicodeStream(int column)
getColumn(column);
return new MsqlUnicodeInputStream(last_column);
|
public synchronized java.sql.SQLWarning | getWarnings()
return warnings;
|
public synchronized boolean | next()Moves to the next row of data for processing. If there are no
more rows to be processed, then it will return false.
current_row++;
try {
current_row_data = getRow(current_row);
}
catch( SQLException e ) {
return false;
}
return true;
|
private void | readRow(byte[] data)
byte[][] cols = new byte[column_count][];
String ascii;
try {
ascii = new String(data, "8859_9");
}
catch( UnsupportedEncodingException e ) {
throw new MsqlException(e);
}
for(int i=0; i<column_count; i++) {
// we can get away with this since ascii arabics == unicode arabics
int colon = ascii.indexOf(':");
byte[] column;
int size;
try {
size = Integer.parseInt(ascii.substring(0, colon));
}
catch( NumberFormatException e ) {
throw new SQLException("Invalid row data format from mSQL.");
}
if( size == -2 ) {
column = null;
size = 0;
}
else {
String tmp = ascii.substring(colon+1, colon+size+1);
try {
column = tmp.getBytes("8859_9");
}
catch( UnsupportedEncodingException e ) {
throw new MsqlException(e);
}
}
cols[i] = column;
ascii = ascii.substring(colon+size+1);
}
synchronized( rows ) {
rows.addElement(cols);
rows.notify();
}
|
public void | run()
while( true ) {
byte[] data;
String tmp;
synchronized( input ) {
try {
data = input.read();
}
catch( IOException e ) {
synchronized( rows ) {
//statement.passIOException(e);
read_exception = new MsqlException(e);
complete = true;
input = null;
return;
}
}
}
try {
tmp = new String(data, "8859_9");
}
catch( UnsupportedEncodingException e ) {
e.printStackTrace();
synchronized( rows ) {
//statement.passIOException(e);
read_exception = new MsqlException(e);
complete = true;
rows.notify();
}
return;
}
if( tmp.startsWith("-1:") ) {
synchronized( rows ) {
read_exception = new MsqlException(tmp);
complete = true;
rows.notify();
}
return;
}
else if( tmp.startsWith("-100") ) {
break;
}
else {
try {
readRow(data);
}
catch( SQLException e ) {
synchronized( rows ) {
read_exception = new MsqlException(e);
complete = true;
rows.notify();
}
return;
}
}
}
synchronized( rows ) {
if( !meta_set ) {
try {
field_info = new MsqlResultSet(statement, input, 6, true);
}
catch( SQLException e ) {
e.printStackTrace();
field_info = null;
}
}
complete = true;
rows.notify();
}
|
public synchronized boolean | wasNull()
if( last_column == null ) {
return true;
}
else {
return false;
}
|