Source Code Cross Referenced for ResultSet.java in  » Database-DBMS » Quadcap-Embeddable-Database » com » quadcap » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » Quadcap Embeddable Database » com.quadcap.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.quadcap.jdbc;
0002:
0003:        /* Copyright 1999 - 2003 Quadcap Software.  All rights reserved.
0004:         *
0005:         * This software is distributed under the Quadcap Free Software License.
0006:         * This software may be used or modified for any purpose, personal or
0007:         * commercial.  Open Source redistributions are permitted.  Commercial
0008:         * redistribution of larger works derived from, or works which bundle
0009:         * this software requires a "Commercial Redistribution License"; see
0010:         * http://www.quadcap.com/purchase.
0011:         *
0012:         * Redistributions qualify as "Open Source" under  one of the following terms:
0013:         *   
0014:         *    Redistributions are made at no charge beyond the reasonable cost of
0015:         *    materials and delivery.
0016:         *
0017:         *    Redistributions are accompanied by a copy of the Source Code or by an
0018:         *    irrevocable offer to provide a copy of the Source Code for up to three
0019:         *    years at the cost of materials and delivery.  Such redistributions
0020:         *    must allow further use, modification, and redistribution of the Source
0021:         *    Code under substantially the same terms as this license.
0022:         *
0023:         * Redistributions of source code must retain the copyright notices as they
0024:         * appear in each source code file, these license terms, and the
0025:         * disclaimer/limitation of liability set forth as paragraph 6 below.
0026:         *
0027:         * Redistributions in binary form must reproduce this Copyright Notice,
0028:         * these license terms, and the disclaimer/limitation of liability set
0029:         * forth as paragraph 6 below, in the documentation and/or other materials
0030:         * provided with the distribution.
0031:         *
0032:         * The Software is provided on an "AS IS" basis.  No warranty is
0033:         * provided that the Software is free of defects, or fit for a
0034:         * particular purpose.  
0035:         *
0036:         * Limitation of Liability. Quadcap Software shall not be liable
0037:         * for any damages suffered by the Licensee or any third party resulting
0038:         * from use of the Software.
0039:         */
0040:
0041:        import java.io.Externalizable;
0042:        import java.io.IOException;
0043:        import java.io.ObjectInput;
0044:        import java.io.ObjectOutput;
0045:        import java.io.InputStream;
0046:        import java.io.Reader;
0047:
0048:        import java.util.Calendar;
0049:        import java.util.Vector;
0050:
0051:        import java.math.BigDecimal;
0052:        import java.math.BigInteger;
0053:
0054:        //#ifndef JDK11
0055:        import java.util.Map;
0056:
0057:        import java.sql.Array;
0058:        import java.sql.Blob;
0059:        import java.sql.Clob;
0060:        import java.sql.Ref; //#endif
0061:
0062:        import java.sql.Date;
0063:        import java.sql.SQLException;
0064:        import java.sql.SQLWarning;
0065:        import java.sql.Time;
0066:        import java.sql.Timestamp;
0067:        import java.sql.Types;
0068:
0069:        import com.quadcap.util.Debug;
0070:
0071:        import com.quadcap.sql.Column;
0072:        import com.quadcap.sql.Cursor;
0073:        import com.quadcap.sql.Database;
0074:        import com.quadcap.sql.QedResultSet;
0075:        import com.quadcap.sql.Row;
0076:        import com.quadcap.sql.SelectExpression;
0077:        import com.quadcap.sql.Session;
0078:
0079:        import com.quadcap.sql.types.*;
0080:
0081:        import com.quadcap.sql.file.BlockFile;
0082:        import com.quadcap.sql.file.Log;
0083:
0084:        import com.quadcap.io.AsciiInputStream;
0085:        import com.quadcap.io.AsciiReader;
0086:        import com.quadcap.io.InputStreamReader;
0087:        import com.quadcap.io.ReaderInputStream;
0088:
0089:        import com.quadcap.util.ConfigNumber;
0090:        import com.quadcap.util.Util;
0091:
0092:        /**
0093:         * This class implements the <code>java.sql.ResultSet</code> interface,
0094:         * and provides facilities for accessing the results of a SQL query.
0095:         * QED supports updateable <code>ResultSet</code>s.
0096:         *
0097:         * <p>TODO: update{BC}lob</p>
0098:         *
0099:         * @author Stan Bailes
0100:         */
0101:        public class ResultSet implements  QedResultSet {
0102:            /*{com.quadcap.qed.Trace-vars.xml-1056}
0103:             * <config-var>
0104:             *   <config-name>qed.trace.ResultSet</config-name>
0105:             *   <config-dflt>0</config-dflt>
0106:             *   <config-desc>
0107:             *   <pre>
0108:             *     bit 0: API execution
0109:             *     bit 1: findColumn
0110:             *     bit 2: rows
0111:             *     bit 3: row + column -> object
0112:             *     bit 5: updateObject(row, col, obj)
0113:             *    </pre>
0114:             *    </config-desc>
0115:             * </config-var>
0116:             */
0117:            //#ifdef DEBUG
0118:            static final ConfigNumber trace = ConfigNumber.find(
0119:                    "qed.trace.ResultSet", "0");
0120:            //#endif
0121:
0122:            Statement stmt;
0123:            Cursor cursor;
0124:            Row row;
0125:            int rowNum = 0;
0126:            boolean onInsertRow = false;
0127:            boolean onUpdateRow = false;
0128:            boolean bf = false;
0129:            boolean rowUpdated = false;
0130:            boolean rowDeleted = false;
0131:
0132:            Row insertRow = null;
0133:            boolean wasNull = false;
0134:            Object lock = new Object();
0135:            int rowCount = 0;
0136:
0137:            /**
0138:             * Constructor that wraps a cursor.  Used internally to QED.
0139:             * @deprecated
0140:             * @param cursor a cursor
0141:             */
0142:            public ResultSet(Cursor cursor) {
0143:                this .cursor = cursor;
0144:            }
0145:
0146:            /**
0147:             * My database session/connection
0148:             */
0149:            final private Session getSession() {
0150:                return cursor.getSession();
0151:            }
0152:
0153:            /**
0154:             * I have been granted access to The File itself.  I am most humble.
0155:             */
0156:            final private BlockFile getBlockFile() {
0157:                return getSession().getFile();
0158:            }
0159:
0160:            /**
0161:             * My "handle" for this op.
0162:             */
0163:            final private long getTransactionId() throws IOException,
0164:                    SQLException {
0165:                return getSession().getTransactionId();
0166:            }
0167:
0168:            /**
0169:             * Return the current cursor row.
0170:             */
0171:            final Row getCursorRow() throws SQLException {
0172:                if (onInsertRow) {
0173:                    if (insertRow == null) {
0174:                        insertRow = new Row(cursor.getColumnCount());
0175:                        for (int i = 1; i <= insertRow.size(); i++) {
0176:                            insertRow.set(i, ValueNull.valueNull);
0177:                        }
0178:                    }
0179:                    return insertRow;
0180:                } else if (onUpdateRow) {
0181:                    if (insertRow == null) {
0182:                        insertRow = new Row(cursor.getColumnCount());
0183:                        for (int i = 1; i < insertRow.size(); i++) {
0184:                            insertRow.set(i, row.item(i));
0185:                        }
0186:                    }
0187:                    return insertRow;
0188:                } else {
0189:                    if (row == null) {
0190:                        row = cursor.getRow();
0191:                        //#ifdef DEBUG
0192:                        if (trace.bit(2)) {
0193:                            Debug.println("cursor.getRow: " + row);
0194:                        }
0195:                        //#endif
0196:                    }
0197:                    return row;
0198:                }
0199:            }
0200:
0201:            /**
0202:             * Return the value in the specified column.
0203:             */
0204:            Value getValue(int col) throws SQLException {
0205:                Value v = null;
0206:                Row r = getCursorRow();
0207:                if (r != null) {
0208:                    v = r.item(col);
0209:                    if (v != null) {
0210:                        wasNull = Value.isNull(v);
0211:                    } else {
0212:                        throw new SQLException("Can't return column " + col);
0213:                    }
0214:                } else {
0215:                    throw new SQLException(
0216:                            "ResultSet isn't positioned on a valid row");
0217:                }
0218:                return v;
0219:            }
0220:
0221:            /**
0222:             * Convert the value in the specified column to the given type.
0223:             */
0224:            final Value getValue(int col, Type type) throws SQLException {
0225:                return type.convert(getValue(col));
0226:            }
0227:
0228:            /**
0229:             * Return the value in the specified column as a Java "Object"
0230:             * after performing the indicated type conversion.
0231:             */
0232:            public Object getObject(int col, Type type) throws SQLException {
0233:                Value v = getValue(col, type);
0234:                //#ifdef DEBUG
0235:                if (trace.bit(3)) {
0236:                    Debug.println("get(" + col + ", " + type.getTypeName()
0237:                            + ") = " + v);
0238:                }
0239:                //#endif
0240:                return v.asJavaObject();
0241:            }
0242:
0243:            //------------------------------------------------------------------
0244:            // java.sql.ResultSet implementation
0245:            //------------------------------------------------------------------
0246:
0247:            /**
0248:             * Position the resultset to the specified row.  If positive, the
0249:             * row number indicates an offset from the beginning of the 
0250:             * <code>ResultSet</code> (row 1 is the first row).  If negative,
0251:             * the row number indicates an offset from the end of the
0252:             * <code>ResultSet</code> (row -1 is the last row).
0253:             * <p>
0254:             * In general, this release of QED supports absolute positioning 
0255:             * to the first row of the <code>ResultSet</code> only.
0256:             *
0257:             * @param row the row number
0258:             * @return true if we're positioned on a valid row, false if we're
0259:             *  before the first row or after the last row.
0260:             * @exception SQLException if row is zero.
0261:             */
0262:            public boolean absolute(int x) throws SQLException {
0263:                checkScrollable();
0264:                //#ifdef DEBUG
0265:                if (trace.bit(0)) {
0266:                    Debug.println("ResultSet.absolute(" + x + ")");
0267:                    //Debug.println("cursor: " + cursor.getClass() + ": " + cursor);
0268:                }
0269:                //#endif
0270:                if (x == 0) {
0271:                    throw new SQLException(
0272:                            "ResultSet.absolute(0), bad parameter");
0273:                }
0274:                rowNum = x;
0275:                resetRow();
0276:                bf = false;
0277:                return cursor.absolute(rowNum);
0278:            }
0279:
0280:            private final void resetRow() {
0281:                onInsertRow = false;
0282:                onUpdateRow = false;
0283:                row = null;
0284:                rowUpdated = false;
0285:                rowDeleted = false;
0286:            }
0287:
0288:            /**
0289:             * Position the cursor to the end of the <code>ResultSet</code>,
0290:             * after the last row.  Our underlying cursor doesn't support this
0291:             * operation, so we use 'absolute()' to get to the end, then 'next()'
0292:             * to move past the end.
0293:             *
0294:             * @exception SQLException may be thrown.
0295:             */
0296:            public void afterLast() throws SQLException {
0297:                checkScrollable();
0298:                cursor.afterLast();
0299:                resetRow();
0300:                bf = false;
0301:            }
0302:
0303:            /**
0304:             * Position the cursor to the beginning of the <code>ResultSet</code>,
0305:             * before the first row.
0306:             *
0307:             * @exception SQLException may be thrown.
0308:             */
0309:            public void beforeFirst() throws SQLException {
0310:                checkScrollable();
0311:                cursor.beforeFirst();
0312:                resetRow();
0313:                bf = true;
0314:            }
0315:
0316:            /**
0317:             * This function rolls back row updates, as long as
0318:             * <code>updateRow()</code> hasn't been called yet.  
0319:             *
0320:             * @exception SQLException may be thrown
0321:             */
0322:            public void cancelRowUpdates() throws SQLException {
0323:                if (onInsertRow) {
0324:                    throw new SQLException(
0325:                            "ResultSet.cancelRowUpdates() called "
0326:                                    + "while on insert row");
0327:                }
0328:                resetRow();
0329:            }
0330:
0331:            /**
0332:             * Clears all warnings that have been reported on this
0333:             * <code>ResultSet</code> object.
0334:             * QED doesn't currently throw any SQLWarnings,
0335:             * so this operation does nothing.
0336:             */
0337:            public void clearWarnings() throws SQLException {
0338:            }
0339:
0340:            /**
0341:             * We will clean up the user's mess for him.
0342:             */
0343:            public void finalize() throws Throwable {
0344:                try {
0345:                    if (cursor != null)
0346:                        close();
0347:                } catch (Throwable t) {
0348:                }
0349:                super .finalize();
0350:            }
0351:
0352:            /**
0353:             * Close this <code>ResultSet</code> object.  If this is an
0354:             * updatable <code>ResultSet</code>, and the connection that this
0355:             * <code>ResultSet</code> was created from is in <code>autoCommit</code>
0356:             * mode, the transaction is committed at this time.
0357:             *
0358:             * @exception SQLException may be thrown
0359:             */
0360:            public void close() throws SQLException {
0361:                if (cursor == null)
0362:                    return;
0363:
0364:                Session s = cursor.getSession();
0365:
0366:                synchronized (lock) {
0367:                    cursor = null;
0368:                    if (s != null) {
0369:                        try {
0370:                            s.endStatement(false);
0371:                        } catch (IOException e) {
0372:                            throw new SQLException(e.toString());
0373:                        }
0374:                    }
0375:                }
0376:            }
0377:
0378:            /**
0379:             * Delete the current row from the <code>ResultSet</code> and the
0380:             * underlying database.
0381:             *
0382:             * @exception SQLException may be thrown
0383:             */
0384:            public void deleteRow() throws SQLException {
0385:                //#ifdef DEBUG
0386:                if (trace.bit(0)) {
0387:                    Debug.println("ResultSet.deleteRow()");
0388:                }
0389:                //#endif
0390:                checkUpdatable();
0391:                if (onInsertRow) {
0392:                    throw new SQLException(
0393:                            "ResultSet.deleteRow(): Can't delete while on insert row");
0394:                }
0395:                cursor.deleteRow();
0396:                rowDeleted = true;
0397:            }
0398:
0399:            /**
0400:             * Return the column number of the specified column. 
0401:             *
0402:             * @param column the name of the column
0403:             * @return the number of the column in the resultset.
0404:             */
0405:            public int findColumn(String column) throws SQLException {
0406:                Column col = cursor.getColumn(column.toUpperCase());
0407:                if (col == null) {
0408:                    //#ifdef DEBUG
0409:                    SelectExpression.showCursor(cursor, true);
0410:                    //#endif
0411:                    throw new SQLException("Bad column name: " + column,
0412:                            "42000");
0413:                }
0414:                int coln = col.getColumn();
0415:                //#ifdef DEBUG
0416:                if (trace.bit(1)) {
0417:                    Debug.println("ResultSet.findColumn(" + column + ") = "
0418:                            + coln);
0419:                }
0420:                //#endif
0421:                return coln;
0422:            }
0423:
0424:            /**
0425:             * Position the cursor on the first row of the <code>ResultSet</code>.
0426:             * Return true if the <code>ResultSet</code> has at least one row.
0427:             *
0428:             *
0429:             * @exception SQLException may be thrown
0430:             */
0431:            public boolean first() throws SQLException {
0432:                return absolute(1);
0433:            }
0434:
0435:            /**
0436:             * Return an <code>InputStream</code> object that can be used to read
0437:             * the specified character value as a stream of ASCII bytes.
0438:             *
0439:             * @param col the column number
0440:             * @return an <code>InputStream</code>
0441:             * @exception SQLException may be thrown
0442:             */
0443:            public InputStream getAsciiStream(int col) throws SQLException {
0444:                Value v = getValue(col);
0445:                if (Value.isNull(v))
0446:                    return null;
0447:                return new AsciiInputStream(getCharacterStream(col));
0448:            }
0449:
0450:            /**
0451:             * Return an <code>InputStream</code> object that can be used to read
0452:             * the specified character value as a stream of ASCII bytes.
0453:             *
0454:             * @param column the column name
0455:             * @return an <code>InputStream</code>
0456:             * @exception SQLException may be thrown
0457:             */
0458:            public InputStream getAsciiStream(String column)
0459:                    throws SQLException {
0460:                return getAsciiStream(findColumn(column));
0461:            }
0462:
0463:            /**
0464:             * Retrieve the specified column as a <code>BigDecimal</code> object.
0465:             *
0466:             * @param col the column number
0467:             * @return the column's value in the current row
0468:             * @exception SQLException may be thrown
0469:             */
0470:            public BigDecimal getBigDecimal(int col) throws SQLException {
0471:                try {
0472:                    ValueScaledInteger v = (ValueScaledInteger) getValue(col,
0473:                            TypeDecimal.typeDecimal);
0474:                    if (v != null)
0475:                        return v.bigDecimalValue();
0476:                } catch (ClassCastException e) {
0477:                    if (wasNull)
0478:                        return null;
0479:                }
0480:                throw new SQLException("Can't return column " + col
0481:                        + " as BigDecimal", "22003");
0482:            }
0483:
0484:            /**
0485:             * @deprecated
0486:             */
0487:            public BigDecimal getBigDecimal(int col, int scale)
0488:                    throws SQLException {
0489:                BigDecimal big = getBigDecimal(col);
0490:                return big.setScale(scale);
0491:            }
0492:
0493:            /**
0494:             * Retrieve the specified column as a <code>BigDecimal</code> object.
0495:             *
0496:             * @param column the column name
0497:             * @return the column's value in the current row
0498:             * @exception SQLException may be thrown
0499:             */
0500:            public BigDecimal getBigDecimal(String column) throws SQLException {
0501:                return getBigDecimal(findColumn(column));
0502:            }
0503:
0504:            /**
0505:             * @deprecated
0506:             */
0507:            public BigDecimal getBigDecimal(String column, int scale)
0508:                    throws SQLException {
0509:                return getBigDecimal(findColumn(column), scale);
0510:            }
0511:
0512:            /**
0513:             * Return an <code>InputStream</code> object that can be used to read
0514:             * the specified column value as a stream of bytes.
0515:             *
0516:             * @param col the column number
0517:             * @return an <code>InputStream</code>
0518:             * @exception SQLException may be thrown
0519:             */
0520:            public InputStream getBinaryStream(int col) throws SQLException {
0521:                try {
0522:                    Value v = getValue(col);
0523:                    if (Value.isNull(v))
0524:                        return null;
0525:                    int type = v.getType().getJDBCType();
0526:                    switch (type) {
0527:                    case Types.CHAR:
0528:                    case Types.VARCHAR:
0529:                        return ((ValueString) v).getBinaryStream();
0530:                    case Types.BINARY:
0531:                    case Types.VARBINARY:
0532:                        return ((ValueOctets) v).getBinaryStream();
0533:                        //-//#ifdef JDK11
0534:                        //-         case Type.BLOB:
0535:                        //#else
0536:                    case Types.BLOB:
0537:                        //#endif
0538:                        return ((ValueBlob) v).getBinaryStream();
0539:                        //-//#ifdef JDK11
0540:                        //-         case Type.CLOB:
0541:                        //#else
0542:                    case Types.CLOB:
0543:                        //#endif
0544:                        return ((ValueClob) v).getBinaryStream();
0545:                    default:
0546:                        throw new ValueException("Can't convert: " + type
0547:                                + " to binary stream");
0548:                    }
0549:                } catch (ValueException e) {
0550:                    throw new SQLException("Can't return column " + col
0551:                            + " as Binary Stream", "22003");
0552:                }
0553:            }
0554:
0555:            /**
0556:             * Return an <code>InputStream</code> object that can be used to read
0557:             * the specified column value as a stream of bytes.
0558:             *
0559:             * @param column the column name
0560:             * @return an <code>InputStream</code>
0561:             * @exception SQLException may be thrown
0562:             */
0563:            public InputStream getBinaryStream(String column)
0564:                    throws SQLException {
0565:                return getBinaryStream(findColumn(column));
0566:            }
0567:
0568:            /**
0569:             * Retrieve the specified column as a <code>boolean</code>.
0570:             *
0571:             * @param col the column number
0572:             * @return the column's value in the current row
0573:             * @exception SQLException may be thrown
0574:             */
0575:            public boolean getBoolean(int col) throws SQLException {
0576:                Object obj = getObject(col);
0577:                if (obj == null)
0578:                    return false;
0579:                if (obj instanceof  Boolean) {
0580:                    return ((Boolean) obj).booleanValue();
0581:                }
0582:                Number num = asNumber(obj);
0583:                if (num != null) {
0584:                    return num.doubleValue() != 0;
0585:                }
0586:                return obj.toString().toLowerCase().equals("true");
0587:            }
0588:
0589:            /**
0590:             * Retrieve the specified column as a <code>boolean</code>.
0591:             *
0592:             * @param column the column name
0593:             * @return the column's value in the current row
0594:             * @exception SQLException may be thrown
0595:             */
0596:            public boolean getBoolean(String column) throws SQLException {
0597:                return getBoolean(findColumn(column));
0598:            }
0599:
0600:            /**
0601:             * Are you a number?
0602:             *
0603:             * Any sort of number?
0604:             *
0605:             * Even some fancy schmancy number?
0606:             *
0607:             * Are you?
0608:             *
0609:             * Or not.
0610:             */
0611:            final Number asNumber(Object obj) {
0612:                if (obj instanceof  Number)
0613:                    return (Number) obj;
0614:                if (obj instanceof  String) {
0615:                    try {
0616:                        return new Long(obj.toString());
0617:                    } catch (NumberFormatException e) {
0618:                    }
0619:                }
0620:                if (obj instanceof  byte[]) {
0621:                    return new BigDecimal(new BigInteger((byte[]) obj));
0622:                }
0623:                if (obj instanceof  Boolean) {
0624:                    int val = ((Boolean) obj).booleanValue() ? 1 : 0;
0625:                    return new Integer(val);
0626:                }
0627:                return null;
0628:            }
0629:
0630:            /**
0631:             * Retrieve the specified column as a <code>byte</code>.
0632:             *
0633:             * @param col the column number
0634:             * @return the column's value in the current row
0635:             * @exception SQLException may be thrown
0636:             */
0637:            public byte getByte(int col) throws SQLException {
0638:                try {
0639:                    ValueByte v = (ValueByte) getValue(col,
0640:                            TypeTinyInt.typeTinyInt);
0641:                    if (v != null)
0642:                        return v.byteValue();
0643:                } catch (ClassCastException e) {
0644:                    if (wasNull)
0645:                        return 0;
0646:                }
0647:                throw new SQLException("Can't return column " + col
0648:                        + " as byte", "22003");
0649:            }
0650:
0651:            /**
0652:             * Retrieve the specified column as a <code>byte</code>.
0653:             *
0654:             * @param column the column name
0655:             * @return the column's value in the current row
0656:             * @exception SQLException may be thrown
0657:             */
0658:            public byte getByte(String column) throws SQLException {
0659:                return getByte(findColumn(column));
0660:            }
0661:
0662:            /**
0663:             * Retrieve the specified column as an array of <code>byte</code>s.
0664:             *
0665:             * @param col the column number
0666:             * @return the column's value in the current row
0667:             * @exception SQLException may be thrown
0668:             */
0669:            public byte[] getBytes(int col) throws SQLException {
0670:                try {
0671:                    Value v1 = getValue(col, TypeVarBinary.typeVarBinary);
0672:                    if (wasNull)
0673:                        return null;
0674:                    ValueOctets v = (ValueOctets) v1;
0675:                    return v.getBytes();
0676:                } catch (Exception e) {
0677:                    throw new SQLException("Can't return column " + col
0678:                            + " as bytes", "22003");
0679:                }
0680:            }
0681:
0682:            /**
0683:             * Retrieve the specified column as an array of <code>byte</code>s.
0684:             *
0685:             * @param column the column name
0686:             * @return the column's value in the current row
0687:             * @exception SQLException may be thrown
0688:             */
0689:            public byte[] getBytes(String column) throws SQLException {
0690:                return getBytes(findColumn(column));
0691:            }
0692:
0693:            /**
0694:             * Return a <code>Reader</code> object that can be used to read
0695:             * the specified column value as a stream of characters.
0696:             *
0697:             * @param col the column number
0698:             * @return a <code>Reader</code>
0699:             * @exception SQLException may be thrown
0700:             */
0701:            public Reader getCharacterStream(int col) throws SQLException {
0702:                try {
0703:                    Value v = getValue(col);
0704:                    if (Value.isNull(v))
0705:                        return null;
0706:                    int type = v.getType().getJDBCType();
0707:                    switch (type) {
0708:                    case Types.CHAR:
0709:                    case Types.VARCHAR:
0710:                        return ((ValueString) v).getCharacterStream();
0711:                    case Types.BINARY:
0712:                    case Types.VARBINARY:
0713:                        return new ByteReader(((ValueOctets) v)
0714:                                .getBinaryStream());
0715:                    case Types.BLOB:
0716:                        return new ByteReader(((ValueBlob) v).getBinaryStream());
0717:                    case Types.CLOB:
0718:                        return ((ValueClob) v).getCharacterStream();
0719:                    default:
0720:                        throw new ValueException("Can't convert: " + type
0721:                                + " to character stream");
0722:                    }
0723:                } catch (ValueException e) {
0724:                    throw new SQLException("Can't return column " + col
0725:                            + " as character stream", "22003");
0726:                }
0727:
0728:            }
0729:
0730:            /**
0731:             * Return a <code>Reader</code> object that can be used to read
0732:             * the specified column value as a stream of characters.
0733:             *
0734:             * @param column the column name
0735:             * @return a <code>Reader</code>
0736:             * @exception SQLException may be thrown
0737:             */
0738:            public Reader getCharacterStream(String column) throws SQLException {
0739:                return getCharacterStream(findColumn(column));
0740:            }
0741:
0742:            /**
0743:             * QED doesn't support named cursors, so this method throws a
0744:             * SQLException "not implemented"
0745:             *
0746:             * @return never
0747:             * @exception SQLException not implemented
0748:             */
0749:            public String getCursorName() throws SQLException {
0750:                throw new SQLException("named cursors not supported", "0A000");
0751:            }
0752:
0753:            /**
0754:             * Retrieve the specified column as a <code>Date</code> object.
0755:             *
0756:             * @param col the column number
0757:             * @return the column's value in the current row
0758:             * @exception SQLException may be thrown
0759:             */
0760:            public Date getDate(int col) throws SQLException {
0761:                Date d = null;
0762:                Value v = getValue(col);
0763:                if (!Value.isNull(v)) {
0764:                    try {
0765:                        ValueDate vd = (ValueDate) v.convert(TypeDate.typeDate);
0766:                        d = new Date(vd.getTime());
0767:                    } catch (Exception e) {
0768:                        throw new SQLException("Can't convert column " + col
0769:                                + " to date", "22003");
0770:                    }
0771:                }
0772:                return d;
0773:            }
0774:
0775:            /**
0776:             * Retrieve the specified column as a <code>Date</code> object.
0777:             *
0778:             * @param col the column number
0779:             * @param c a <code>Calendar<code> object that is used for converting
0780:             *  the database date to the local timezone.  The database date is
0781:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
0782:             * @return the column's value in the current row
0783:             * @exception SQLException may be thrown
0784:             */
0785:            public Date getDate(int col, Calendar c) throws SQLException {
0786:                Date d = getDate(col);
0787:                if (d != null) {
0788:                    long t = d.getTime();
0789:                    c.setTime(d);
0790:                    t += (c.get(Calendar.ZONE_OFFSET) + c
0791:                            .get(Calendar.DST_OFFSET));
0792:                    d = new Date(t);
0793:                }
0794:                return d;
0795:            }
0796:
0797:            /**
0798:             * Retrieve the specified column as a <code>Date</code> object.
0799:             *
0800:             * @param column the column name
0801:             * @return the column's value in the current row
0802:             * @exception SQLException may be thrown
0803:             */
0804:            public Date getDate(String column) throws SQLException {
0805:                return getDate(findColumn(column));
0806:            }
0807:
0808:            /**
0809:             * Retrieve the specified column as a <code>Date</code> object.
0810:             *
0811:             * @param column the column name
0812:             * @param c a <code>Calendar<code> object that is used for converting
0813:             *  the database date to the local timezone.  The database date is
0814:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
0815:             * @return the column's value in the current row
0816:             * @exception SQLException may be thrown
0817:             */
0818:            public Date getDate(String column, Calendar c) throws SQLException {
0819:                return getDate(findColumn(column), c);
0820:            }
0821:
0822:            /**
0823:             * Retrieve the specified column as a <code>double</code>.
0824:             *
0825:             * @param col the column number
0826:             * @return the column's value in the current row
0827:             * @exception SQLException may be thrown
0828:             */
0829:            public double getDouble(int col) throws SQLException {
0830:                try {
0831:                    ValueDouble v = (ValueDouble) getValue(col,
0832:                            TypeReal.typeDouble);
0833:                    if (v != null)
0834:                        return v.doubleValue();
0835:                } catch (ClassCastException e) {
0836:                    if (wasNull)
0837:                        return 0;
0838:                }
0839:                throw new SQLException("Can't return column " + col
0840:                        + " as double", "22003");
0841:            }
0842:
0843:            /**
0844:             * Retrieve the specified column as a <code>double</code>.
0845:             *
0846:             * @param column the column name
0847:             * @return the column's value in the current row
0848:             * @exception SQLException may be thrown
0849:             */
0850:            public double getDouble(String column) throws SQLException {
0851:                return getDouble(findColumn(column));
0852:            }
0853:
0854:            /**
0855:             * QED, being an embedded driver, fetches rows only when they are
0856:             * needed, with no performance penalty.  Thus, the fetch size is
0857:             * always <code>one</code>.
0858:             *
0859:             * @return one.
0860:             */
0861:            public int getFetchSize() {
0862:                return 1;
0863:            }
0864:
0865:            /**
0866:             * Retrieve the specified column as a <code>float</code>.
0867:             *
0868:             * @param col the column number
0869:             * @return the column's value in the current row
0870:             * @exception SQLException may be thrown
0871:             */
0872:            public float getFloat(int col) throws SQLException {
0873:                try {
0874:                    ValueFloat v = (ValueFloat) getValue(col,
0875:                            TypeReal.typeFloat);
0876:                    if (v != null)
0877:                        return v.floatValue();
0878:                } catch (ClassCastException e) {
0879:                    if (wasNull)
0880:                        return 0;
0881:                }
0882:                throw new SQLException("Can't return column " + col
0883:                        + " as float", "22003");
0884:            }
0885:
0886:            /**
0887:             * Retrieve the specified column as a <code>float</code>.
0888:             *
0889:             * @param column the column name
0890:             * @return the column's value in the current row
0891:             * @exception SQLException may be thrown
0892:             */
0893:            public float getFloat(String column) throws SQLException {
0894:                return getFloat(findColumn(column));
0895:            }
0896:
0897:            /**
0898:             * Retrieve the specified column as an <code>int</code>.
0899:             *
0900:             * @param col the column number
0901:             * @return the column's value in the current row
0902:             * @exception SQLException may be thrown
0903:             */
0904:            public int getInt(int col) throws SQLException {
0905:                try {
0906:                    ValueInteger v = (ValueInteger) getValue(col,
0907:                            TypeInt.typeInt);
0908:                    if (v != null)
0909:                        return v.intValue();
0910:                } catch (ClassCastException e) {
0911:                    if (wasNull)
0912:                        return 0;
0913:                }
0914:                throw new SQLException(
0915:                        "Can't return column " + col + " as int", "22003");
0916:            }
0917:
0918:            /**
0919:             * Retrieve the specified column as an <code>int</code>.
0920:             *
0921:             * @param column the column name
0922:             * @return the column's value in the current row
0923:             * @exception SQLException may be thrown
0924:             */
0925:            public int getInt(String column) throws SQLException {
0926:                return getInt(findColumn(column));
0927:            }
0928:
0929:            /**
0930:             * Retrieve the specified column as a <code>long</code>.
0931:             *
0932:             * @param col the column number
0933:             * @return the column's value in the current row
0934:             * @exception SQLException may be thrown
0935:             */
0936:            public long getLong(int col) throws SQLException {
0937:                try {
0938:                    ValueLong v = (ValueLong) getValue(col,
0939:                            TypeBigInt.typeBigInt);
0940:                    if (v != null)
0941:                        return v.longValue();
0942:                } catch (ClassCastException e) {
0943:                    if (wasNull)
0944:                        return 0;
0945:                }
0946:                throw new SQLException("Can't return column " + col
0947:                        + " as long", "22003");
0948:            }
0949:
0950:            /**
0951:             * Retrieve the specified column as a <code>long</code>.
0952:             *
0953:             * @param column the column name
0954:             * @return the column's value in the current row
0955:             * @exception SQLException may be thrown
0956:             */
0957:            public long getLong(String column) throws SQLException {
0958:                return getLong(findColumn(column));
0959:            }
0960:
0961:            /**
0962:             * Return a <code>ResultSetMetaData</code> object that can be used
0963:             * to obtain information about the columns of this 
0964:             * <code>ResultSet</code>.
0965:             *
0966:             * @return a <code>ResultSetMetaData</code> object that describes
0967:             *  the columns of this <code>ResultSet</code>.
0968:             * @exception SQLException may be thrown
0969:             */
0970:            public java.sql.ResultSetMetaData getMetaData() throws SQLException {
0971:                return new ResultSetMetaData(cursor);
0972:            }
0973:
0974:            /**
0975:             * Retrieve the specified column as a Java <code>Object</code>. 
0976:             * The type of the object is based on the underlying SQL datatype,
0977:             * using the conversions as specified by JDBC.
0978:             *
0979:             * @param col the column number
0980:             * @return the column's value in the current row
0981:             * @exception SQLException may be thrown
0982:             */
0983:            public Object getObject(int col) throws SQLException {
0984:                try {
0985:                    Value v = getValue(col);
0986:                    //#ifdef DEBUG
0987:                    if (trace.bit(3)) {
0988:                        Debug.println("get(" + col + ") = " + v);
0989:                    }
0990:                    //#endif
0991:                    return v.asJavaObject();
0992:                } catch (SQLException e) {
0993:                    throw e;
0994:                } catch (Exception ex) {
0995:                    Debug.print(ex);
0996:                    throw new SQLException("Invalid column index: " + col,
0997:                            "22003");
0998:                }
0999:            }
1000:
1001:            /**
1002:             * Retrieve the specified column as a Java <code>Object</code>. 
1003:             * The type of the object is based on the underlying SQL datatype,
1004:             * using the conversions as specified by JDBC.
1005:             *
1006:             * @param column the column name
1007:             * @return the column's value in the current row
1008:             * @exception SQLException may be thrown
1009:             */
1010:            public Object getObject(String column) throws SQLException {
1011:                return getObject(findColumn(column));
1012:            }
1013:
1014:            /**
1015:             * Return the row number of the current row in the
1016:             * <code>ResultSet</code>.
1017:             */
1018:            public int getRow() throws SQLException {
1019:                if (rowNum < 0) {
1020:                    int siz = (int) cursor.size();
1021:                    if (siz >= 0) {
1022:                        rowNum = siz + 1 + rowNum;
1023:                    } else {
1024:                        throw new SQLException(
1025:                                "Sorry, but the underlying cursor ("
1026:                                        + cursor
1027:                                        + ") doesn't supply row number information");
1028:                    }
1029:                }
1030:                return rowNum;
1031:            }
1032:
1033:            /**
1034:             * Retrieve the specified column as a <code>short</code>.
1035:             *
1036:             * @param col the column number
1037:             * @return the column's value in the current row
1038:             * @exception SQLException may be thrown
1039:             */
1040:            public short getShort(int col) throws SQLException {
1041:                try {
1042:                    ValueShort v = (ValueShort) getValue(col,
1043:                            TypeSmallInt.typeSmallInt);
1044:                    if (v != null)
1045:                        return v.shortValue();
1046:                } catch (ClassCastException e) {
1047:                    if (wasNull)
1048:                        return 0;
1049:                }
1050:                throw new SQLException("Can't return column " + col
1051:                        + " as short", "22003");
1052:            }
1053:
1054:            /**
1055:             * Retrieve the specified column as a <code>short</code>.
1056:             *
1057:             * @param column the column name
1058:             * @return the column's value in the current row
1059:             * @exception SQLException may be thrown
1060:             */
1061:            public short getShort(String column) throws SQLException {
1062:                return getShort(findColumn(column));
1063:            }
1064:
1065:            /**
1066:             * Attach this result set to its parent statement.
1067:             */
1068:            public void setStatement(java.sql.Statement stmt) {
1069:                this .stmt = (Statement) stmt;
1070:                this .resultSetType = this .stmt.resultSetType;
1071:                this .resultSetConcurrency = this .stmt.resultSetConcurrency;
1072:            }
1073:
1074:            /**
1075:             * Return the <code>Statement</code> object that generated this
1076:             * <code>ResultSet</code>.
1077:             *
1078:             * @return the <code>Statement</code> object that generated this
1079:             *     <code>ResultSet</code>
1080:             */
1081:            public java.sql.Statement getStatement() {
1082:                return stmt;
1083:            }
1084:
1085:            /**
1086:             * Retrieve the specified column as a <code>String</code> object.
1087:             *
1088:             * @param col the column number
1089:             * @return the column's value in the current row
1090:             * @exception SQLException may be thrown
1091:             */
1092:            public String getString(int col) throws SQLException {
1093:                Object obj = getObject(col, TypeVarChar.typeVarChar);
1094:                if (obj == null)
1095:                    return null;
1096:                return obj.toString();
1097:            }
1098:
1099:            /**
1100:             * Retrieve the specified column as a <code>String</code> object.
1101:             *
1102:             * @param column the column name
1103:             * @return the column's value in the current row
1104:             * @exception SQLException may be thrown
1105:             */
1106:            public String getString(String column) throws SQLException {
1107:                return getString(findColumn(column));
1108:            }
1109:
1110:            /**
1111:             * Retrieve the specified column as a <code>Time</code> object.
1112:             *
1113:             * @param col the column number
1114:             * @return the column's value in the current row
1115:             * @exception SQLException may be thrown
1116:             */
1117:            public Time getTime(int col) throws SQLException {
1118:                Time t = null;
1119:                Value v = getValue(col);
1120:                if (!Value.isNull(v)) {
1121:                    try {
1122:                        ValueTime vt = (ValueTime) v.convert(TypeTime.typeTime);
1123:                        t = new Time(vt.getTime());
1124:                    } catch (Exception e) {
1125:                        throw new SQLException("Can't convert column " + col
1126:                                + " to time", "22003");
1127:                    }
1128:                }
1129:                return t;
1130:            }
1131:
1132:            /**
1133:             * Retrieve the specified column as a <code>Time</code> object.
1134:             *
1135:             * @param col the column number
1136:             * @param c a <code>Calendar<code> object that is used for converting
1137:             *  the database time to the local timezone.  The database time is
1138:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
1139:             * @return the column's value in the current row
1140:             * @exception SQLException may be thrown
1141:             */
1142:            public Time getTime(int col, Calendar c) throws SQLException {
1143:                Time d = getTime(col);
1144:                if (d != null) {
1145:                    long t = d.getTime();
1146:                    c.setTime(d);
1147:                    t += (c.get(Calendar.ZONE_OFFSET) + c
1148:                            .get(Calendar.DST_OFFSET));
1149:                    d = new Time(t);
1150:                }
1151:                return d;
1152:            }
1153:
1154:            /**
1155:             * Retrieve the specified column as a <code>Time</code> object.
1156:             *
1157:             * @param column the column name
1158:             * @return the column's value in the current row
1159:             * @exception SQLException may be thrown
1160:             */
1161:            public Time getTime(String column) throws SQLException {
1162:                return getTime(findColumn(column));
1163:            }
1164:
1165:            /**
1166:             * Retrieve the specified column as a <code>Time</code> object.
1167:             *
1168:             * @param column the column name
1169:             * @param c a <code>Calendar<code> object that is used for converting
1170:             *  the database time to the local timezone.  The database time is
1171:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
1172:             * @return the column's value in the current row
1173:             * @exception SQLException may be thrown
1174:             */
1175:            public Time getTime(String column, Calendar c) throws SQLException {
1176:                return getTime(findColumn(column));
1177:            }
1178:
1179:            /**
1180:             * Retrieve the specified column as a <code>Timestamp</code> object.
1181:             *
1182:             * @param col the column number
1183:             * @return the column's value in the current row
1184:             * @exception SQLException may be thrown
1185:             */
1186:            public Timestamp getTimestamp(int col) throws SQLException {
1187:                Timestamp t = null;
1188:                Value v = getValue(col, TypeTimestamp.typeTimestamp);
1189:                if (!wasNull) {
1190:                    try {
1191:                        ValueTimestamp vt = (ValueTimestamp) v;
1192:                        t = new Timestamp(vt.getTime());
1193:                    } catch (ClassCastException e) {
1194:                        throw new SQLException("Can't convert column " + col
1195:                                + " to timestamp", "22003");
1196:                    }
1197:                }
1198:                return t;
1199:            }
1200:
1201:            /**
1202:             * Retrieve the specified column as a <code>Timestamp</code> object.
1203:             *
1204:             * @param col the column number
1205:             * @param c a <code>Calendar<code> object that is used for converting
1206:             *  the database time to the local timezone.  The database time is
1207:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
1208:             * @return the column's value in the current row
1209:             * @exception SQLException may be thrown
1210:             */
1211:            public Timestamp getTimestamp(int col, Calendar c)
1212:                    throws SQLException {
1213:                Timestamp d = getTimestamp(col);
1214:                if (d != null) {
1215:                    long t = d.getTime();
1216:                    c.setTime(d);
1217:                    t += (c.get(Calendar.ZONE_OFFSET) + c
1218:                            .get(Calendar.DST_OFFSET));
1219:                    Timestamp r = new Timestamp(t);
1220:                    r.setNanos(d.getNanos());
1221:                    d = r;
1222:                }
1223:                return d;
1224:            }
1225:
1226:            /**
1227:             * Retrieve the specified column as a <code>Timestamp</code> object.
1228:             *
1229:             * @param column the column name
1230:             * @return the column's value in the current row
1231:             * @exception SQLException may be thrown
1232:             */
1233:            public Timestamp getTimestamp(String column) throws SQLException {
1234:                return getTimestamp(findColumn(column));
1235:            }
1236:
1237:            /**
1238:             * Retrieve the specified column as a <code>Timestamp</code> object.
1239:             *
1240:             * @param column the column name
1241:             * @param c a <code>Calendar<code> object that is used for converting
1242:             *  the database time to the local timezone.  The database time is
1243:             *  adjusted based on the <code>Calendar</code> timezone and DST offset.
1244:             * @return the column's value in the current row
1245:             * @exception SQLException may be thrown
1246:             */
1247:            public Timestamp getTimestamp(String column, Calendar c)
1248:                    throws SQLException {
1249:                return getTimestamp(findColumn(column), c);
1250:            }
1251:
1252:            /**
1253:             * @deprecated
1254:             */
1255:            public InputStream getUnicodeStream(int col) throws SQLException {
1256:                return getBinaryStream(col);
1257:            }
1258:
1259:            /**
1260:             * @deprecated
1261:             */
1262:            public InputStream getUnicodeStream(String column)
1263:                    throws SQLException {
1264:                return getBinaryStream(column);
1265:            }
1266:
1267:            /**
1268:             * QED doesn't implement any <code>SQLWarning</code>s, so this
1269:             * function always returns <code>null</code>
1270:             *
1271:             * @return null
1272:             */
1273:            public SQLWarning getWarnings() {
1274:                return null;
1275:            }
1276:
1277:            /**
1278:             * If this <code>ResultSet</code> is currently positioned on the
1279:             * insert row, then insert the current row into the database.
1280:             *
1281:             * @exception SQLException may be thrown if we're not currently
1282:             *   on the insert row, or if there is an error reported from the
1283:             *   database for the insert operation
1284:             */
1285:            public void insertRow() throws SQLException {
1286:                //#ifdef DEBUG
1287:                if (trace.bit(0)) {
1288:                    Debug.println("ResultSet.insertRow()");
1289:                }
1290:                //#endif
1291:                checkUpdatable();
1292:                if (onInsertRow && insertRow != null) {
1293:                    cursor.insertRow(insertRow);
1294:                    rowUpdated = true;
1295:                } else {
1296:                    throw new SQLException("Can't insert -- no insert row");
1297:                }
1298:            }
1299:
1300:            /**
1301:             * Update the current row (based on previous calls to the
1302:             * <code>updateXXX</code> methods) in the database.
1303:             *
1304:             * @exception SQLException may be thrown if we're currently
1305:             *   on the insert row, or if there is an error reported from the
1306:             *   database for the update operation
1307:             */
1308:            public void updateRow() throws SQLException {
1309:                //#ifdef DEBUG
1310:                if (trace.bit(0)) {
1311:                    Debug.println("ResultSet.updateRow()");
1312:                }
1313:                //#endif
1314:                checkUpdatable();
1315:                if (onInsertRow) {
1316:                    throw new SQLException(
1317:                            "updateRow(): Can't update while on insert row");
1318:                }
1319:                Row rowX = onUpdateRow ? insertRow : row;
1320:                if (rowX != null) {
1321:                    cursor.getSession().clearViewCheck();
1322:                    cursor.updateRow(rowX);
1323:                    rowUpdated = true;
1324:                }
1325:            }
1326:
1327:            /**
1328:             * Return <b>true</b> if this cursor is positioned after the
1329:             * last row.
1330:             *
1331:             * @exception SQLException may be thrown
1332:             */
1333:            public boolean isAfterLast() throws SQLException {
1334:                checkScrollable();
1335:                return !onInsertRow && rowNum == 0 && !bf;
1336:            }
1337:
1338:            /**
1339:             * Return <b>true</b> if this cursor is positioned before the
1340:             * first row.
1341:             *
1342:             * @exception SQLException may be thrown
1343:             */
1344:            public boolean isBeforeFirst() throws SQLException {
1345:                checkScrollable();
1346:                return !onInsertRow && rowNum == 0 && bf;
1347:            }
1348:
1349:            /**
1350:             * Return <b>true</b> if this cursor is positioned on the
1351:             * first row.
1352:             *
1353:             * @exception SQLException may be thrown
1354:             */
1355:            public boolean isFirst() throws SQLException {
1356:                checkScrollable();
1357:                return !onInsertRow && rowNum == 1;
1358:            }
1359:
1360:            /**
1361:             * Return <b>true</b> if this cursor is positioned on the
1362:             * last row.
1363:             *
1364:             * @exception SQLException may be thrown
1365:             */
1366:            public boolean isLast() throws SQLException {
1367:                checkScrollable();
1368:                if (!onInsertRow) {
1369:                    if (rowNum > 0) {
1370:                        int siz = (int) cursor.size();
1371:                        if (siz > 0) {
1372:                            return rowNum == siz;
1373:                        }
1374:                    } else if (rowNum < 0) {
1375:                        return rowNum == -1;
1376:                    }
1377:                    if (!next()) {
1378:                        return true;
1379:                    } else {
1380:                        previous();
1381:                    }
1382:                }
1383:                return false;
1384:            }
1385:
1386:            /**
1387:             * Move to the last row of the <code>ResultSet</code>.
1388:             *
1389:             * @return true if we manage to successfully position the 
1390:             *   <code>ResultSet</code> on the last row
1391:             * @exception SQLException is likely to be thrown ;-)
1392:             */
1393:            public boolean last() throws SQLException {
1394:                return absolute(-1);
1395:            }
1396:
1397:            /**
1398:             * If the cursor is on the insert row, move it back to the previous
1399:             * position in the <code>ResultSet</code>.  If the cursor is not
1400:             * on the insert row, this function has no effect.
1401:             */
1402:            public void moveToCurrentRow() {
1403:                //#ifdef DEBUG
1404:                if (trace.bit(0)) {
1405:                    Debug.println("ResultSet.moveToCurrentRow()");
1406:                }
1407:                //#endif
1408:                onInsertRow = false;
1409:            }
1410:
1411:            /**
1412:             * Move the cursor to the insert row.
1413:             */
1414:            public void moveToInsertRow() {
1415:                //#ifdef DEBUG
1416:                if (trace.bit(0)) {
1417:                    Debug.println("ResultSet.moveToInsertRow()");
1418:                }
1419:                //#endif
1420:                insertRow = null;
1421:                onInsertRow = true;
1422:            }
1423:
1424:            /**
1425:             * Advance the cursor to the next row in the <code>ResultSet</code>.
1426:             * 
1427:             * @return true if the cursor is positioned on a valid row, false
1428:             *   if the cursor has passed the end of the <code>ResultSet</code>.
1429:             *
1430:             * @exception SQLException may be thrown
1431:             */
1432:            public boolean next() throws SQLException {
1433:                resetRow();
1434:                boolean ret = false;
1435:                if (stmt != null && stmt.maxRows > 0
1436:                        && rowCount >= stmt.maxRows) {
1437:                    ret = false;
1438:                } else if (cursor != null) {
1439:                    rowCount++;
1440:                    ret = cursor.next();
1441:                    if (ret)
1442:                        rowNum++;
1443:                }
1444:                //#ifdef DEBUG
1445:                if (trace.bit(0)) {
1446:                    Debug.println("ResultSet.next() (cursor "
1447:                            + cursor.getClass().getName() + ") returns " + ret);
1448:                }
1449:                //#endif
1450:                return ret;
1451:            }
1452:
1453:            /**
1454:             * Advance the cursor to the next row in the <code>ResultSet</code>.
1455:             * 
1456:             * @return true if the cursor is positioned on a valid row, false
1457:             *   if the cursor has passed the end of the <code>ResultSet</code>.
1458:             *
1459:             * @exception SQLException may be thrown
1460:             */
1461:            public boolean previous() throws SQLException {
1462:                resetRow();
1463:                boolean ret = false;
1464:                if (stmt != null && cursor != null) {
1465:                    ret = cursor.prev();
1466:                    if (ret) {
1467:                        rowNum--;
1468:                        rowCount--;
1469:                    }
1470:                }
1471:                //#ifdef DEBUG
1472:                if (trace.bit(0)) {
1473:                    Debug.println("ResultSet.next() (cursor "
1474:                            + cursor.getClass().getName() + ") returns " + ret);
1475:                }
1476:                //#endif
1477:                return ret;
1478:            }
1479:
1480:            /**
1481:             * Refresh the row from the underlying data store
1482:             */
1483:            public void refreshRow() throws SQLException {
1484:                this .row = null;
1485:            }
1486:
1487:            /**
1488:             * Move the cursor <code>rows</code> units forward
1489:             * (if <code>rows &gt; 0</code>) or backward
1490:             * (if <code>rows &lt; 0</code>)
1491:             */
1492:            public boolean relative(int rows) throws SQLException {
1493:                if (rowNum != 0) {
1494:                    return absolute(rowNum + rows);
1495:                } else {
1496:                    return false;
1497:                }
1498:            }
1499:
1500:            /**
1501:             * Return <code>true</code> if the current row has been deleted.
1502:             *
1503:             * @return false
1504:             */
1505:            public boolean rowDeleted() {
1506:                return rowDeleted;
1507:            }
1508:
1509:            /**
1510:             * Return <code>true</code> if the current row has been inserted.
1511:             */
1512:            public boolean rowInserted() {
1513:                return rowUpdated && onInsertRow;
1514:            }
1515:
1516:            /**
1517:             * Return <code>true</code> if the current row has been updated.
1518:             */
1519:            public boolean rowUpdated() throws SQLException {
1520:                return rowUpdated && !onInsertRow;
1521:            }
1522:
1523:            /**
1524:             * This release of QED ignores the 'fetch direction' hint
1525:             */
1526:            public void setFetchDirection(int direction) throws SQLException {
1527:            }
1528:
1529:            /**
1530:             * QED, being an embedded driver, fetches rows only when they are
1531:             * needed, with no performance penalty.  Thus, the fetch size is
1532:             * always <code>one</code>, and this function has no effect.
1533:             */
1534:            public void setFetchSize(int size) {
1535:            }
1536:
1537:            /**
1538:             * Update the specified character value using an 
1539:             * <code>InputStream</code> that contains a stream of ASCII bytes.
1540:             * The ASCII bytes are converted to Unicode character values before
1541:             * being inserted into the database.
1542:             *
1543:             * @param col the column number
1544:             * @param is an input stream containing ASCII bytes.
1545:             * @param length the number of bytes to read from the stream
1546:             * @return an <code>InputStream</code>
1547:             * @exception SQLException may be thrown
1548:             */
1549:            public void updateAsciiStream(int col, InputStream is, int length)
1550:                    throws SQLException {
1551:                updateCharacterStream(col, new AsciiReader(is), length);
1552:            }
1553:
1554:            /**
1555:             * Update the specified character value using an 
1556:             * <code>InputStream</code> that contains a stream of ASCII bytes.
1557:             * The ASCII bytes are converted to Unicode character values before
1558:             * being inserted into the database.
1559:             *
1560:             * @param column the column name
1561:             * @param is an input stream containing ASCII bytes.
1562:             * @param length the number of bytes to read from the stream
1563:             * @return an <code>InputStream</code>
1564:             * @exception SQLException may be thrown
1565:             */
1566:            public void updateAsciiStream(String column, InputStream is,
1567:                    int length) throws SQLException {
1568:                updateAsciiStream(findColumn(column), is, length);
1569:            }
1570:
1571:            /**
1572:             * Update the specified column with a <code>BigDecimal</code> value.
1573:             *
1574:             * @param column the column name
1575:             * @param val the new value
1576:             * @exception SQLException may be thrown
1577:             */
1578:            public void updateBigDecimal(int col, BigDecimal val)
1579:                    throws SQLException {
1580:                checkWritable(col);
1581:                getCursorRow().set(col, new ValueScaledInteger(val));
1582:            }
1583:
1584:            /**
1585:             * Update the specified column with a <code>BigDecimal</code> value.
1586:             *
1587:             * @param column the column name
1588:             * @param val the new value
1589:             * @exception SQLException may be thrown
1590:             */
1591:            public void updateBigDecimal(String column, BigDecimal val)
1592:                    throws SQLException {
1593:                updateBigDecimal(findColumn(column), val);
1594:            }
1595:
1596:            /**
1597:             * Update the specified  value using an 
1598:             * <code>InputStream</code> that contains a stream of bytes.
1599:             *
1600:             * @param col the column number
1601:             * @param is an input stream
1602:             * @param length the number of bytes to read from the stream
1603:             * @return an <code>InputStream</code>
1604:             * @exception SQLException may be thrown
1605:             */
1606:            public void updateBinaryStream(int col, InputStream is, int length)
1607:                    throws SQLException {
1608:                checkWritable(col);
1609:                try {
1610:                    ValueBlob val = new ValueBlob(getSession().getDatabase(),
1611:                            getTransactionId(), is, length);
1612:                    getCursorRow().set(col, val);
1613:                } catch (IOException e) {
1614:                    Debug.print(e);
1615:                    throw new SQLException("Can't update binary stream",
1616:                            "22000");
1617:                }
1618:
1619:            }
1620:
1621:            /**
1622:             * Update the specified  value using an 
1623:             * <code>InputStream</code> that contains a stream of bytes.
1624:             *
1625:             * @param column the column name
1626:             * @param is an input stream
1627:             * @param length the number of bytes to read from the stream
1628:             * @return an <code>InputStream</code>
1629:             * @exception SQLException may be thrown
1630:             */
1631:            public void updateBinaryStream(String column, InputStream is,
1632:                    int length) throws SQLException {
1633:                updateBinaryStream(findColumn(column), is, length);
1634:            }
1635:
1636:            /**
1637:             * Update the specified column with a <code>boolean</code> value.
1638:             *
1639:             * @param col the column numbere
1640:             * @param val the new value
1641:             * @exception SQLException may be thrown
1642:             */
1643:            public void updateBoolean(int col, boolean val) throws SQLException {
1644:                checkWritable(col);
1645:                getCursorRow().set(col, new ValueBoolean(val));
1646:            }
1647:
1648:            /**
1649:             * Update the specified column with a <code>boolean</code> value.
1650:             *
1651:             * @param column the column name
1652:             * @param val the new value
1653:             * @exception SQLException may be thrown
1654:             */
1655:            public void updateBoolean(String column, boolean val)
1656:                    throws SQLException {
1657:                updateBoolean(findColumn(column), val);
1658:            }
1659:
1660:            /**
1661:             * Update the specified column with a <code>byte</code> value.
1662:             *
1663:             * @param col the column number
1664:             * @param val the new value
1665:             * @exception SQLException may be thrown
1666:             */
1667:            public void updateByte(int col, byte val) throws SQLException {
1668:                checkWritable(col);
1669:                getCursorRow().set(col, new ValueShort(val));
1670:            }
1671:
1672:            /**
1673:             * Update the specified column with a <code>byte</code> value.
1674:             *
1675:             * @param column the column name
1676:             * @param val the new value
1677:             * @exception SQLException may be thrown
1678:             */
1679:            public void updateByte(String column, byte val) throws SQLException {
1680:                updateByte(findColumn(column), val);
1681:            }
1682:
1683:            /**
1684:             * Update the specified column with a <code>byte</code> array value.
1685:             *
1686:             * @param col the column number
1687:             * @param val the new value
1688:             * @exception SQLException may be thrown
1689:             */
1690:            public void updateBytes(int col, byte[] val) throws SQLException {
1691:                checkWritable(col);
1692:                getCursorRow().set(col, new ValueOctets(val));
1693:            }
1694:
1695:            /**
1696:             * Update the specified column with a <code>byte</code> array value.
1697:             *
1698:             * @param column the column name
1699:             * @param val the new value
1700:             * @exception SQLException may be thrown
1701:             */
1702:            public void updateBytes(String column, byte[] val)
1703:                    throws SQLException {
1704:                updateBytes(findColumn(column), val);
1705:            }
1706:
1707:            /**
1708:             * Update the specified character value using a
1709:             * <code>Reader</code> that contains a stream of characters.
1710:             *
1711:             * @param col the column number
1712:             * @param r an input reader
1713:             * @param length the number of characters to read from the reader
1714:             * @return an <code>InputStream</code>
1715:             * @exception SQLException may be thrown
1716:             */
1717:            public void updateCharacterStream(int col, Reader r, int length)
1718:                    throws SQLException {
1719:                updateBinaryStream(col, new ReaderInputStream(r), length * 2);
1720:            }
1721:
1722:            /**
1723:             * Update the specified character value using a
1724:             * <code>Reader</code> that contains a stream of characters.
1725:             *
1726:             * @param column the column name
1727:             * @param r an input reader
1728:             * @param length the number of characters to read from the reader
1729:             * @return an <code>InputStream</code>
1730:             * @exception SQLException may be thrown
1731:             */
1732:            public void updateCharacterStream(String column, Reader r,
1733:                    int length) throws SQLException {
1734:                updateCharacterStream(findColumn(column), r, length);
1735:            }
1736:
1737:            /**
1738:             * Update the specified column with a <code>Date</code> value.
1739:             *
1740:             * @param col the column number
1741:             * @param val the new value
1742:             * @exception SQLException may be thrown
1743:             */
1744:            public void updateDate(int col, Date val) throws SQLException {
1745:                checkWritable(col);
1746:                getCursorRow().set(col, new ValueDate(val.getTime()));
1747:            }
1748:
1749:            /**
1750:             * Update the specified column with a <code>Date</code> value.
1751:             *
1752:             * @param column the column name
1753:             * @param val the new value
1754:             * @exception SQLException may be thrown
1755:             */
1756:            public void updateDate(String column, Date val) throws SQLException {
1757:                updateDate(findColumn(column), val);
1758:            }
1759:
1760:            /**
1761:             * Update the specified column with a <code>double</code> value.
1762:             *
1763:             * @param col the column number
1764:             * @param val the new value
1765:             * @exception SQLException may be thrown
1766:             */
1767:            public void updateDouble(int col, double val) throws SQLException {
1768:                checkWritable(col);
1769:                getCursorRow().set(col, new ValueDouble(val));
1770:            }
1771:
1772:            /**
1773:             * Update the specified column with a <code>double</code> value.
1774:             *
1775:             * @param column the column name
1776:             * @param val the new value
1777:             * @exception SQLException may be thrown
1778:             */
1779:            public void updateDouble(String column, double val)
1780:                    throws SQLException {
1781:                updateDouble(findColumn(column), val);
1782:            }
1783:
1784:            /**
1785:             * Update the specified column with a <code>float</code> value.
1786:             *
1787:             * @param col the column number
1788:             * @param val the new value
1789:             * @exception SQLException may be thrown
1790:             */
1791:            public void updateFloat(int col, float val) throws SQLException {
1792:                checkWritable(col);
1793:                getCursorRow().set(col, new ValueDouble(val));
1794:            }
1795:
1796:            /**
1797:             * Update the specified column with a <code>float</code> value.
1798:             *
1799:             * @param column the column name
1800:             * @param val the new value
1801:             * @exception SQLException may be thrown
1802:             */
1803:            public void updateFloat(String column, float val)
1804:                    throws SQLException {
1805:                updateFloat(findColumn(column), val);
1806:            }
1807:
1808:            /**
1809:             * Update the specified column with a <code>int</code> value.
1810:             *
1811:             * @param col the column number
1812:             * @param val the new value
1813:             * @exception SQLException may be thrown
1814:             */
1815:            public void updateInt(int col, int val) throws SQLException {
1816:                //#ifdef DEBUG
1817:                if (trace.bit(5)) {
1818:                    Debug.println("updateInt(" + col + ", " + val + ")");
1819:                }
1820:                //#endif
1821:                checkWritable(col);
1822:                Row row1 = getCursorRow();
1823:                row1.set(col, new ValueInteger(val));
1824:            }
1825:
1826:            /**
1827:             * Update the specified column with a <code>int</code> value.
1828:             *
1829:             * @param column the column name
1830:             * @param val the new value
1831:             * @exception SQLException may be thrown
1832:             */
1833:            public void updateInt(String column, int val) throws SQLException {
1834:                updateInt(findColumn(column), val);
1835:            }
1836:
1837:            /**
1838:             * Update the specified column with a <code>long</code> value.
1839:             *
1840:             * @param col the column number
1841:             * @param val the new value
1842:             * @exception SQLException may be thrown
1843:             */
1844:            public void updateLong(int col, long val) throws SQLException {
1845:                checkWritable(col);
1846:                getCursorRow().set(col, new ValueLong(val));
1847:            }
1848:
1849:            /**
1850:             * Update the specified column with a <code>long</code> value.
1851:             *
1852:             * @param column the column name
1853:             * @param val the new value
1854:             * @exception SQLException may be thrown
1855:             */
1856:            public void updateLong(String column, long val) throws SQLException {
1857:                updateLong(findColumn(column), val);
1858:            }
1859:
1860:            /**
1861:             * Update the specified column with a <code>null</code> value.
1862:             *
1863:             * @param column the column name
1864:             * @exception SQLException may be thrown
1865:             */
1866:            public void updateNull(int col) throws SQLException {
1867:                checkWritable(col);
1868:                getCursorRow().set(col, ValueNull.valueNull);
1869:            }
1870:
1871:            /**
1872:             * Update the specified column with a <code>null</code> value.
1873:             *
1874:             * @param column the column name
1875:             * @exception SQLException may be thrown
1876:             */
1877:            public void updateNull(String column) throws SQLException {
1878:                updateNull(findColumn(column));
1879:            }
1880:
1881:            /**
1882:             * Update the specified column with the value of a
1883:             * Java <code>Object</code>.
1884:             *
1885:             * @param col the column number
1886:             * @param val the new value
1887:             * @exception SQLException may be thrown
1888:             */
1889:            public void updateObject(int col, Object val) throws SQLException {
1890:                //#ifdef DEBUG
1891:                if (trace.bit(5)) {
1892:                    Debug.println("updateObject(" + col + ", " + val + ")");
1893:                }
1894:                //#endif
1895:                checkWritable(col);
1896:                getCursorRow().set(col, Value.fromObject(val));
1897:            }
1898:
1899:            /**
1900:             * Update the specified column with the value of a
1901:             * Java <code>Object</code>.
1902:             *
1903:             * @param col the column number
1904:             * @param val the new value
1905:             * @param scale ignored in this release of QED
1906:             * @exception SQLException may be thrown
1907:             */
1908:            public void updateObject(int col, Object val, int scale)
1909:                    throws SQLException {
1910:                updateObject(col, val); // XXX tossing scale!
1911:            }
1912:
1913:            /**
1914:             * Update the specified column with the value of a
1915:             * Java <code>Object</code>.
1916:             *
1917:             * @param column the column name
1918:             * @param val the new value
1919:             * @exception SQLException may be thrown
1920:             */
1921:            public void updateObject(String column, Object val)
1922:                    throws SQLException {
1923:                updateObject(findColumn(column), val);
1924:
1925:            }
1926:
1927:            /**
1928:             * Update the specified column with the value of a
1929:             * Java <code>Object</code>.
1930:             *
1931:             * @param col the column number
1932:             * @param val the new value
1933:             * @param scale ignored in this release of QED
1934:             * @exception SQLException may be thrown
1935:             */
1936:            public void updateObject(String column, Object val, int scale)
1937:                    throws SQLException {
1938:                updateObject(findColumn(column), val, scale);
1939:            }
1940:
1941:            /**
1942:             * Update the specified column with a <code>short</code> value.
1943:             *
1944:             * @param col the column number
1945:             * @param val the new value
1946:             * @exception SQLException may be thrown
1947:             */
1948:            public void updateShort(int col, short val) throws SQLException {
1949:                checkWritable(col);
1950:                getCursorRow().set(col, new ValueShort(val));
1951:            }
1952:
1953:            /**
1954:             * Update the specified column with a <code>short</code> value.
1955:             *
1956:             * @param column the column name
1957:             * @param val the new value
1958:             * @exception SQLException may be thrown
1959:             */
1960:            public void updateShort(String column, short val)
1961:                    throws SQLException {
1962:                updateShort(findColumn(column), val);
1963:            }
1964:
1965:            /**
1966:             * Update the specified column with a <code>String</code> value.
1967:             *
1968:             * @param col the column number
1969:             * @param val the new value
1970:             * @exception SQLException may be thrown
1971:             */
1972:            public void updateString(int col, String val) throws SQLException {
1973:                checkWritable(col);
1974:                getCursorRow().set(col, new ValueString(val));
1975:            }
1976:
1977:            /**
1978:             * Update the specified column with a <code>String</code> value.
1979:             *
1980:             * @param column the column name
1981:             * @param val the new value
1982:             * @exception SQLException may be thrown
1983:             */
1984:            public void updateString(String column, String val)
1985:                    throws SQLException {
1986:                updateString(findColumn(column), val);
1987:            }
1988:
1989:            /**
1990:             * Update the specified column with a <code>Time</code> value.
1991:             *
1992:             * @param col the column number
1993:             * @param val the new value
1994:             * @exception SQLException may be thrown
1995:             */
1996:            public void updateTime(int col, Time val) throws SQLException {
1997:                checkWritable(col);
1998:                getCursorRow().set(col, new ValueTime(val.getTime()));
1999:            }
2000:
2001:            /**
2002:             * Update the specified column with a <code>Time</code> value.
2003:             *
2004:             * @param column the column name
2005:             * @param val the new value
2006:             * @exception SQLException may be thrown
2007:             */
2008:            public void updateTime(String column, Time val) throws SQLException {
2009:                updateTime(findColumn(column), val);
2010:            }
2011:
2012:            /**
2013:             * Update the specified column with a <code>Timestamp</code> value.
2014:             *
2015:             * @param col the column number
2016:             * @param val the new value
2017:             * @exception SQLException may be thrown
2018:             */
2019:            public void updateTimestamp(int col, Timestamp val)
2020:                    throws SQLException {
2021:                checkWritable(col);
2022:                getCursorRow().set(col, new ValueTimestamp(val));
2023:            }
2024:
2025:            /**
2026:             * Update the specified column with a <code>Timestamp</code> value.
2027:             *
2028:             * @param column the column name
2029:             * @param val the new value
2030:             * @exception SQLException may be thrown
2031:             */
2032:            public void updateTimestamp(String column, Timestamp val)
2033:                    throws SQLException {
2034:                updateTimestamp(findColumn(column), val);
2035:            }
2036:
2037:            /**
2038:             * Return <code>true</code> if the last value fetched (via a
2039:             * <code>getXXX()</code> method) was <code>NULL</code>.
2040:             *
2041:             * @return true if the last value fetched was <code>NULL</code>.
2042:             */
2043:            public boolean wasNull() {
2044:                return wasNull;
2045:            }
2046:
2047:            int resultSetType = ResultSet.TYPE_FORWARD_ONLY;
2048:            int resultSetConcurrency = ResultSet.CONCUR_READ_ONLY;
2049:
2050:            /**
2051:             * Ensure that this ResultSet is scrollable.  This method is a
2052:             * factorization of the common check necessary for all ResultSet
2053:             * scoll methods.
2054:             */
2055:            final void checkScrollable() throws SQLException {
2056:                if (resultSetType == ResultSet.TYPE_FORWARD_ONLY) {
2057:                    throw new SQLException(
2058:                            "checkScrollable(): type == ResultSet.TYPE_FORWARD_ONLY");
2059:                }
2060:            }
2061:
2062:            /**
2063:             * Ensure that this ResultSet is updatable.  This method is a
2064:             * factorization of the common check necessary for all ResultSet
2065:             * update methods.
2066:             */
2067:            final void checkUpdatable() throws SQLException {
2068:                if (resultSetConcurrency == ResultSet.CONCUR_READ_ONLY) {
2069:                    throw new SQLException(
2070:                            "checkUpdatable(): concurrency == CONCUR_READ_ONLY");
2071:                }
2072:            }
2073:
2074:            /**
2075:             * Throw an exception if the specified column number isn't writable.
2076:             */
2077:            final private void checkWritable(int col) throws SQLException {
2078:                checkUpdatable();
2079:                if (!cursor.isWritable(col)) {
2080:                    //#ifdef DEBUG
2081:                    Debug.println("cursor = " + cursor);
2082:                    //#endif
2083:                    throw new SQLException("Not writable: "
2084:                            + cursor.getColumn(col).getName(), "42000");
2085:                }
2086:                if (!(onInsertRow || onUpdateRow)) {
2087:                    onUpdateRow = true;
2088:                    insertRow = null;
2089:                }
2090:            }
2091:
2092:            /**
2093:             * Return the concurrency level of this <code>ResultSet</code>.
2094:             *
2095:             * @return this <code>ResultSet</code>s concurrency level
2096:             */
2097:            public int getConcurrency() {
2098:                return resultSetConcurrency;
2099:            }
2100:
2101:            /**
2102:             * This release of QED only supports forward cursor movement.
2103:             *
2104:             * @return <code>FETCH_FORWARD</code>
2105:             */
2106:            public int getFetchDirection() {
2107:                return FETCH_FORWARD;
2108:            }
2109:
2110:            //#ifndef JDK11
2111:            /**
2112:             * This release of QED doesn't support <code>ARRAY</code> types.
2113:             *
2114:             * @exception SQLException "not implemented"
2115:             */
2116:            public Array getArray(int col) throws SQLException {
2117:                throw new SQLException("not implemented", "0A000");
2118:            }
2119:
2120:            /**
2121:             * This release of QED doesn't support <code>ARRAY</code> types.
2122:             *
2123:             * @exception SQLException "not implemented"
2124:             */
2125:            public Array getArray(String column) throws SQLException {
2126:                return getArray(findColumn(column));
2127:            }
2128:
2129:            /**
2130:             * Retrieve the specified column as a <code>Blob</code> object.
2131:             *
2132:             * @param col the column number
2133:             * @return the column's value in the current row
2134:             * @exception SQLException may be thrown
2135:             */
2136:            public Blob getBlob(int col) throws SQLException {
2137:                Value v = getValue(col);
2138:                if (Value.isNull(v))
2139:                    return null;
2140:                v = v.convert(TypeBlob.typeBlob);
2141:                ValueBlob vb = (ValueBlob) v;
2142:                return vb;
2143:            }
2144:
2145:            /**
2146:             * Retrieve the specified column as a <code>Blob</code> object.
2147:             *
2148:             * @param column the column name
2149:             * @return the column's value in the current row
2150:             * @exception SQLException may be thrown
2151:             */
2152:            public Blob getBlob(String column) throws SQLException {
2153:                return getBlob(findColumn(column));
2154:            }
2155:
2156:            /**
2157:             * Retrieve the specified column as a Java <code>Object</code>,
2158:             * using the supplied type map.  This feature is not supported
2159:             * by this release of QED.
2160:             *
2161:             * @exception SQLException "not implemented"
2162:             */
2163:            public Object getObject(int col, Map map) throws SQLException {
2164:                throw new SQLException("not implemented", "0A000");
2165:            }
2166:
2167:            /**
2168:             * Retrieve the specified column as a Java <code>Object</code>,
2169:             * using the supplied type map.  This feature is not supported
2170:             * by this release of QED.
2171:             *
2172:             * @exception SQLException "not implemented"
2173:             */
2174:            public Object getObject(String column, Map map) throws SQLException {
2175:                return getObject(findColumn(column), map);
2176:            }
2177:
2178:            /**
2179:             * This release of QED doesn't support <code>REF</code> types.
2180:             *
2181:             * @exception SQLException "not implemented"
2182:             */
2183:            public Ref getRef(int col) throws SQLException {
2184:                throw new SQLException("not implemented", "0A000");
2185:            }
2186:
2187:            /**
2188:             * This release of QED doesn't support <code>REF</code> types.
2189:             *
2190:             * @exception SQLException "not implemented"
2191:             */
2192:            public Ref getRef(String column) throws SQLException {
2193:                return getRef(findColumn(column));
2194:            }
2195:
2196:            /**
2197:             * This QED release only supports <code>ResultSet.TYPE_FORWARD_ONLY</code>.
2198:             *
2199:             * @return <code>ResultSet.TYPE_FORWARD_ONLY</code>
2200:             */
2201:            public int getType() {
2202:                return resultSetType;
2203:            }
2204:
2205:            /**
2206:             * Retrieve the specified column as a <code>Clob</code> object.
2207:             *
2208:             * @param col the column number
2209:             * @return the column's value in the current row
2210:             * @exception SQLException may be thrown
2211:             */
2212:            public Clob getClob(int col) throws SQLException {
2213:                Value v = getValue(col);
2214:                if (Value.isNull(v))
2215:                    return null;
2216:                v = v.convert(TypeClob.typeClob);
2217:                ValueClob vb = (ValueClob) v;
2218:                return vb;
2219:            }
2220:
2221:            /**
2222:             * Retrieve the specified column as a <code>Clob</code> object.
2223:             *
2224:             * @param column the column name
2225:             * @return the column's value in the current row
2226:             * @exception SQLException may be thrown
2227:             */
2228:            public Clob getClob(String column) throws SQLException {
2229:                return getClob(findColumn(column));
2230:            }
2231:
2232:            //#endif
2233:
2234:            //#ifdef JDK14
2235:            //-------------------------- JDBC 3.0 -----------------------------------
2236:            /**
2237:             * The constant indicating that <code>ResultSet</code> objects should not
2238:             * be closed when the method <code>Connection.commit</code> is called.
2239:             *
2240:             * @since 1.4
2241:             */
2242:            //int HOLD_CURSORS_OVER_COMMIT = 1;
2243:            /**
2244:             * The constant indicating that <code>ResultSet</code> objects should be
2245:             * closed when the method <code>Connection.commit</code> is called.
2246:             *
2247:             * @since 1.4
2248:             */
2249:            //int CLOSE_CURSORS_AT_COMMIT = 2;
2250:            /**
2251:             * Retrieves the value of the designated column in the current row
2252:             * of this <code>ResultSet</code> object as a <code>java.net.URL</code>
2253:             * object in the Java programming language.
2254:             * 
2255:             * @param columnIndex the index of the column 1 is the first, 2 is the second,...
2256:             * @return the column value as a <code>java.net.URL</code> object;
2257:             * if the value is SQL <code>NULL</code>,
2258:             * the value returned is <code>null</code> in the Java programming language
2259:             * @exception SQLException if a database access error occurs,
2260:             *            or if a URL is malformed
2261:             * @since 1.4
2262:             */
2263:            public java.net.URL getURL(int columnIndex) throws SQLException {
2264:                try {
2265:                    return new java.net.URL(getString(columnIndex));
2266:                } catch (java.net.MalformedURLException e) {
2267:                    throw new SQLException(e.toString());
2268:                }
2269:            }
2270:
2271:            /**
2272:             * Retrieves the value of the designated column in the current row
2273:             * of this <code>ResultSet</code> object as a <code>java.net.URL</code>
2274:             * object in the Java programming language.
2275:             * 
2276:             * @param columnName the SQL name of the column
2277:             * @return the column value as a <code>java.net.URL</code> object;
2278:             * if the value is SQL <code>NULL</code>,
2279:             * the value returned is <code>null</code> in the Java programming language
2280:             * @exception SQLException if a database access error occurs
2281:             *            or if a URL is malformed
2282:             * @since 1.4
2283:             */
2284:            public java.net.URL getURL(String columnName) throws SQLException {
2285:                return getURL(findColumn(columnName));
2286:            }
2287:
2288:            /**
2289:             * Updates the designated column with a <code>java.sql.Ref</code> value.
2290:             * The updater methods are used to update column values in the
2291:             * current row or the insert row.  The updater methods do not 
2292:             * update the underlying database; instead the <code>updateRow</code> or
2293:             * <code>insertRow</code> methods are called to update the database.
2294:             *
2295:             * @param columnIndex the first column is 1, the second is 2, ...
2296:             * @param x the new column value
2297:             * @exception SQLException if a database access error occurs
2298:             * @since 1.4
2299:             */
2300:            public void updateRef(int columnIndex, java.sql.Ref x)
2301:                    throws SQLException {
2302:                throw new SQLException("Not implemented");
2303:            }
2304:
2305:            /** 
2306:             * Updates the designated column with a <code>java.sql.Ref</code> value.
2307:             * The updater methods are used to update column values in the
2308:             * current row or the insert row.  The updater methods do not 
2309:             * update the underlying database; instead the <code>updateRow</code> or
2310:             * <code>insertRow</code> methods are called to update the database.
2311:             *
2312:             * @param columnName the name of the column
2313:             * @param x the new column value
2314:             * @exception SQLException if a database access error occurs
2315:             * @since 1.4
2316:             */
2317:            public void updateRef(String columnName, java.sql.Ref x)
2318:                    throws SQLException {
2319:                throw new SQLException("Not implemented");
2320:            }
2321:
2322:            /**
2323:             * Updates the designated column with a <code>java.sql.Blob</code> value.
2324:             * The updater methods are used to update column values in the
2325:             * current row or the insert row.  The updater methods do not 
2326:             * update the underlying database; instead the <code>updateRow</code> or
2327:             * <code>insertRow</code> methods are called to update the database.
2328:             *
2329:             * @param columnIndex the first column is 1, the second is 2, ...
2330:             * @param x the new column value
2331:             * @exception SQLException if a database access error occurs
2332:             * @since 1.4
2333:             */
2334:            public void updateBlob(int columnIndex, java.sql.Blob x)
2335:                    throws SQLException {
2336:                throw new SQLException("Not implemented");
2337:            }
2338:
2339:            /** 
2340:             * Updates the designated column with a <code>java.sql.Blob</code> value.
2341:             * The updater methods are used to update column values in the
2342:             * current row or the insert row.  The updater methods do not 
2343:             * update the underlying database; instead the <code>updateRow</code> or
2344:             * <code>insertRow</code> methods are called to update the database.
2345:             *
2346:             * @param columnName the name of the column
2347:             * @param x the new column value
2348:             * @exception SQLException if a database access error occurs
2349:             * @since 1.4
2350:             */
2351:            public void updateBlob(String columnName, java.sql.Blob x)
2352:                    throws SQLException {
2353:                throw new SQLException("Not implemented");
2354:            }
2355:
2356:            /**
2357:             * Updates the designated column with a <code>java.sql.Clob</code> value.
2358:             * The updater methods are used to update column values in the
2359:             * current row or the insert row.  The updater methods do not 
2360:             * update the underlying database; instead the <code>updateRow</code> or
2361:             * <code>insertRow</code> methods are called to update the database.
2362:             *
2363:             * @param columnIndex the first column is 1, the second is 2, ...
2364:             * @param x the new column value
2365:             * @exception SQLException if a database access error occurs
2366:             * @since 1.4
2367:             */
2368:            public void updateClob(int columnIndex, java.sql.Clob x)
2369:                    throws SQLException {
2370:                throw new SQLException("Not implemented");
2371:            }
2372:
2373:            /** 
2374:             * Updates the designated column with a <code>java.sql.Clob</code> value.
2375:             * The updater methods are used to update column values in the
2376:             * current row or the insert row.  The updater methods do not 
2377:             * update the underlying database; instead the <code>updateRow</code> or
2378:             * <code>insertRow</code> methods are called to update the database.
2379:             *
2380:             * @param columnName the name of the column
2381:             * @param x the new column value
2382:             * @exception SQLException if a database access error occurs
2383:             * @since 1.4
2384:             */
2385:            public void updateClob(String columnName, java.sql.Clob x)
2386:                    throws SQLException {
2387:                throw new SQLException("Not implemented");
2388:            }
2389:
2390:            /**
2391:             * Updates the designated column with a <code>java.sql.Array</code> value.
2392:             * The updater methods are used to update column values in the
2393:             * current row or the insert row.  The updater methods do not 
2394:             * update the underlying database; instead the <code>updateRow</code> or
2395:             * <code>insertRow</code> methods are called to update the database.
2396:             *
2397:             * @param columnIndex the first column is 1, the second is 2, ...
2398:             * @param x the new column value
2399:             * @exception SQLException if a database access error occurs
2400:             * @since 1.4
2401:             */
2402:            public void updateArray(int columnIndex, java.sql.Array x)
2403:                    throws SQLException {
2404:                throw new SQLException("Not implemented");
2405:            }
2406:
2407:            /** 
2408:             * Updates the designated column with a <code>java.sql.Array</code> value.
2409:             * The updater methods are used to update column values in the
2410:             * current row or the insert row.  The updater methods do not 
2411:             * update the underlying database; instead the <code>updateRow</code> or
2412:             * <code>insertRow</code> methods are called to update the database.
2413:             *
2414:             * @param columnName the name of the column
2415:             * @param x the new column value
2416:             * @exception SQLException if a database access error occurs
2417:             * @since 1.4
2418:             */
2419:            public void updateArray(String columnName, java.sql.Array x)
2420:                    throws SQLException {
2421:                throw new SQLException("Not implemented");
2422:            }
2423:            //#endif
2424:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.