Source Code Cross Referenced for AxionResultSet.java in  » Database-DBMS » axion » org » axiondb » 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 » axion » org.axiondb.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * $Id: AxionResultSet.java,v 1.40 2007/11/13 19:04:01 rwald Exp $
0003:         * =======================================================================
0004:         * Copyright (c) 2002-2005 Axion Development Team.  All rights reserved.
0005:         *
0006:         * Redistribution and use in source and binary forms, with or without
0007:         * modification, are permitted provided that the following conditions
0008:         * are met:
0009:         *
0010:         * 1. Redistributions of source code must retain the above
0011:         *    copyright notice, this list of conditions and the following
0012:         *    disclaimer.
0013:         *
0014:         * 2. Redistributions in binary form must reproduce the above copyright
0015:         *    notice, this list of conditions and the following disclaimer in
0016:         *    the documentation and/or other materials provided with the
0017:         *    distribution.
0018:         *
0019:         * 3. The names "Tigris", "Axion", nor the names of its contributors may
0020:         *    not be used to endorse or promote products derived from this
0021:         *    software without specific prior written permission.
0022:         *
0023:         * 4. Products derived from this software may not be called "Axion", nor
0024:         *    may "Tigris" or "Axion" appear in their names without specific prior
0025:         *    written permission.
0026:         *
0027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0028:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
0030:         * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0031:         * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0032:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0033:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0034:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0035:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0036:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0037:         * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0038:         * =======================================================================
0039:         */
0040:
0041:        package org.axiondb.jdbc;
0042:
0043:        import java.io.ByteArrayInputStream;
0044:        import java.io.InputStream;
0045:        import java.io.Reader;
0046:        import java.io.UnsupportedEncodingException;
0047:        import java.math.BigDecimal;
0048:        import java.math.BigInteger;
0049:        import java.net.URL;
0050:        import java.sql.Array;
0051:        import java.sql.Blob;
0052:        import java.sql.Clob;
0053:        import java.sql.Date;
0054:        import java.sql.NClob;
0055:        import java.sql.Ref;
0056:        import java.sql.ResultSet;
0057:        import java.sql.ResultSetMetaData;
0058:        import java.sql.RowId;
0059:        import java.sql.SQLException;
0060:        import java.sql.SQLWarning;
0061:        import java.sql.SQLXML;
0062:        import java.sql.Statement;
0063:        import java.sql.Time;
0064:        import java.sql.Timestamp;
0065:        import java.sql.Types;
0066:        import java.util.Calendar;
0067:        import java.util.Collections;
0068:        import java.util.Map;
0069:
0070:        import org.axiondb.AxionException;
0071:        import org.axiondb.ColumnIdentifier;
0072:        import org.axiondb.ConstraintViolationException;
0073:        import org.axiondb.DataType;
0074:        import org.axiondb.Row;
0075:        import org.axiondb.RowDecorator;
0076:        import org.axiondb.RowDecoratorIterator;
0077:        import org.axiondb.Selectable;
0078:        import org.axiondb.Transaction;
0079:        import org.axiondb.TransactionManager;
0080:        import org.axiondb.engine.rowiterators.EmptyRowIterator;
0081:        import org.axiondb.engine.rowiterators.RowIteratorRowDecoratorIterator;
0082:        import org.axiondb.engine.rows.SimpleRow;
0083:        import org.axiondb.util.ExceptionConverter;
0084:
0085:        /**
0086:         * A {@link java.sql.ResultSet}implementation.
0087:         * 
0088:         * @version $Revision: 1.40 $ $Date: 2007/11/13 19:04:01 $
0089:         * @author Chuck Burdick
0090:         * @author Rodney Waldhoff
0091:         * @author Ahimanikya Satapathy
0092:         * @author Jonathan Giron
0093:         */
0094:        public class AxionResultSet implements  ResultSet {
0095:
0096:            private static final int DIR_FORWARD = 1;
0097:            private static final int DIR_REVERSE = -1;
0098:            private static final int DIR_UNKNOWN = 0;
0099:
0100:            /** What {@link #getBigDecimal}returns when the corresponding value is NULL. */
0101:            private static final BigDecimal NULL_BIGDECIMAL = null;
0102:
0103:            /** What {@link #getBlob}returns when the corresponding value is NULL. */
0104:            private static final Blob NULL_BLOB = null;
0105:
0106:            /** What {@link #getBoolean}returns when the corresponding value is NULL. */
0107:            private static final boolean NULL_BOOLEAN = false;
0108:
0109:            /** What {@link #getByte}returns when the corresponding value is NULL. */
0110:            private static final byte NULL_BYTE = (byte) 0;
0111:
0112:            /** What {@link #getBytes}returns when the corresponding value is NULL. */
0113:            private static final byte[] NULL_BYTES = null;
0114:
0115:            /** What {@link #getClob}returns when the corresponding value is NULL. */
0116:            private static final Clob NULL_CLOB = null;
0117:
0118:            /** What {@link #getDate}returns when the corresponding value is NULL. */
0119:            private static final Date NULL_DATE = null;
0120:
0121:            /** What {@link #getDouble}returns when the corresponding value is NULL. */
0122:            private static final double NULL_DOUBLE = 0d;
0123:
0124:            /** What {@link #getFloat}returns when the corresponding value is NULL. */
0125:            private static final float NULL_FLOAT = 0;
0126:
0127:            /** What {@link #getInt}returns when the corresponding value is NULL. */
0128:            private static final int NULL_INT = 0;
0129:
0130:            /** What {@link #getLong}returns when the corresponding value is NULL. */
0131:            private static final long NULL_LONG = 0L;
0132:
0133:            /** What {@link #getCharacterStream}returns when the corresponding value is NULL. */
0134:            private static final Reader NULL_READER = null;
0135:
0136:            /** What {@link #getShort}returns when the corresponding value is NULL. */
0137:            private static final short NULL_SHORT = (short) 0;
0138:
0139:            /** What {@link #getBinaryStream}returns when the corresponding value is NULL. */
0140:            private static final InputStream NULL_STREAM = null;
0141:
0142:            /** What {@link #getString}returns when the corresponding value is NULL. */
0143:            private static final String NULL_STRING = null;
0144:
0145:            /** What {@link #getTime}returns when the corresponding value is NULL. */
0146:            private static final Time NULL_TIME = null;
0147:
0148:            /** What {@link #getTimestamp}returns when the corresponding value is NULL. */
0149:            private static final Timestamp NULL_TIMESTAMP = null;
0150:
0151:            /** What {@link #getURL}returns when the corresponding value is NULL. */
0152:            private static final URL NULL_URL = null;
0153:
0154:            private static final int USE_DEFAULT_SCALE = Integer.MIN_VALUE;
0155:
0156:            public static ResultSet createEmptyResultSet(Statement stmt) {
0157:                return new AxionResultSet(new RowIteratorRowDecoratorIterator(
0158:                        EmptyRowIterator.INSTANCE, new RowDecorator(
0159:                                Collections.EMPTY_MAP)), new Selectable[0],
0160:                        stmt);
0161:            }
0162:
0163:            //-------------------------------------------------------------- Attributes
0164:
0165:            /** @deprecated use {@link #AxionResultSet(RowDecoratorIterator,Selectable,Statement)  */
0166:            public AxionResultSet(RowDecoratorIterator rows,
0167:                    Selectable[] selected) {
0168:                this (rows, selected, null);
0169:            }
0170:
0171:            public AxionResultSet(RowDecoratorIterator rows,
0172:                    Selectable[] selected, Statement stmt) {
0173:                _rows = rows;
0174:                _selected = selected;
0175:                _meta = new AxionResultSetMetaData(selected);
0176:                setStatement(stmt);
0177:            }
0178:
0179:            protected AxionResultSet() {
0180:            }
0181:
0182:            //------------------------------------------------------- ResultSet Methods
0183:
0184:            public boolean absolute(int row) throws SQLException {
0185:                assertOpen();
0186:                assertScrollable();
0187:
0188:                if (row < 0) {
0189:                    if (row == -1) {
0190:                        return last();
0191:                    }
0192:
0193:                    afterLast();
0194:                    return relative(row);
0195:                } else {
0196:                    beforeFirst();
0197:                    return relative(row);
0198:                }
0199:            }
0200:
0201:            public void afterLast() throws SQLException {
0202:                last();
0203:                next();
0204:            }
0205:
0206:            public void beforeFirst() throws SQLException {
0207:                assertOpen();
0208:                assertScrollable();
0209:                clearInsertOrUpdateIfAny();
0210:
0211:                try {
0212:                    _rows.reset();
0213:                    _currentRowIndex = 0; // TODO: this should probably be an attribute of the RowDecoratorIterator
0214:                    _afterLast = false;
0215:                    _lastDir = DIR_FORWARD;
0216:                } catch (AxionException e) {
0217:                    throw ExceptionConverter.convert(e);
0218:                } catch (RuntimeException e) {
0219:                    throw ExceptionConverter.convert(e);
0220:                }
0221:            }
0222:
0223:            public void cancelRowUpdates() throws SQLException {
0224:                assertOpen();
0225:                assertUpdateable();
0226:                assertNotInInsertMode();
0227:                clearUpdateRow();
0228:            }
0229:
0230:            public void clearWarnings() throws SQLException {
0231:                _warning = null;
0232:            }
0233:
0234:            public void close() throws SQLException {
0235:                if (null != _transactionManager && null != _transaction) {
0236:                    try {
0237:                        _transactionManager.commitTransaction(_transaction);
0238:                    } catch (AxionException e) {
0239:                        throw ExceptionConverter.convert(e);
0240:                    }
0241:                    _transactionManager = null;
0242:                    _transaction = null;
0243:                }
0244:                _closed = true;
0245:                _selected = null;
0246:                _currentRow = null;
0247:                _insertUpdateRow = null;
0248:                _warning = null;
0249:                _updateLock = null;
0250:            }
0251:
0252:            public void deleteRow() throws SQLException {
0253:                assertOpen();
0254:
0255:                synchronized (_updateLock) {
0256:                    assertUpdateable();
0257:                    assertNotInInsertMode();
0258:                    assertCurrentRow();
0259:
0260:                    try {
0261:                        boolean lastRowDeleted = isLast();
0262:
0263:                        _rows.getIterator().remove();
0264:                        clearUpdateRow();
0265:
0266:                        if (lastRowDeleted) {
0267:                            _afterLast = true;
0268:                        } else {
0269:                            _currentRowIndex--;
0270:                        }
0271:                    } catch (AxionException e) {
0272:                        throw ExceptionConverter.convert(e);
0273:                    } catch (UnsupportedOperationException e) {
0274:                        throw new SQLException(
0275:                                "Cannot delete row: table/view is not updateable.");
0276:                    }
0277:                }
0278:            }
0279:
0280:            public int findColumn(String colName) throws SQLException {
0281:                assertOpen();
0282:                return getResultSetIndexForColumnName(colName);
0283:            }
0284:
0285:            public boolean first() throws SQLException {
0286:                beforeFirst();
0287:                return next();
0288:            }
0289:
0290:            public Array getArray(int i) throws SQLException {
0291:                throw new SQLException("Not supported");
0292:            }
0293:
0294:            public Array getArray(String colName) throws SQLException {
0295:                return getArray(getResultSetIndexForColumnName(colName));
0296:            }
0297:
0298:            public InputStream getAsciiStream(int i) throws SQLException {
0299:                Clob clob = getClob(i);
0300:                if (null == clob) {
0301:                    return NULL_STREAM;
0302:                }
0303:                return clob.getAsciiStream();
0304:            }
0305:
0306:            public InputStream getAsciiStream(String colName)
0307:                    throws SQLException {
0308:                return getAsciiStream(getResultSetIndexForColumnName(colName));
0309:            }
0310:
0311:            public BigDecimal getBigDecimal(int i) throws SQLException {
0312:                Object value = getValue(i);
0313:                if (null == value) {
0314:                    return NULL_BIGDECIMAL;
0315:                }
0316:
0317:                try {
0318:                    return getDataType(i).toBigDecimal(value);
0319:                } catch (AxionException e) {
0320:                    throw ExceptionConverter.convert(e);
0321:                }
0322:            }
0323:
0324:            /** @deprecated See {@link java.sql.ResultSet#getBigDecimal(int,int)} */
0325:            public BigDecimal getBigDecimal(int i, int scale)
0326:                    throws SQLException {
0327:                Object value = getValue(i);
0328:                if (null == value) {
0329:                    return NULL_BIGDECIMAL;
0330:                }
0331:                try {
0332:                    BigInteger bigint = getDataType(i).toBigInteger(value);
0333:                    if (null == bigint) {
0334:                        return NULL_BIGDECIMAL;
0335:                    }
0336:                    return new BigDecimal(bigint, scale);
0337:                } catch (AxionException e) {
0338:                    throw ExceptionConverter.convert(e);
0339:                }
0340:            }
0341:
0342:            public BigDecimal getBigDecimal(String colName) throws SQLException {
0343:                return getBigDecimal(getResultSetIndexForColumnName(colName));
0344:            }
0345:
0346:            /** @deprecated See {@link java.sql.ResultSet#getBigDecimal(java.lang.String,int)} */
0347:            public BigDecimal getBigDecimal(String colName, int scale)
0348:                    throws SQLException {
0349:                return getBigDecimal(getResultSetIndexForColumnName(colName),
0350:                        scale);
0351:            }
0352:
0353:            public InputStream getBinaryStream(int i) throws SQLException {
0354:                Blob blob = getBlob(i);
0355:                if (null == blob) {
0356:                    return NULL_STREAM;
0357:                }
0358:                return blob.getBinaryStream();
0359:            }
0360:
0361:            public InputStream getBinaryStream(String colName)
0362:                    throws SQLException {
0363:                return getBinaryStream(getResultSetIndexForColumnName(colName));
0364:            }
0365:
0366:            public Blob getBlob(int i) throws SQLException {
0367:                Object value = getValue(i);
0368:                if (null == value) {
0369:                    return NULL_BLOB;
0370:                }
0371:                try {
0372:                    return getDataType(i).toBlob(value);
0373:                } catch (AxionException e) {
0374:                    throw ExceptionConverter.convert(e);
0375:                }
0376:            }
0377:
0378:            public Blob getBlob(String colName) throws SQLException {
0379:                return getBlob(getResultSetIndexForColumnName(colName));
0380:            }
0381:
0382:            public boolean getBoolean(int i) throws SQLException {
0383:                Object value = getValue(i);
0384:                if (null == value) {
0385:                    return NULL_BOOLEAN;
0386:                }
0387:                try {
0388:                    return getDataType(i).toBoolean(value);
0389:                } catch (AxionException e) {
0390:                    throw ExceptionConverter.convert(e);
0391:                }
0392:            }
0393:
0394:            public boolean getBoolean(String colName) throws SQLException {
0395:                return getBoolean(getResultSetIndexForColumnName(colName));
0396:            }
0397:
0398:            public byte getByte(int i) throws SQLException {
0399:                Object value = getValue(i);
0400:                if (null == value) {
0401:                    return NULL_BYTE;
0402:                }
0403:                try {
0404:                    return getDataType(i).toByte(value);
0405:                } catch (AxionException e) {
0406:                    throw ExceptionConverter.convert(e);
0407:                }
0408:            }
0409:
0410:            public byte getByte(String colName) throws SQLException {
0411:                return getByte(getResultSetIndexForColumnName(colName));
0412:            }
0413:
0414:            public byte[] getBytes(int i) throws SQLException {
0415:                Object value = getValue(i);
0416:                if (null == value) {
0417:                    return NULL_BYTES;
0418:                }
0419:                try {
0420:                    return getDataType(i).toByteArray(value);
0421:                } catch (AxionException e) {
0422:                    throw ExceptionConverter.convert(e);
0423:                }
0424:            }
0425:
0426:            public byte[] getBytes(String colName) throws SQLException {
0427:                return getBytes(getResultSetIndexForColumnName(colName));
0428:            }
0429:
0430:            public Reader getCharacterStream(int i) throws SQLException {
0431:                Clob clob = getClob(i);
0432:                if (null == clob) {
0433:                    return NULL_READER;
0434:                }
0435:                return clob.getCharacterStream();
0436:            }
0437:
0438:            public Reader getCharacterStream(String colName)
0439:                    throws SQLException {
0440:                return getCharacterStream(getResultSetIndexForColumnName(colName));
0441:            }
0442:
0443:            public Clob getClob(int i) throws SQLException {
0444:                Object value = getValue(i);
0445:                if (null == value) {
0446:                    return NULL_CLOB;
0447:                }
0448:                try {
0449:                    return getDataType(i).toClob(value);
0450:                } catch (AxionException e) {
0451:                    throw ExceptionConverter.convert(e);
0452:                }
0453:            }
0454:
0455:            public Clob getClob(String colName) throws SQLException {
0456:                return getClob(getResultSetIndexForColumnName(colName));
0457:            }
0458:
0459:            public int getConcurrency() throws SQLException {
0460:                return (_stmt != null) ? _stmt.getResultSetConcurrency()
0461:                        : ResultSet.CONCUR_READ_ONLY;
0462:            }
0463:
0464:            public String getCursorName() throws SQLException {
0465:                throw new SQLException("Not supported");
0466:            }
0467:
0468:            public Date getDate(int i) throws SQLException {
0469:                Object value = getValue(i);
0470:                if (null == value) {
0471:                    return NULL_DATE;
0472:                }
0473:                try {
0474:                    return getDataType(i).toDate(value);
0475:                } catch (AxionException e) {
0476:                    throw ExceptionConverter.convert(e);
0477:                }
0478:            }
0479:
0480:            public Date getDate(int i, Calendar cal) throws SQLException {
0481:                throw new SQLException("Not supported");
0482:            }
0483:
0484:            public Date getDate(String colName) throws SQLException {
0485:                return getDate(getResultSetIndexForColumnName(colName));
0486:            }
0487:
0488:            public Date getDate(String colName, Calendar cal)
0489:                    throws SQLException {
0490:                return getDate(getResultSetIndexForColumnName(colName), cal);
0491:            }
0492:
0493:            public double getDouble(int i) throws SQLException {
0494:                Object value = getValue(i);
0495:                if (null == value) {
0496:                    return NULL_DOUBLE;
0497:                }
0498:                try {
0499:                    return getDataType(i).toDouble(value);
0500:                } catch (AxionException e) {
0501:                    throw ExceptionConverter.convert(e);
0502:                }
0503:            }
0504:
0505:            public double getDouble(String colName) throws SQLException {
0506:                return getDouble(getResultSetIndexForColumnName(colName));
0507:            }
0508:
0509:            public int getFetchDirection() throws SQLException {
0510:                return FETCH_UNKNOWN;
0511:            }
0512:
0513:            public int getFetchSize() throws SQLException {
0514:                return 0;
0515:            }
0516:
0517:            public float getFloat(int i) throws SQLException {
0518:                Object value = getValue(i);
0519:                if (null == value) {
0520:                    return NULL_FLOAT;
0521:                }
0522:                try {
0523:                    return getDataType(i).toFloat(value);
0524:                } catch (AxionException e) {
0525:                    throw ExceptionConverter.convert(e);
0526:                }
0527:            }
0528:
0529:            public float getFloat(String colName) throws SQLException {
0530:                return getFloat(getResultSetIndexForColumnName(colName));
0531:            }
0532:
0533:            public int getInt(int i) throws SQLException {
0534:                Object value = getValue(i);
0535:                if (null == value) {
0536:                    return NULL_INT;
0537:                }
0538:
0539:                try {
0540:                    return getDataType(i).toInt(value);
0541:                } catch (AxionException e) {
0542:                    throw ExceptionConverter.convert(e);
0543:                }
0544:            }
0545:
0546:            public int getInt(String colName) throws SQLException {
0547:                return getInt(getResultSetIndexForColumnName(colName));
0548:            }
0549:
0550:            public long getLong(int i) throws SQLException {
0551:                Object value = getValue(i);
0552:                if (null == value) {
0553:                    return NULL_LONG;
0554:                }
0555:                try {
0556:                    return getDataType(i).toLong(value);
0557:                } catch (AxionException e) {
0558:                    throw ExceptionConverter.convert(e);
0559:                }
0560:            }
0561:
0562:            public long getLong(String colName) throws SQLException {
0563:                return getLong(getResultSetIndexForColumnName(colName));
0564:            }
0565:
0566:            public ResultSetMetaData getMetaData() throws SQLException {
0567:                return _meta;
0568:            }
0569:
0570:            public Object getObject(int i) throws SQLException {
0571:                return getValue(i);
0572:            }
0573:
0574:            public Object getObject(String colName) throws SQLException {
0575:                return getObject(getResultSetIndexForColumnName(colName));
0576:            }
0577:
0578:            public Ref getRef(int i) throws SQLException {
0579:                throw new SQLException("Not supported");
0580:            }
0581:
0582:            public Ref getRef(String colName) throws SQLException {
0583:                return getRef(getResultSetIndexForColumnName(colName));
0584:            }
0585:
0586:            public int getRow() throws SQLException {
0587:                try {
0588:                    return _currentRow.getRowIndex() + 1;
0589:                } catch (AxionException e) {
0590:                    throw ExceptionConverter.convert(e);
0591:                }
0592:            }
0593:
0594:            public short getShort(int i) throws SQLException {
0595:                Object value = getValue(i);
0596:                if (null == value) {
0597:                    return NULL_SHORT;
0598:                }
0599:                try {
0600:                    return getDataType(i).toShort(value);
0601:                } catch (AxionException e) {
0602:                    throw ExceptionConverter.convert(e);
0603:                }
0604:            }
0605:
0606:            public short getShort(String colName) throws SQLException {
0607:                return getShort(getResultSetIndexForColumnName(colName));
0608:            }
0609:
0610:            public Statement getStatement() throws SQLException {
0611:                return _stmt;
0612:            }
0613:
0614:            public String getString(int i) throws SQLException {
0615:                Object value = getValue(i);
0616:                if (null == value) {
0617:                    return NULL_STRING;
0618:                }
0619:                try {
0620:                    return getDataType(i).toString(value);
0621:                } catch (AxionException e) {
0622:                    throw ExceptionConverter.convert(e);
0623:                }
0624:            }
0625:
0626:            public String getString(String colName) throws SQLException {
0627:                return getString(getResultSetIndexForColumnName(colName));
0628:            }
0629:
0630:            public Time getTime(int i) throws SQLException {
0631:                Object value = getValue(i);
0632:                if (null == value) {
0633:                    return NULL_TIME;
0634:                }
0635:                try {
0636:                    return getDataType(i).toTime(value);
0637:                } catch (AxionException e) {
0638:                    throw ExceptionConverter.convert(e);
0639:                }
0640:            }
0641:
0642:            public Time getTime(int i, Calendar cal) throws SQLException {
0643:                throw new SQLException("Not supported");
0644:            }
0645:
0646:            public Time getTime(String colName) throws SQLException {
0647:                return getTime(getResultSetIndexForColumnName(colName));
0648:            }
0649:
0650:            public Time getTime(String colName, Calendar cal)
0651:                    throws SQLException {
0652:                return getTime(getResultSetIndexForColumnName(colName), cal);
0653:            }
0654:
0655:            public Timestamp getTimestamp(int i) throws SQLException {
0656:                Object value = getValue(i);
0657:                if (null == value) {
0658:                    return NULL_TIMESTAMP;
0659:                }
0660:                try {
0661:                    return getDataType(i).toTimestamp(value);
0662:                } catch (AxionException e) {
0663:                    throw ExceptionConverter.convert(e);
0664:                }
0665:            }
0666:
0667:            public Timestamp getTimestamp(int i, Calendar cal)
0668:                    throws SQLException {
0669:                throw new SQLException("Not supported");
0670:            }
0671:
0672:            public Timestamp getTimestamp(String colName) throws SQLException {
0673:                return getTimestamp(getResultSetIndexForColumnName(colName));
0674:            }
0675:
0676:            public Timestamp getTimestamp(String colName, Calendar cal)
0677:                    throws SQLException {
0678:                return getTimestamp(getResultSetIndexForColumnName(colName),
0679:                        cal);
0680:            }
0681:
0682:            public int getType() throws SQLException {
0683:                return (_stmt != null) ? _stmt.getResultSetType()
0684:                        : ResultSet.TYPE_FORWARD_ONLY;
0685:            }
0686:
0687:            /** @deprecated See {@link java.sql.ResultSet#getUnicodeStream} */
0688:            public InputStream getUnicodeStream(int i) throws SQLException {
0689:                String val = getString(i);
0690:                if (null == val) {
0691:                    return NULL_STREAM;
0692:                }
0693:                try {
0694:                    return new ByteArrayInputStream(val.getBytes("UnicodeBig"));
0695:                } catch (UnsupportedEncodingException e) {
0696:                    throw ExceptionConverter.convert(e);
0697:                }
0698:            }
0699:
0700:            /** @deprecated See {@link java.sql.ResultSet#getUnicodeStream} */
0701:            public InputStream getUnicodeStream(String colName)
0702:                    throws SQLException {
0703:                return getUnicodeStream(getResultSetIndexForColumnName(colName));
0704:            }
0705:
0706:            public URL getURL(int i) throws SQLException {
0707:                Object value = getValue(i);
0708:                if (null == value) {
0709:                    return NULL_URL;
0710:                }
0711:                try {
0712:                    return getDataType(i).toURL(value);
0713:                } catch (AxionException e) {
0714:                    throw ExceptionConverter.convert(e);
0715:                }
0716:            }
0717:
0718:            public URL getURL(String colName) throws SQLException {
0719:                return getURL(getResultSetIndexForColumnName(colName));
0720:            }
0721:
0722:            public SQLWarning getWarnings() throws SQLException {
0723:                return _warning;
0724:            }
0725:
0726:            public void insertRow() throws SQLException {
0727:                assertOpen();
0728:
0729:                synchronized (_updateLock) {
0730:                    assertUpdateable();
0731:                    assertInInsertMode();
0732:                    assertUpdateRowExists();
0733:                    assertCurrentRow();
0734:
0735:                    try {
0736:                        // Add a copy of the _insertUpdateRow to allow it to be reused in subsequent
0737:                        // inserts.
0738:                        _rows.getIterator()
0739:                                .add(new SimpleRow(_insertUpdateRow));
0740:                    } catch (AxionException e) {
0741:                        handleExceptionOnInsertUpdate(e, "Cannot insert row.");
0742:                    } catch (UnsupportedOperationException e) {
0743:                        throw new SQLException(
0744:                                "Cannot insert row - table/view is not updateable.");
0745:                    }
0746:                }
0747:            }
0748:
0749:            public boolean isAfterLast() throws SQLException {
0750:                return !(_rows.getIterator().isEmpty()) && _afterLast;
0751:            }
0752:
0753:            public boolean isBeforeFirst() throws SQLException {
0754:                return !(_rows.getIterator().isEmpty())
0755:                        && 0 == _currentRowIndex;
0756:            }
0757:
0758:            public boolean isFirst() throws SQLException {
0759:                return !(_rows.getIterator().isEmpty())
0760:                        && 1 == _currentRowIndex;
0761:            }
0762:
0763:            public boolean isLast() throws SQLException {
0764:                assertOpen();
0765:
0766:                boolean isLastRow = false;
0767:                if (!(_rows.getIterator().isEmpty()) && !_afterLast
0768:                        && _currentRowIndex != 0) {
0769:                    isLastRow = !_rows.hasNext();
0770:                }
0771:                return isLastRow;
0772:            }
0773:
0774:            public boolean last() throws SQLException {
0775:                assertOpen();
0776:                assertScrollable();
0777:
0778:                _lastDir = DIR_FORWARD;
0779:                clearInsertOrUpdateIfAny();
0780:
0781:                RowDecorator row = null;
0782:                try {
0783:                    row = _rows.last();
0784:                    if (row != null) {
0785:                        _currentRow = row;
0786:                        _currentRowIndex = _currentRow.getRowIndex() + 1;
0787:                        return true;
0788:                    }
0789:                } catch (AxionException e) {
0790:                    throw ExceptionConverter.convert(e);
0791:                }
0792:                return false;
0793:            }
0794:
0795:            public void moveToCurrentRow() throws SQLException {
0796:                assertOpen();
0797:                assertUpdateable();
0798:                clearInsertRow();
0799:            }
0800:
0801:            public void moveToInsertRow() throws SQLException {
0802:                assertOpen();
0803:                assertUpdateable();
0804:                createInsertRow();
0805:            }
0806:
0807:            public boolean next() throws SQLException {
0808:                assertOpen();
0809:                clearInsertOrUpdateIfAny();
0810:
0811:                if (_maxRows > 0 && _currentRowIndex >= _maxRows) {
0812:                    _afterLast = true;
0813:                    return false;
0814:                }
0815:
0816:                boolean result = false;
0817:                try {
0818:                    result = _rows.hasNext();
0819:                } catch (RuntimeException re) {
0820:                    throw ExceptionConverter.convert(re);
0821:                }
0822:
0823:                if (result) {
0824:                    try {
0825:                        if (DIR_REVERSE == _lastDir) {
0826:                            _rows.next();
0827:                        }
0828:                        _lastDir = DIR_FORWARD;
0829:
0830:                        if (_rows.hasNext()) {
0831:                            _afterLast = false;
0832:                            _currentRow = _rows.next();
0833:                            _currentRowIndex = _currentRow.getRowIndex() + 1;
0834:                        } else {
0835:                            _currentRowIndex++;
0836:                            _afterLast = true;
0837:                        }
0838:                    } catch (AxionException e) {
0839:                        throw ExceptionConverter.convert(e);
0840:                    }
0841:                } else {
0842:                    if (!_afterLast) {
0843:                        _currentRowIndex++;
0844:                    }
0845:                    _afterLast = true;
0846:                }
0847:
0848:                return result;
0849:            }
0850:
0851:            public boolean previous() throws SQLException {
0852:                assertOpen();
0853:                assertScrollable();
0854:                clearInsertOrUpdateIfAny();
0855:
0856:                if (_currentRowIndex <= 0) {
0857:                    return false;
0858:                }
0859:
0860:                boolean result = false;
0861:                try {
0862:                    result = _rows.hasPrevious();
0863:                } catch (RuntimeException re) {
0864:                    throw ExceptionConverter.convert(re);
0865:                }
0866:
0867:                if (result) {
0868:                    try {
0869:                        if (_afterLast && _rows.hasCurrent()) {
0870:                            _currentRow = _rows.current();
0871:                            _currentRowIndex = _currentRow.getRowIndex() + 1;
0872:                        } else if (isFirst()) {
0873:                            beforeFirst();
0874:                            _afterLast = false;
0875:                            return false;
0876:                        } else {
0877:                            if (!_afterLast && DIR_FORWARD == _lastDir) {
0878:                                _rows.previous();
0879:                            }
0880:                            _lastDir = DIR_REVERSE;
0881:                            _currentRow = _rows.previous();
0882:                            _currentRowIndex = _currentRow.getRowIndex() + 1;
0883:                        }
0884:
0885:                    } catch (AxionException e) {
0886:                        throw ExceptionConverter.convert(e);
0887:                    }
0888:                } else {
0889:                    beforeFirst();
0890:                }
0891:
0892:                _afterLast = false;
0893:                return result;
0894:            }
0895:
0896:            public void refreshRow() throws SQLException {
0897:                throw new SQLException("Not supported");
0898:            }
0899:
0900:            public boolean relative(int rows) throws SQLException {
0901:                assertOpen();
0902:                assertScrollable();
0903:
0904:                if (rows < 0) {
0905:                    return previous(-1 * rows);
0906:                }
0907:                return next(rows);
0908:            }
0909:
0910:            public boolean rowDeleted() throws SQLException {
0911:                return false;
0912:            }
0913:
0914:            public boolean rowInserted() throws SQLException {
0915:                return false;
0916:            }
0917:
0918:            public boolean rowUpdated() throws SQLException {
0919:                return false;
0920:            }
0921:
0922:            public void setFetchDirection(int direction) throws SQLException {
0923:                // fetchDirection is just a hint
0924:            }
0925:
0926:            public void setFetchSize(int size) throws SQLException {
0927:                // fetch size is just a hint
0928:            }
0929:
0930:            public void setMaxRows(int max) {
0931:                _maxRows = max;
0932:            }
0933:
0934:            public void setTransaction(TransactionManager manager,
0935:                    Transaction transaction) {
0936:                _transactionManager = manager;
0937:                _transaction = transaction;
0938:            }
0939:
0940:            /** Currently unsupported. */
0941:            public void updateArray(int arg0, Array arg1) throws SQLException {
0942:                throw new SQLException("updateArray is currently not supported");
0943:            }
0944:
0945:            public void updateArray(String colName, Array arg1)
0946:                    throws SQLException {
0947:                updateArray(getResultSetIndexForColumnName(colName), arg1);
0948:            }
0949:
0950:            public void updateAsciiStream(int i, InputStream in, int length)
0951:                    throws SQLException {
0952:                throw new SQLException("Not supported");
0953:            }
0954:
0955:            public void updateAsciiStream(String colName, InputStream in,
0956:                    int length) throws SQLException {
0957:                updateAsciiStream(getResultSetIndexForColumnName(colName), in,
0958:                        length);
0959:            }
0960:
0961:            public void updateBigDecimal(int i, BigDecimal value)
0962:                    throws SQLException {
0963:                setValue(i, value, USE_DEFAULT_SCALE);
0964:            }
0965:
0966:            public void updateBigDecimal(String colName, BigDecimal value)
0967:                    throws SQLException {
0968:                updateBigDecimal(getResultSetIndexForColumnName(colName), value);
0969:            }
0970:
0971:            public void updateBinaryStream(int i, InputStream value, int length)
0972:                    throws SQLException {
0973:                throw new SQLException("Not supported");
0974:            }
0975:
0976:            public void updateBinaryStream(String colName, InputStream value,
0977:                    int length) throws SQLException {
0978:                updateBinaryStream(getResultSetIndexForColumnName(colName),
0979:                        value, length);
0980:            }
0981:
0982:            /** Currently unsupported. */
0983:            public void updateBlob(int arg0, Blob arg1) throws SQLException {
0984:                throw new SQLException("updateBlob is currently not supported");
0985:            }
0986:
0987:            public void updateBlob(String colName, Blob arg1)
0988:                    throws SQLException {
0989:                updateBlob(getResultSetIndexForColumnName(colName), arg1);
0990:            }
0991:
0992:            public void updateBoolean(int i, boolean value) throws SQLException {
0993:                setValue(i, Boolean.valueOf(value), USE_DEFAULT_SCALE);
0994:            }
0995:
0996:            public void updateBoolean(String colName, boolean value)
0997:                    throws SQLException {
0998:                updateBoolean(getResultSetIndexForColumnName(colName), value);
0999:            }
1000:
1001:            public void updateByte(int i, byte value) throws SQLException {
1002:                setValue(i, new Byte(value), USE_DEFAULT_SCALE);
1003:            }
1004:
1005:            public void updateByte(String colName, byte value)
1006:                    throws SQLException {
1007:                updateByte(getResultSetIndexForColumnName(colName), value);
1008:            }
1009:
1010:            public void updateBytes(int i, byte[] value) throws SQLException {
1011:                setValue(i, value, USE_DEFAULT_SCALE);
1012:            }
1013:
1014:            public void updateBytes(String colName, byte[] value)
1015:                    throws SQLException {
1016:                updateBytes(getResultSetIndexForColumnName(colName), value);
1017:            }
1018:
1019:            public void updateCharacterStream(int i, Reader value, int length)
1020:                    throws SQLException {
1021:                throw new SQLException("Not supported");
1022:            }
1023:
1024:            public void updateCharacterStream(String colName, Reader value,
1025:                    int length) throws SQLException {
1026:                updateCharacterStream(getResultSetIndexForColumnName(colName),
1027:                        value, length);
1028:            }
1029:
1030:            /** Currently unsupported. */
1031:            public void updateClob(int arg0, Clob arg1) throws SQLException {
1032:                throw new SQLException("updateClob is currently not supported");
1033:            }
1034:
1035:            public void updateClob(String colName, Clob arg1)
1036:                    throws SQLException {
1037:                updateClob(getResultSetIndexForColumnName(colName), arg1);
1038:            }
1039:
1040:            public void updateDate(int i, Date value) throws SQLException {
1041:                setValue(i, value, USE_DEFAULT_SCALE);
1042:            }
1043:
1044:            public void updateDate(String colName, Date value)
1045:                    throws SQLException {
1046:                updateDate(getResultSetIndexForColumnName(colName), value);
1047:            }
1048:
1049:            public void updateDouble(int i, double value) throws SQLException {
1050:                setValue(i, new Double(value), USE_DEFAULT_SCALE);
1051:            }
1052:
1053:            public void updateDouble(String colName, double value)
1054:                    throws SQLException {
1055:                updateDouble(getResultSetIndexForColumnName(colName), value);
1056:            }
1057:
1058:            public void updateFloat(int i, float value) throws SQLException {
1059:                setValue(i, new Float(value), USE_DEFAULT_SCALE);
1060:            }
1061:
1062:            public void updateFloat(String colName, float value)
1063:                    throws SQLException {
1064:                updateFloat(getResultSetIndexForColumnName(colName), value);
1065:            }
1066:
1067:            public void updateInt(int i, int value) throws SQLException {
1068:                setValue(i, new Integer(value), USE_DEFAULT_SCALE);
1069:            }
1070:
1071:            public void updateInt(String colName, int value)
1072:                    throws SQLException {
1073:                updateInt(getResultSetIndexForColumnName(colName), value);
1074:            }
1075:
1076:            public void updateLong(int i, long value) throws SQLException {
1077:                setValue(i, new Long(value), USE_DEFAULT_SCALE);
1078:            }
1079:
1080:            public void updateLong(String colName, long value)
1081:                    throws SQLException {
1082:                updateLong(getResultSetIndexForColumnName(colName), value);
1083:            }
1084:
1085:            public void updateNull(int i) throws SQLException {
1086:                setValue(i, null, USE_DEFAULT_SCALE);
1087:            }
1088:
1089:            public void updateNull(String colName) throws SQLException {
1090:                updateNull(getResultSetIndexForColumnName(colName));
1091:            }
1092:
1093:            public void updateObject(int i, Object value) throws SQLException {
1094:                updateObject(i, value, USE_DEFAULT_SCALE);
1095:            }
1096:
1097:            public void updateObject(int i, Object value, int scale)
1098:                    throws SQLException {
1099:                setValue(i, value, scale);
1100:            }
1101:
1102:            public void updateObject(String colName, Object value)
1103:                    throws SQLException {
1104:                updateObject(getResultSetIndexForColumnName(colName), value);
1105:            }
1106:
1107:            public void updateObject(String colName, Object value, int scale)
1108:                    throws SQLException {
1109:                updateObject(getResultSetIndexForColumnName(colName), value,
1110:                        scale);
1111:            }
1112:
1113:            /** Currently unsupported. */
1114:            public void updateRef(int arg0, Ref arg1) throws SQLException {
1115:                throw new SQLException("updateRef is currently not supported");
1116:            }
1117:
1118:            public void updateRef(String colName, Ref arg1) throws SQLException {
1119:                updateRef(getResultSetIndexForColumnName(colName), arg1);
1120:            }
1121:
1122:            public void updateRow() throws SQLException {
1123:                assertOpen();
1124:
1125:                synchronized (_updateLock) {
1126:                    assertUpdateable();
1127:                    assertNotInInsertMode();
1128:                    assertUpdateRowExists();
1129:                    assertCurrentRow();
1130:
1131:                    try {
1132:                        _rows.getIterator().set(_insertUpdateRow);
1133:                        _currentRow = _rows.current();
1134:                    } catch (AxionException e) {
1135:                        handleExceptionOnInsertUpdate(e, "Cannot update row.");
1136:                    } catch (UnsupportedOperationException e) {
1137:                        throw new SQLException(
1138:                                "Cannot update row: table/view is not updateable.");
1139:                    }
1140:
1141:                    _insertUpdateRow = null;
1142:                }
1143:            }
1144:
1145:            public void updateShort(int i, short value) throws SQLException {
1146:                setValue(i, new Short(value), USE_DEFAULT_SCALE);
1147:            }
1148:
1149:            public void updateShort(String colName, short value)
1150:                    throws SQLException {
1151:                updateShort(getResultSetIndexForColumnName(colName), value);
1152:            }
1153:
1154:            public void updateString(int i, String value) throws SQLException {
1155:                setValue(i, value, USE_DEFAULT_SCALE);
1156:            }
1157:
1158:            public void updateString(String colName, String value)
1159:                    throws SQLException {
1160:                updateString(getResultSetIndexForColumnName(colName), value);
1161:            }
1162:
1163:            public void updateTime(int i, Time value) throws SQLException {
1164:                setValue(i, value, USE_DEFAULT_SCALE);
1165:            }
1166:
1167:            public void updateTime(String colName, Time value)
1168:                    throws SQLException {
1169:                updateTime(getResultSetIndexForColumnName(colName), value);
1170:            }
1171:
1172:            public void updateTimestamp(int i, Timestamp value)
1173:                    throws SQLException {
1174:                setValue(i, value, USE_DEFAULT_SCALE);
1175:            }
1176:
1177:            public void updateTimestamp(String colName, Timestamp value)
1178:                    throws SQLException {
1179:                updateTimestamp(getResultSetIndexForColumnName(colName), value);
1180:            }
1181:
1182:            public boolean wasNull() throws SQLException {
1183:                return _wasNull;
1184:            }
1185:
1186:            protected void setStatement(Statement stmt) {
1187:                _stmt = stmt;
1188:            }
1189:
1190:            /** Throw a {@link SQLException}if there is no {@link #_currentRow}. */
1191:            private final void assertCurrentRow() throws SQLException {
1192:                if (null == _currentRow) {
1193:                    throw new SQLException("No current row");
1194:                }
1195:            }
1196:
1197:            private final void assertInInsertMode() throws SQLException {
1198:                if (!_insertMode) {
1199:                    throw new SQLException(
1200:                            "Not in insert mode - operation failed.");
1201:                }
1202:            }
1203:
1204:            private final void assertNotInInsertMode() throws SQLException {
1205:                if (_insertMode) {
1206:                    throw new SQLException("In insert mode - operation failed.");
1207:                }
1208:            }
1209:
1210:            private final void assertOpen() throws SQLException {
1211:                if (_closed) {
1212:                    throw new SQLException("Already closed");
1213:                }
1214:            }
1215:
1216:            private final void assertScrollable() throws SQLException {
1217:                if (ResultSet.TYPE_FORWARD_ONLY == getType()) {
1218:                    throw new SQLException(
1219:                            "Invalid cursor movement request - ResultSet is forward-only.");
1220:                }
1221:            }
1222:
1223:            private final void assertUpdateable() throws SQLException {
1224:                if (ResultSet.CONCUR_UPDATABLE != getConcurrency()) {
1225:                    throw new SQLException(
1226:                            "Not an updateable ResultSet - operation failed.");
1227:                }
1228:            }
1229:
1230:            private final void assertUpdateRowExists() throws SQLException {
1231:                if (null == _insertUpdateRow) {
1232:                    throw new SQLException("No update row");
1233:                }
1234:            }
1235:
1236:            private void clearInsertOrUpdateIfAny() throws SQLException {
1237:                if (_insertUpdateRow != null) {
1238:                    if (_insertMode) {
1239:                        moveToCurrentRow();
1240:                    } else {
1241:                        cancelRowUpdates();
1242:                    }
1243:                }
1244:            }
1245:
1246:            private void clearInsertRow() {
1247:                synchronized (_updateLock) {
1248:                    clearUpdateRow();
1249:                    _insertMode = false;
1250:                }
1251:            }
1252:
1253:            private void clearUpdateRow() {
1254:                synchronized (_updateLock) {
1255:                    _insertUpdateRow = null;
1256:                }
1257:            }
1258:
1259:            private Row createInsertRow() throws SQLException {
1260:                synchronized (_updateLock) {
1261:                    _insertMode = true;
1262:                    _insertUpdateRow = new SimpleRow(_meta.getColumnCount());
1263:                }
1264:                return _insertUpdateRow;
1265:            }
1266:
1267:            /**
1268:             * Obtain the DataType for the given 1-based (ResultSet) index
1269:             */
1270:            private DataType getDataType(int num) throws SQLException {
1271:                Selectable sel = _selected[num - 1];
1272:                return sel.getDataType();
1273:            }
1274:
1275:            private Row getOrCreateUpdateRow() throws SQLException {
1276:                assertCurrentRow();
1277:
1278:                synchronized (_updateLock) {
1279:                    if (null == _insertUpdateRow) {
1280:                        _insertUpdateRow = new SimpleRow(_currentRow.getRow());
1281:                    }
1282:                    return _insertUpdateRow;
1283:                }
1284:            }
1285:
1286:            //------------------------------------------------------------ Private Util
1287:
1288:            /**
1289:             * Get the 1-based ResultSet index for the specified column name.
1290:             */
1291:            private int getResultSetIndexForColumnName(String columnname)
1292:                    throws SQLException {
1293:                ColumnIdentifier id = null;
1294:                columnname = columnname.toUpperCase();
1295:                for (int i = 0; i < _selected.length; i++) {
1296:                    if (_selected[i] instanceof  ColumnIdentifier) {
1297:                        id = (ColumnIdentifier) (_selected[i]);
1298:                        if (columnname.equals(id.getName())
1299:                                || columnname.equals(id.getAlias())) {
1300:                            return (i + 1);
1301:                        }
1302:                    }
1303:                }
1304:                throw new SQLException("No column named " + columnname
1305:                        + " found.");
1306:            }
1307:
1308:            /**
1309:             * Obtain the value from the current row for the given 1-based (ResultSet) index, and
1310:             * convert it according to the corresponding {@link DataType}
1311:             */
1312:            private Object getValue(int num) throws SQLException {
1313:                assertOpen();
1314:                Object val = null;
1315:
1316:                if (_insertMode) {
1317:                    val = _insertUpdateRow.get(num - 1);
1318:                } else {
1319:                    assertCurrentRow();
1320:
1321:                    Selectable sel = _selected[num - 1];
1322:                    try {
1323:                        val = sel.evaluate(_currentRow);
1324:                    } catch (AxionException e) {
1325:                        throw ExceptionConverter.convert(e);
1326:                    }
1327:                }
1328:
1329:                _wasNull = (null == val);
1330:                return val;
1331:            }
1332:
1333:            private void handleExceptionOnInsertUpdate(AxionException e,
1334:                    String defaultMessage) throws SQLException {
1335:                if (!"99999".equals(e.getSQLState())) {
1336:                    if (e instanceof  ConstraintViolationException) {
1337:                        if ("NOT NULL"
1338:                                .equals(((ConstraintViolationException) e)
1339:                                        .getConstraintType())) {
1340:                            throw new SQLException(e.getMessage(), "22004");
1341:                        }
1342:                    }
1343:                    throw new SQLException(e.getMessage(), e.getSQLState());
1344:                } else {
1345:                    throw new SQLException(defaultMessage);
1346:                }
1347:            }
1348:
1349:            /** move forward n rows, i.e., call next() n times */
1350:            private boolean next(int n) throws SQLException {
1351:                boolean result = (null != _currentRow);
1352:                for (int i = 0; i < n; i++) {
1353:                    result = next();
1354:                }
1355:                return result;
1356:            }
1357:
1358:            /** move backward n rows, i.e., call previous() n times */
1359:            private boolean previous(int n) throws SQLException {
1360:                boolean result = (null != _currentRow);
1361:                for (int i = 0; i < n; i++) {
1362:                    result = previous();
1363:                }
1364:                return result;
1365:            }
1366:
1367:            /**
1368:             * Sets value of the given row in the update row cache for the given 1-based (ResultSet) index,
1369:             * converting it as appropriate to the corresponding {@link DataType}
1370:             * 
1371:             * @param num (1-based) column index 
1372:             * @param value new column value
1373:             * @param scale for {@link Types#DECIMAL} or {@link Types#NUMERIC} types, this is the number of 
1374:             * digits after the decimal point.  For all other types this value will be ignored.
1375:             *  
1376:             * @throws SQLException
1377:             */
1378:            private void setValue(int num, Object value, int scale)
1379:                    throws SQLException {
1380:                assertUpdateable();
1381:
1382:                DataType type = getDataType(num);
1383:                synchronized (_updateLock) {
1384:                    Row row = (_insertMode) ? _insertUpdateRow
1385:                            : getOrCreateUpdateRow();
1386:                    try {
1387:                        row.set(num - 1, type.convert(value));
1388:                    } catch (UnsupportedOperationException e) {
1389:                        ExceptionConverter.convert(e);
1390:                    } catch (AxionException e) {
1391:                        ExceptionConverter.convert(e);
1392:                    }
1393:                }
1394:            }
1395:
1396:            protected RowDecoratorIterator _rows = null;
1397:            private boolean _afterLast = false;
1398:            private boolean _closed = false;
1399:            private RowDecorator _currentRow = null;
1400:            private int _currentRowIndex = 0;
1401:            private boolean _insertMode = false;
1402:            private Row _insertUpdateRow = null;
1403:            private int _lastDir = DIR_UNKNOWN;
1404:            private int _maxRows = 0;
1405:            private ResultSetMetaData _meta = null;
1406:            private Selectable[] _selected = null;
1407:            private Statement _stmt = null;
1408:
1409:            private Transaction _transaction = null;
1410:            private TransactionManager _transactionManager = null;
1411:            private Object _updateLock = new Object();
1412:            private SQLWarning _warning = null;
1413:
1414:            /** Whether the last value returned was NULL. */
1415:            private boolean _wasNull = false;
1416:
1417:            @Override
1418:            public int getHoldability() throws SQLException {
1419:                throw new SQLException("Not supported");
1420:            }
1421:
1422:            @Override
1423:            public Reader getNCharacterStream(int arg0) throws SQLException {
1424:                throw new SQLException("Not supported");
1425:            }
1426:
1427:            @Override
1428:            public Reader getNCharacterStream(String arg0) throws SQLException {
1429:                throw new SQLException("Not supported.");
1430:            }
1431:
1432:            @Override
1433:            public NClob getNClob(int arg0) throws SQLException {
1434:                throw new SQLException("Not supported.");
1435:            }
1436:
1437:            @Override
1438:            public NClob getNClob(String arg0) throws SQLException {
1439:                throw new SQLException("Not supported.");
1440:            }
1441:
1442:            @Override
1443:            public String getNString(int arg0) throws SQLException {
1444:                throw new SQLException("Not supported.");
1445:            }
1446:
1447:            @Override
1448:            public String getNString(String arg0) throws SQLException {
1449:                throw new SQLException("Not supported.");
1450:            }
1451:
1452:            @Override
1453:            public Object getObject(int arg0, Map<String, Class<?>> arg1)
1454:                    throws SQLException {
1455:                throw new SQLException("Not supported.");
1456:            }
1457:
1458:            @Override
1459:            public Object getObject(String arg0, Map<String, Class<?>> arg1)
1460:                    throws SQLException {
1461:                throw new SQLException("Not supported.");
1462:            }
1463:
1464:            @Override
1465:            public RowId getRowId(int arg0) throws SQLException {
1466:                throw new SQLException("Not supported.");
1467:            }
1468:
1469:            @Override
1470:            public RowId getRowId(String arg0) throws SQLException {
1471:                throw new SQLException("Not supported.");
1472:            }
1473:
1474:            @Override
1475:            public SQLXML getSQLXML(int arg0) throws SQLException {
1476:                throw new SQLException("Not supported.");
1477:            }
1478:
1479:            @Override
1480:            public SQLXML getSQLXML(String arg0) throws SQLException {
1481:                throw new SQLException("Not supported.");
1482:            }
1483:
1484:            @Override
1485:            public boolean isClosed() throws SQLException {
1486:                throw new SQLException("Not supported.");
1487:            }
1488:
1489:            @Override
1490:            public void updateAsciiStream(int arg0, InputStream arg1)
1491:                    throws SQLException {
1492:                throw new SQLException("Not supported.");
1493:            }
1494:
1495:            @Override
1496:            public void updateAsciiStream(String arg0, InputStream arg1)
1497:                    throws SQLException {
1498:                throw new SQLException("Not supported.");
1499:            }
1500:
1501:            @Override
1502:            public void updateAsciiStream(int arg0, InputStream arg1, long arg2)
1503:                    throws SQLException {
1504:                throw new SQLException("Not supported.");
1505:            }
1506:
1507:            @Override
1508:            public void updateAsciiStream(String arg0, InputStream arg1,
1509:                    long arg2) throws SQLException {
1510:                throw new SQLException("Not supported.");
1511:            }
1512:
1513:            @Override
1514:            public void updateBinaryStream(int arg0, InputStream arg1)
1515:                    throws SQLException {
1516:                throw new SQLException("Not supported.");
1517:            }
1518:
1519:            @Override
1520:            public void updateBinaryStream(String arg0, InputStream arg1)
1521:                    throws SQLException {
1522:                throw new SQLException("Not supported.");
1523:            }
1524:
1525:            @Override
1526:            public void updateBinaryStream(int arg0, InputStream arg1, long arg2)
1527:                    throws SQLException {
1528:                throw new SQLException("Not supported.");
1529:            }
1530:
1531:            @Override
1532:            public void updateBinaryStream(String arg0, InputStream arg1,
1533:                    long arg2) throws SQLException {
1534:                throw new SQLException("Not supported.");
1535:            }
1536:
1537:            @Override
1538:            public void updateBlob(int arg0, InputStream arg1)
1539:                    throws SQLException {
1540:                throw new SQLException("Not supported.");
1541:            }
1542:
1543:            @Override
1544:            public void updateBlob(String arg0, InputStream arg1)
1545:                    throws SQLException {
1546:                throw new SQLException("Not supported.");
1547:            }
1548:
1549:            @Override
1550:            public void updateBlob(int arg0, InputStream arg1, long arg2)
1551:                    throws SQLException {
1552:                throw new SQLException("Not supported.");
1553:            }
1554:
1555:            @Override
1556:            public void updateBlob(String arg0, InputStream arg1, long arg2)
1557:                    throws SQLException {
1558:                throw new SQLException("Not supported.");
1559:            }
1560:
1561:            @Override
1562:            public void updateCharacterStream(int arg0, Reader arg1)
1563:                    throws SQLException {
1564:                throw new SQLException("Not supported.");
1565:            }
1566:
1567:            @Override
1568:            public void updateCharacterStream(String arg0, Reader arg1)
1569:                    throws SQLException {
1570:                throw new SQLException("Not supported.");
1571:            }
1572:
1573:            @Override
1574:            public void updateCharacterStream(int arg0, Reader arg1, long arg2)
1575:                    throws SQLException {
1576:                throw new SQLException("Not supported.");
1577:            }
1578:
1579:            @Override
1580:            public void updateCharacterStream(String arg0, Reader arg1,
1581:                    long arg2) throws SQLException {
1582:                throw new SQLException("Not supported.");
1583:            }
1584:
1585:            @Override
1586:            public void updateClob(int arg0, Reader arg1) throws SQLException {
1587:                throw new SQLException("Not supported.");
1588:            }
1589:
1590:            @Override
1591:            public void updateClob(String arg0, Reader arg1)
1592:                    throws SQLException {
1593:                throw new SQLException("Not supported.");
1594:            }
1595:
1596:            @Override
1597:            public void updateClob(int arg0, Reader arg1, long arg2)
1598:                    throws SQLException {
1599:                throw new SQLException("Not supported.");
1600:            }
1601:
1602:            @Override
1603:            public void updateClob(String arg0, Reader arg1, long arg2)
1604:                    throws SQLException {
1605:                throw new SQLException("Not supported.");
1606:            }
1607:
1608:            @Override
1609:            public void updateNCharacterStream(int arg0, Reader arg1)
1610:                    throws SQLException {
1611:                throw new SQLException("Not supported.");
1612:            }
1613:
1614:            @Override
1615:            public void updateNCharacterStream(String arg0, Reader arg1)
1616:                    throws SQLException {
1617:                throw new SQLException("Not supported.");
1618:            }
1619:
1620:            @Override
1621:            public void updateNCharacterStream(int arg0, Reader arg1, long arg2)
1622:                    throws SQLException {
1623:                throw new SQLException("Not supported.");
1624:            }
1625:
1626:            @Override
1627:            public void updateNCharacterStream(String arg0, Reader arg1,
1628:                    long arg2) throws SQLException {
1629:                throw new SQLException("Not supported.");
1630:            }
1631:
1632:            @Override
1633:            public void updateNClob(int arg0, NClob arg1) throws SQLException {
1634:                throw new SQLException("Not supported.");
1635:            }
1636:
1637:            @Override
1638:            public void updateNClob(String arg0, NClob arg1)
1639:                    throws SQLException {
1640:                throw new SQLException("Not supported.");
1641:            }
1642:
1643:            @Override
1644:            public void updateNClob(int arg0, Reader arg1) throws SQLException {
1645:                throw new SQLException("Not supported.");
1646:            }
1647:
1648:            @Override
1649:            public void updateNClob(String arg0, Reader arg1)
1650:                    throws SQLException {
1651:                throw new SQLException("Not supported.");
1652:            }
1653:
1654:            @Override
1655:            public void updateNClob(int arg0, Reader arg1, long arg2)
1656:                    throws SQLException {
1657:                throw new SQLException("Not supported.");
1658:            }
1659:
1660:            @Override
1661:            public void updateNClob(String arg0, Reader arg1, long arg2)
1662:                    throws SQLException {
1663:                throw new SQLException("Not supported.");
1664:            }
1665:
1666:            @Override
1667:            public void updateNString(int arg0, String arg1)
1668:                    throws SQLException {
1669:                throw new SQLException("Not supported.");
1670:            }
1671:
1672:            @Override
1673:            public void updateNString(String arg0, String arg1)
1674:                    throws SQLException {
1675:                throw new SQLException("Not supported.");
1676:            }
1677:
1678:            @Override
1679:            public void updateRowId(int arg0, RowId arg1) throws SQLException {
1680:                throw new SQLException("Not supported.");
1681:            }
1682:
1683:            @Override
1684:            public void updateRowId(String arg0, RowId arg1)
1685:                    throws SQLException {
1686:                throw new SQLException("Not supported.");
1687:            }
1688:
1689:            @Override
1690:            public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException {
1691:                throw new SQLException("Not supported.");
1692:            }
1693:
1694:            @Override
1695:            public void updateSQLXML(String arg0, SQLXML arg1)
1696:                    throws SQLException {
1697:                throw new SQLException("Not supported.");
1698:            }
1699:
1700:            @Override
1701:            public boolean isWrapperFor(Class<?> arg0) throws SQLException {
1702:                throw new SQLException("Not supported.");
1703:            }
1704:
1705:            @Override
1706:            public <T> T unwrap(Class<T> arg0) throws SQLException {
1707:                throw new SQLException("Not supported.");
1708:            }
1709:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.