1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 package com.sun.star.comp.sdbc;
22 
23 import java.io.InputStreamReader;
24 import java.math.BigDecimal;
25 import java.nio.charset.Charset;
26 
27 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySet;
28 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertyGetter;
29 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertySetter;
30 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger;
31 import org.apache.openoffice.comp.sdbc.dbtools.util.DBTypeConversion;
32 import org.apache.openoffice.comp.sdbc.dbtools.util.DbTools;
33 import org.apache.openoffice.comp.sdbc.dbtools.util.PropertyIds;
34 import org.apache.openoffice.comp.sdbc.dbtools.util.Resources;
35 import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources;
36 import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState;
37 
38 import com.sun.star.beans.PropertyAttribute;
39 import com.sun.star.beans.PropertyVetoException;
40 import com.sun.star.comp.sdbc.ConnectionLog.ObjectType;
41 import com.sun.star.container.XNameAccess;
42 import com.sun.star.io.XInputStream;
43 import com.sun.star.lang.IllegalArgumentException;
44 import com.sun.star.lang.WrappedTargetException;
45 import com.sun.star.lang.XServiceInfo;
46 import com.sun.star.lib.uno.adapter.InputStreamToXInputStreamAdapter;
47 import com.sun.star.lib.uno.adapter.XInputStreamToInputStreamAdapter;
48 import com.sun.star.logging.LogLevel;
49 import com.sun.star.sdbc.SQLException;
50 import com.sun.star.sdbc.SQLWarning;
51 import com.sun.star.sdbc.XArray;
52 import com.sun.star.sdbc.XBlob;
53 import com.sun.star.sdbc.XClob;
54 import com.sun.star.sdbc.XCloseable;
55 import com.sun.star.sdbc.XColumnLocate;
56 import com.sun.star.sdbc.XRef;
57 import com.sun.star.sdbc.XResultSet;
58 import com.sun.star.sdbc.XResultSetMetaData;
59 import com.sun.star.sdbc.XResultSetMetaDataSupplier;
60 import com.sun.star.sdbc.XResultSetUpdate;
61 import com.sun.star.sdbc.XRow;
62 import com.sun.star.sdbc.XRowUpdate;
63 import com.sun.star.sdbc.XWarningsSupplier;
64 import com.sun.star.uno.Any;
65 import com.sun.star.uno.AnyConverter;
66 import com.sun.star.uno.Type;
67 import com.sun.star.util.Date;
68 import com.sun.star.util.DateTime;
69 import com.sun.star.util.Time;
70 
71 public class JavaSQLResultSet extends PropertySet
72         implements XResultSet, XRow, XResultSetMetaDataSupplier,
73             XWarningsSupplier, XResultSetUpdate, XRowUpdate, XCloseable,
74             XColumnLocate, XServiceInfo {
75 
76     private static final String[] services = {
77             "com.sun.star.sdbc.ResultSet"
78     };
79 
80     private java.sql.ResultSet jdbcResultSet;
81     private JavaSQLConnection connection;
82     private Object statement;
83     private ResourceBasedEventLogger logger;
84 
JavaSQLResultSet(java.sql.ResultSet jdbcResultSet, JavaSQLConnection connection)85     public JavaSQLResultSet(java.sql.ResultSet jdbcResultSet, JavaSQLConnection connection) {
86         this (jdbcResultSet, connection, null);
87     }
88 
JavaSQLResultSet(java.sql.ResultSet jdbcResultSet, JavaSQLConnection connection, Object statement)89     public JavaSQLResultSet(java.sql.ResultSet jdbcResultSet, JavaSQLConnection connection, Object statement) {
90         this.jdbcResultSet = jdbcResultSet;
91         this.connection = connection;
92         this.statement = statement;
93         logger = new ConnectionLog(connection.getLogger(), ObjectType.RESULT);
94         registerProperties();
95     }
96 
97     // XComponent
98 
99     @Override
postDisposing()100     protected synchronized void postDisposing() {
101         super.postDisposing();
102         if (jdbcResultSet != null) {
103             try {
104                 jdbcResultSet.close();
105             } catch (java.sql.SQLException jdbcSqlException) {
106                 logger.log(LogLevel.WARNING, jdbcSqlException);
107             }
108             jdbcResultSet = null;
109         }
110     }
111 
112     // XCloseable
113 
114     @Override
close()115     public void close() throws SQLException {
116         dispose();
117     }
118 
119     // XServiceInfo
120 
121     @Override
getImplementationName()122     public String getImplementationName() {
123         return "com.sun.star.sdbcx.JResultSet";
124     }
125 
126     @Override
getSupportedServiceNames()127     public String[] getSupportedServiceNames() {
128         return services.clone();
129     }
130 
131     @Override
supportsService(String serviceName)132     public boolean supportsService(String serviceName) {
133         for (String service : services) {
134             if (service.equals(serviceName)) {
135                 return true;
136             }
137         }
138         return false;
139     }
140 
141     // XPropertySet
142 
registerProperties()143     private void registerProperties() {
144         registerProperty(PropertyIds.CURSORNAME.name, PropertyIds.CURSORNAME.id, Type.STRING, (short)PropertyAttribute.READONLY,
145                 new PropertyGetter() {
146                     @Override
147                     public Object getValue() throws WrappedTargetException {
148                         return getCursorName();
149                     }
150                 }, null);
151         registerProperty(PropertyIds.RESULTSETCONCURRENCY.name, PropertyIds.RESULTSETCONCURRENCY.id,
152                 Type.LONG, (short)PropertyAttribute.READONLY,
153                 new PropertyGetter() {
154                     @Override
155                     public Object getValue() throws WrappedTargetException {
156                         return getResultSetConcurrency();
157                     }
158                 }, null);
159         registerProperty(PropertyIds.RESULTSETTYPE.name, PropertyIds.RESULTSETTYPE.id,
160                 Type.LONG, (short)PropertyAttribute.READONLY,
161                 new PropertyGetter() {
162                     @Override
163                     public Object getValue() throws WrappedTargetException {
164                         return getResultSetType();
165                     }
166                 }, null);
167         registerProperty(PropertyIds.FETCHDIRECTION.name, PropertyIds.FETCHDIRECTION.id,
168                 Type.LONG, (short)0,
169                 new PropertyGetter() {
170                     @Override
171                     public Object getValue() throws WrappedTargetException {
172                         return getFetchDirection();
173                     }
174                 },
175                 new PropertySetter() {
176                     @Override
177                     public void setValue(Object value) throws PropertyVetoException, IllegalArgumentException, WrappedTargetException {
178                         setFetchDirection((int)value);
179                     }
180                 });
181         registerProperty(PropertyIds.FETCHSIZE.name, PropertyIds.FETCHSIZE.id,
182                 Type.LONG, (short)0,
183                 new PropertyGetter() {
184                     @Override
185                     public Object getValue() throws WrappedTargetException {
186                         return getFetchSize();
187                     }
188                 },
189                 new PropertySetter() {
190                     @Override
191                     public void setValue(Object value) throws PropertyVetoException, IllegalArgumentException, WrappedTargetException {
192                         setFetchSize((int)value);
193                     }
194                 });
195     }
196 
getCursorName()197     private String getCursorName() throws WrappedTargetException {
198         try {
199             String cursorName = jdbcResultSet.getCursorName();
200             if (cursorName == null) {
201                 cursorName = "";
202             }
203             return cursorName;
204         } catch (java.sql.SQLException exception) {
205             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
206         }
207     }
208 
getFetchDirection()209     private int getFetchDirection() throws WrappedTargetException {
210         try {
211             return jdbcResultSet.getFetchDirection();
212         } catch (java.sql.SQLException exception) {
213             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
214         }
215     }
216 
setFetchDirection(int value)217     private void setFetchDirection(int value) throws WrappedTargetException {
218         try {
219             jdbcResultSet.setFetchDirection(value);
220         } catch (java.sql.SQLException exception) {
221             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
222         }
223     }
224 
getFetchSize()225     private int getFetchSize() throws WrappedTargetException {
226         try {
227             return jdbcResultSet.getFetchSize();
228         } catch (java.sql.SQLException exception) {
229             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
230         }
231     }
232 
setFetchSize(int value)233     private void setFetchSize(int value) throws WrappedTargetException {
234         try {
235             jdbcResultSet.setFetchSize(value);
236         } catch (java.sql.SQLException exception) {
237             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
238         }
239     }
240 
getResultSetConcurrency()241     private int getResultSetConcurrency() throws WrappedTargetException {
242         try {
243             return jdbcResultSet.getConcurrency();
244         } catch (java.sql.SQLException exception) {
245             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
246         }
247     }
248 
getResultSetType()249     private int getResultSetType() throws WrappedTargetException {
250         try {
251             return jdbcResultSet.getType();
252         } catch (java.sql.SQLException exception) {
253             throw new WrappedTargetException("SQL error", this, Tools.toUnoException(this, exception));
254         }
255     }
256 
257     // everything else
258 
259     @Override
findColumn(String columnName)260     public int findColumn(String columnName) throws SQLException {
261         try {
262             return jdbcResultSet.findColumn(columnName);
263         } catch (java.sql.SQLException exception) {
264             throw Tools.toUnoException(this, exception);
265         }
266     }
267 
268     @Override
getBinaryStream(int columnIndex)269     public XInputStream getBinaryStream(int columnIndex) throws SQLException {
270         try {
271             return new InputStreamToXInputStreamAdapter(jdbcResultSet.getBinaryStream(columnIndex));
272         } catch (java.sql.SQLException exception) {
273             throw Tools.toUnoException(this, exception);
274         }
275     }
276 
277     @Override
getCharacterStream(int columnIndex)278     public XInputStream getCharacterStream(int columnIndex) throws SQLException {
279         try {
280             return new InputStreamToXInputStreamAdapter(new ReaderInputStream(jdbcResultSet.getCharacterStream(columnIndex)));
281         } catch (java.sql.SQLException exception) {
282             throw Tools.toUnoException(this, exception);
283         }
284     }
285 
286     @Override
getBoolean(int columnIndex)287     public boolean getBoolean(int columnIndex) throws SQLException {
288         try {
289             return jdbcResultSet.getBoolean(columnIndex);
290         } catch (java.sql.SQLException exception) {
291             throw Tools.toUnoException(this, exception);
292         }
293     }
294 
295     @Override
getByte(int columnIndex)296     public byte getByte(int columnIndex) throws SQLException {
297         try {
298             return jdbcResultSet.getByte(columnIndex);
299         } catch (java.sql.SQLException exception) {
300             throw Tools.toUnoException(this, exception);
301         }
302     }
303 
304     @Override
getBytes(int columnIndex)305     public byte[] getBytes(int columnIndex) throws SQLException {
306         try {
307             return jdbcResultSet.getBytes(columnIndex);
308         } catch (java.sql.SQLException exception) {
309             throw Tools.toUnoException(this, exception);
310         }
311     }
312 
313     @Override
getDate(int columnIndex)314     public Date getDate(int columnIndex) throws SQLException {
315         try {
316             java.sql.Date jdbcDate = jdbcResultSet.getDate(columnIndex);
317             if (jdbcDate != null) {
318                 return DBTypeConversion.toDate(jdbcDate.toString());
319             } else {
320                 return null;
321             }
322         } catch (java.sql.SQLException exception) {
323             throw Tools.toUnoException(this, exception);
324         }
325     }
326 
327     @Override
getDouble(int columnIndex)328     public double getDouble(int columnIndex) throws SQLException {
329         try {
330             return jdbcResultSet.getDouble(columnIndex);
331         } catch (java.sql.SQLException exception) {
332             throw Tools.toUnoException(this, exception);
333         }
334     }
335 
336     @Override
getFloat(int columnIndex)337     public float getFloat(int columnIndex) throws SQLException {
338         try {
339             return jdbcResultSet.getFloat(columnIndex);
340         } catch (java.sql.SQLException exception) {
341             throw Tools.toUnoException(this, exception);
342         }
343     }
344 
345     @Override
getInt(int columnIndex)346     public int getInt(int columnIndex) throws SQLException {
347         try {
348             return jdbcResultSet.getInt(columnIndex);
349         } catch (java.sql.SQLException exception) {
350             throw Tools.toUnoException(this, exception);
351         }
352     }
353 
354     @Override
getRow()355     public int getRow() throws SQLException {
356         try {
357             return jdbcResultSet.getRow();
358         } catch (java.sql.SQLException exception) {
359             throw Tools.toUnoException(this, exception);
360         }
361     }
362 
363     @Override
getLong(int columnIndex)364     public long getLong(int columnIndex) throws SQLException {
365         try {
366             return jdbcResultSet.getLong(columnIndex);
367         } catch (java.sql.SQLException exception) {
368             throw Tools.toUnoException(this, exception);
369         }
370     }
371 
372     @Override
getMetaData()373     public XResultSetMetaData getMetaData() throws SQLException {
374         try {
375             java.sql.ResultSetMetaData jdbcMetaData = jdbcResultSet.getMetaData();
376             if (jdbcMetaData != null) {
377                 return new JavaSQLResultSetMetaData(connection, jdbcMetaData);
378             } else {
379                 return null;
380             }
381         } catch (java.sql.SQLException exception) {
382             throw Tools.toUnoException(this, exception);
383         }
384     }
385 
386     @Override
getArray(int columnIndex)387     public XArray getArray(int columnIndex) throws SQLException {
388         try {
389             java.sql.Array array = jdbcResultSet.getArray(columnIndex);
390             if (array != null) {
391                 return new JavaSQLArray(logger, array);
392             } else {
393                 return null;
394             }
395         } catch (java.sql.SQLException exception) {
396             throw Tools.toUnoException(this, exception);
397         }
398     }
399 
400     @Override
getClob(int columnIndex)401     public XClob getClob(int columnIndex) throws SQLException {
402         try {
403             java.sql.Clob clob = jdbcResultSet.getClob(columnIndex);
404             if (clob != null) {
405                 return new JavaSQLClob(logger, clob);
406             } else {
407                 return null;
408             }
409         } catch (java.sql.SQLException exception) {
410             throw Tools.toUnoException(this, exception);
411         }
412     }
413 
414     @Override
getBlob(int columnIndex)415     public XBlob getBlob(int columnIndex) throws SQLException {
416         try {
417             java.sql.Blob blob = jdbcResultSet.getBlob(columnIndex);
418             if (blob != null) {
419                 return new JavaSQLBlob(logger, blob);
420             } else {
421                 return null;
422             }
423         } catch (java.sql.SQLException exception) {
424             throw Tools.toUnoException(this, exception);
425         }
426     }
427 
428     @Override
getRef(int columnIndex)429     public XRef getRef(int columnIndex) throws SQLException {
430         try {
431             java.sql.Ref ref = jdbcResultSet.getRef(columnIndex);
432             if (ref != null) {
433                 return new JavaSQLRef(ref);
434             } else {
435                 return null;
436             }
437         } catch (java.sql.SQLException exception) {
438             throw Tools.toUnoException(this, exception);
439         }
440     }
441 
442     @Override
getObject(int columnIndex, XNameAccess typeMap)443     public Object getObject(int columnIndex, XNameAccess typeMap) throws SQLException {
444         if (typeMap.hasElements()) {
445             throw new SQLException(
446                     SharedResources.getInstance().getResourceStringWithSubstitution(
447                             Resources.STR_UNSUPPORTED_FEATURE, "$featurename$", "Type maps"),
448                     this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0, Any.VOID);
449         }
450         try {
451             Object ret = Any.VOID;
452             Object object = jdbcResultSet.getObject(columnIndex);
453             if (object instanceof String) {
454                 ret = (String) object;
455             } else if (object instanceof Boolean) {
456                 ret = (Boolean) object;
457             } else if (object instanceof java.sql.Date) {
458                 ret = DBTypeConversion.toDate(((java.sql.Date)object).toString());
459             } else if (object instanceof java.sql.Time) {
460                 ret = DBTypeConversion.toTime(((java.sql.Time)object).toString());
461             } else if (object instanceof java.sql.Timestamp) {
462                 ret = DBTypeConversion.toDateTime(((java.sql.Timestamp)object).toString());
463             }
464             return ret;
465         } catch (java.sql.SQLException exception) {
466             throw Tools.toUnoExceptionLogged(this, logger, exception);
467         }
468     }
469 
470     @Override
getShort(int columnIndex)471     public short getShort(int columnIndex) throws SQLException {
472         try {
473             return jdbcResultSet.getShort(columnIndex);
474         } catch (java.sql.SQLException exception) {
475             throw Tools.toUnoException(this, exception);
476         }
477     }
478 
479     @Override
getString(int columnIndex)480     public String getString(int columnIndex) throws SQLException {
481         try {
482             String string = jdbcResultSet.getString(columnIndex);
483             if (string != null) {
484                 return string;
485             } else {
486                 return "";
487             }
488         } catch (java.sql.SQLException exception) {
489             throw Tools.toUnoException(this, exception);
490         }
491     }
492 
493     @Override
getTime(int columnIndex)494     public Time getTime(int columnIndex) throws SQLException {
495         try {
496             java.sql.Time time = jdbcResultSet.getTime(columnIndex);
497             if (time != null) {
498                 return DBTypeConversion.toTime(time.toString());
499             } else {
500                 return new Time();
501             }
502         } catch (java.sql.SQLException exception) {
503             throw Tools.toUnoException(this, exception);
504         }
505     }
506 
507     @Override
getTimestamp(int columnIndex)508     public DateTime getTimestamp(int columnIndex) throws SQLException {
509         try {
510             java.sql.Timestamp timestamp = jdbcResultSet.getTimestamp(columnIndex);
511             if (timestamp != null) {
512                 return DBTypeConversion.toDateTime(timestamp.toString());
513             } else {
514                 return new DateTime();
515             }
516         } catch (java.sql.SQLException exception) {
517             throw Tools.toUnoException(this, exception);
518         }
519     }
520 
521     @Override
isAfterLast()522     public boolean isAfterLast() throws SQLException {
523         try {
524             return jdbcResultSet.isAfterLast();
525         } catch (java.sql.SQLException exception) {
526             throw Tools.toUnoException(this, exception);
527         }
528     }
529 
530     @Override
isFirst()531     public boolean isFirst() throws SQLException {
532         try {
533             return jdbcResultSet.isFirst();
534         } catch (java.sql.SQLException exception) {
535             throw Tools.toUnoException(this, exception);
536         }
537     }
538 
539     @Override
isLast()540     public boolean isLast() throws SQLException {
541         try {
542             return jdbcResultSet.isLast();
543         } catch (java.sql.SQLException exception) {
544             throw Tools.toUnoException(this, exception);
545         }
546     }
547 
548     @Override
beforeFirst()549     public void beforeFirst() throws SQLException {
550         try {
551             jdbcResultSet.beforeFirst();
552         } catch (java.sql.SQLException exception) {
553             throw Tools.toUnoException(this, exception);
554         }
555     }
556 
557     @Override
afterLast()558     public void afterLast() throws SQLException {
559         try {
560             jdbcResultSet.afterLast();
561         } catch (java.sql.SQLException exception) {
562             throw Tools.toUnoException(this, exception);
563         }
564     }
565 
566     @Override
first()567     public boolean first() throws SQLException {
568         try {
569             return jdbcResultSet.first();
570         } catch (java.sql.SQLException exception) {
571             throw Tools.toUnoException(this, exception);
572         }
573     }
574 
575     @Override
last()576     public boolean last() throws SQLException {
577         try {
578             return jdbcResultSet.last();
579         } catch (java.sql.SQLException exception) {
580             throw Tools.toUnoException(this, exception);
581         }
582     }
583 
584     @Override
absolute(int row)585     public boolean absolute(int row) throws SQLException {
586         try {
587             return jdbcResultSet.absolute(row);
588         } catch (java.sql.SQLException exception) {
589             throw Tools.toUnoException(this, exception);
590         }
591     }
592 
593     @Override
relative(int row)594     public boolean relative(int row) throws SQLException {
595         try {
596             return jdbcResultSet.relative(row);
597         } catch (java.sql.SQLException exception) {
598             throw Tools.toUnoException(this, exception);
599         }
600     }
601 
602     @Override
previous()603     public boolean previous() throws SQLException {
604         try {
605             return jdbcResultSet.previous();
606         } catch (java.sql.SQLException exception) {
607             throw Tools.toUnoException(this, exception);
608         }
609     }
610 
611     @Override
getStatement()612     public Object getStatement() throws SQLException {
613         return statement;
614     }
615 
616     @Override
rowDeleted()617     public boolean rowDeleted() throws SQLException {
618         try {
619             return jdbcResultSet.rowDeleted();
620         } catch (java.sql.SQLException exception) {
621             throw Tools.toUnoException(this, exception);
622         }
623     }
624 
625     @Override
rowInserted()626     public boolean rowInserted() throws SQLException {
627         try {
628             return jdbcResultSet.rowInserted();
629         } catch (java.sql.SQLException exception) {
630             throw Tools.toUnoException(this, exception);
631         }
632     }
633 
634     @Override
rowUpdated()635     public boolean rowUpdated() throws SQLException {
636         try {
637             return jdbcResultSet.rowUpdated();
638         } catch (java.sql.SQLException exception) {
639             throw Tools.toUnoException(this, exception);
640         }
641     }
642 
643     @Override
isBeforeFirst()644     public boolean isBeforeFirst() throws SQLException {
645         try {
646             return jdbcResultSet.isBeforeFirst();
647         } catch (java.sql.SQLException exception) {
648             throw Tools.toUnoException(this, exception);
649         }
650     }
651 
652     @Override
next()653     public boolean next() throws SQLException {
654         try {
655             return jdbcResultSet.next();
656         } catch (java.sql.SQLException exception) {
657             throw Tools.toUnoException(this, exception);
658         }
659     }
660 
661     @Override
wasNull()662     public boolean wasNull() throws SQLException {
663         try {
664             return jdbcResultSet.wasNull();
665         } catch (java.sql.SQLException exception) {
666             throw Tools.toUnoException(this, exception);
667         }
668     }
669 
670     @Override
clearWarnings()671     public void clearWarnings() throws SQLException {
672         try {
673             jdbcResultSet.clearWarnings();
674         } catch (java.sql.SQLException exception) {
675             throw Tools.toUnoException(this, exception);
676         }
677     }
678 
679     @Override
getWarnings()680     public Object getWarnings() throws SQLException {
681         try {
682             java.sql.SQLWarning javaWarning = jdbcResultSet.getWarnings();
683             if (javaWarning != null) {
684                 java.lang.Throwable nextException = javaWarning.getCause();
685                 SQLWarning warning = new SQLWarning(javaWarning.getMessage());
686                 warning.Context = this;
687                 warning.SQLState = javaWarning.getSQLState();
688                 warning.ErrorCode = javaWarning.getErrorCode();
689                 warning.NextException = nextException != null ? Tools.toUnoException(this, nextException) : Any.VOID;
690                 return warning;
691             }
692             return Any.VOID;
693         } catch (java.sql.SQLException sqlException) {
694             throw Tools.toUnoException(this, sqlException);
695         }
696     }
697 
698     @Override
insertRow()699     public void insertRow() throws SQLException {
700         try {
701             jdbcResultSet.insertRow();
702         } catch (java.sql.SQLException exception) {
703             throw Tools.toUnoException(this, exception);
704         }
705     }
706 
707     @Override
updateRow()708     public void updateRow() throws SQLException {
709         try {
710             jdbcResultSet.updateRow();
711         } catch (java.sql.SQLException exception) {
712             throw Tools.toUnoException(this, exception);
713         }
714     }
715 
716     @Override
deleteRow()717     public void deleteRow() throws SQLException {
718         try {
719             jdbcResultSet.deleteRow();
720         } catch (java.sql.SQLException exception) {
721             throw Tools.toUnoException(this, exception);
722         }
723     }
724 
725     @Override
cancelRowUpdates()726     public void cancelRowUpdates() throws SQLException {
727         try {
728             jdbcResultSet.cancelRowUpdates();
729         } catch (java.sql.SQLException exception) {
730             throw Tools.toUnoException(this, exception);
731         }
732     }
733 
734     @Override
moveToInsertRow()735     public void moveToInsertRow() throws SQLException {
736         try {
737             jdbcResultSet.moveToInsertRow();
738         } catch (java.sql.SQLException exception) {
739             throw Tools.toUnoException(this, exception);
740         }
741     }
742 
743     @Override
moveToCurrentRow()744     public void moveToCurrentRow() throws SQLException {
745         try {
746             jdbcResultSet.moveToCurrentRow();
747         } catch (java.sql.SQLException exception) {
748             throw Tools.toUnoException(this, exception);
749         }
750     }
751 
752     @Override
updateNull(int columnIndex)753     public void updateNull(int columnIndex) throws SQLException {
754         try {
755             jdbcResultSet.updateNull(columnIndex);
756         } catch (java.sql.SQLException exception) {
757             throw Tools.toUnoException(this, exception);
758         }
759     }
760 
761     @Override
updateBoolean(int columnIndex, boolean x)762     public void updateBoolean(int columnIndex, boolean x) throws SQLException {
763         try {
764             jdbcResultSet.updateBoolean(columnIndex, x);
765         } catch (java.sql.SQLException exception) {
766             throw Tools.toUnoException(this, exception);
767         }
768     }
769 
770     @Override
updateByte(int columnIndex, byte x)771     public void updateByte(int columnIndex, byte x) throws SQLException {
772         try {
773             jdbcResultSet.updateByte(columnIndex, x);
774         } catch (java.sql.SQLException exception) {
775             throw Tools.toUnoException(this, exception);
776         }
777     }
778 
779     @Override
updateShort(int columnIndex, short x)780     public void updateShort(int columnIndex, short x) throws SQLException {
781         try {
782             jdbcResultSet.updateShort(columnIndex, x);
783         } catch (java.sql.SQLException exception) {
784             throw Tools.toUnoException(this, exception);
785         }
786     }
787 
788     @Override
updateInt(int columnIndex, int x)789     public void updateInt(int columnIndex, int x) throws SQLException {
790         try {
791             jdbcResultSet.updateInt(columnIndex, x);
792         } catch (java.sql.SQLException exception) {
793             throw Tools.toUnoException(this, exception);
794         }
795     }
796 
797     @Override
updateLong(int columnIndex, long x)798     public void updateLong(int columnIndex, long x) throws SQLException {
799         try {
800             jdbcResultSet.updateLong(columnIndex, x);
801         } catch (java.sql.SQLException exception) {
802             throw Tools.toUnoException(this, exception);
803         }
804     }
805 
806     @Override
updateFloat(int columnIndex, float x)807     public void updateFloat(int columnIndex, float x) throws SQLException {
808         try {
809             jdbcResultSet.updateFloat(columnIndex, x);
810         } catch (java.sql.SQLException exception) {
811             throw Tools.toUnoException(this, exception);
812         }
813     }
814 
815     @Override
updateDouble(int columnIndex, double x)816     public void updateDouble(int columnIndex, double x) throws SQLException {
817         try {
818             jdbcResultSet.updateDouble(columnIndex, x);
819         } catch (java.sql.SQLException exception) {
820             throw Tools.toUnoException(this, exception);
821         }
822     }
823 
824     @Override
updateString(int columnIndex, String x)825     public void updateString(int columnIndex, String x) throws SQLException {
826         try {
827             jdbcResultSet.updateString(columnIndex, x);
828         } catch (java.sql.SQLException exception) {
829             throw Tools.toUnoException(this, exception);
830         }
831     }
832 
833     @Override
updateBytes(int columnIndex, byte[] x)834     public void updateBytes(int columnIndex, byte[] x) throws SQLException {
835         try {
836             jdbcResultSet.updateBytes(columnIndex, x);
837         } catch (java.sql.SQLException exception) {
838             throw Tools.toUnoException(this, exception);
839         }
840     }
841 
842     @Override
updateDate(int columnIndex, Date x)843     public void updateDate(int columnIndex, Date x) throws SQLException {
844         try {
845             jdbcResultSet.updateDate(columnIndex, java.sql.Date.valueOf(DBTypeConversion.toDateString(x)));
846         } catch (java.sql.SQLException exception) {
847             throw Tools.toUnoException(this, exception);
848         }
849     }
850 
851     @Override
updateTime(int columnIndex, Time x)852     public void updateTime(int columnIndex, Time x) throws SQLException {
853         try {
854             jdbcResultSet.updateTime(columnIndex, java.sql.Time.valueOf(DBTypeConversion.toTimeString(x)));
855         } catch (java.sql.SQLException exception) {
856             throw Tools.toUnoException(this, exception);
857         }
858     }
859 
860     @Override
updateTimestamp(int columnIndex, DateTime x)861     public void updateTimestamp(int columnIndex, DateTime x) throws SQLException {
862         try {
863             jdbcResultSet.updateTimestamp(columnIndex,
864                     java.sql.Timestamp.valueOf(DBTypeConversion.toDateTimeString(x)));
865         } catch (java.sql.SQLException exception) {
866             throw Tools.toUnoException(this, exception);
867         }
868     }
869 
870     @Override
updateBinaryStream(int columnIndex, XInputStream x, int length)871     public void updateBinaryStream(int columnIndex, XInputStream x, int length) throws SQLException {
872         try {
873             jdbcResultSet.updateBinaryStream(columnIndex,
874                     new BoundedInputStream(new XInputStreamToInputStreamAdapter(x), length & 0xffff_ffffL), length);
875         } catch (java.sql.SQLException exception) {
876             throw Tools.toUnoException(this, exception);
877         }
878     }
879 
880     @Override
updateCharacterStream(int columnIndex, XInputStream x, int length)881     public void updateCharacterStream(int columnIndex, XInputStream x, int length) throws SQLException {
882         try {
883             // FIXME: charset?
884             jdbcResultSet.updateCharacterStream(columnIndex, new InputStreamReader(
885                     new BoundedInputStream(new XInputStreamToInputStreamAdapter(x), length & 0xffff_ffffL),
886                     Charset.forName("UTF16-LE")), length);
887         } catch (java.sql.SQLException exception) {
888             throw Tools.toUnoException(this, exception);
889         }
890     }
891 
892     @Override
updateObject(int columnIndex, Object x)893     public void updateObject(int columnIndex, Object x) throws SQLException {
894         if (!DbTools.updateObject(this, columnIndex, x)) {
895             String error = SharedResources.getInstance().getResourceStringWithSubstitution(
896                     Resources.STR_UNKNOWN_COLUMN_TYPE, "$position$", Integer.toString(columnIndex));
897             throw new SQLException(error, this, StandardSQLState.SQL_GENERAL_ERROR.text(), 0, Any.VOID);
898         }
899     }
900 
901     @Override
updateNumericObject(int columnIndex, Object x, int scale)902     public void updateNumericObject(int columnIndex, Object x, int scale) throws SQLException {
903         try {
904             BigDecimal bigDecimal;
905             if (AnyConverter.isDouble(x)) {
906                 bigDecimal = BigDecimal.valueOf(AnyConverter.toDouble(x));
907             } else {
908                 bigDecimal = new BigDecimal(AnyConverter.toString(x));
909             }
910             jdbcResultSet.updateObject(columnIndex, bigDecimal, scale);
911         } catch (IllegalArgumentException | java.sql.SQLException exception) {
912             updateObject(columnIndex, x);
913         }
914     }
915 
916     @Override
refreshRow()917     public void refreshRow() throws SQLException {
918         try {
919             jdbcResultSet.refreshRow();
920         } catch (java.sql.SQLException exception) {
921             throw Tools.toUnoException(this, exception);
922         }
923     }
924 
925 
926 }
927