1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.util.sql;
35
36 import fr.paris.lutece.portal.service.database.AppConnectionService;
37 import fr.paris.lutece.portal.service.database.PluginConnectionService;
38 import fr.paris.lutece.portal.service.plugin.Plugin;
39 import fr.paris.lutece.portal.service.util.AppException;
40 import fr.paris.lutece.portal.service.util.AppLogService;
41 import fr.paris.lutece.portal.service.util.NoDatabaseException;
42
43 import org.apache.logging.log4j.LogManager;
44 import org.apache.logging.log4j.Logger;
45 import org.springframework.jdbc.datasource.DataSourceUtils;
46
47 import org.springframework.transaction.support.TransactionSynchronizationManager;
48
49 import java.io.InputStream;
50 import java.io.Reader;
51 import java.math.BigDecimal;
52 import java.net.URL;
53 import java.sql.Array;
54 import java.sql.Blob;
55 import java.sql.Clob;
56 import java.sql.Connection;
57 import java.sql.Date;
58 import java.sql.NClob;
59 import java.sql.PreparedStatement;
60 import java.sql.Ref;
61 import java.sql.ResultSet;
62 import java.sql.RowId;
63 import java.sql.SQLException;
64 import java.sql.SQLXML;
65 import java.sql.Statement;
66 import java.sql.Time;
67 import java.sql.Timestamp;
68 import java.sql.Types;
69
70 import java.text.MessageFormat;
71 import java.util.ArrayList;
72 import java.util.Calendar;
73 import java.util.List;
74
75 import javax.sql.DataSource;
76
77
78
79
80
81
82 public class DAOUtil implements AutoCloseable
83 {
84 public static final String MSG_EXCEPTION_SELECT_ERROR = "Error selecting row id : ";
85 private static final String DEFAULT_MODULE_NAME = "lutece";
86 private static final String LOGGER_DEBUG_SQL = "lutece.debug.sql.";
87
88
89 private PluginConnectionService _connectionService;
90
91
92 private Connection _connection;
93 private List<Array> _arrays;
94
95
96 private String _strPluginName;
97
98
99 private PreparedStatement _statement;
100
101
102 private ResultSet _resultSet;
103
104
105
106
107 private Integer _autoGeneratedKeys;
108 private ResultSet _generatedKeysResultSet;
109
110
111 private boolean _bReleased;
112 private String _strSQL;
113 private boolean _bTransactionnal;
114 private boolean _bLogQueries;
115
116
117 private Logger _logger;
118 private StringBuilder _sbLogs = new StringBuilder( );
119
120
121
122
123
124
125
126 public DAOUtil( String sql )
127 {
128 this( sql, null, null, true );
129 }
130
131
132
133
134
135
136
137 public DAOUtil( String sql, boolean logQueries )
138 {
139 this( sql, null, null, logQueries );
140 }
141
142
143
144
145
146
147
148
149
150 public DAOUtil( String strSQL, Plugin plugin )
151 {
152 this( strSQL, null, plugin, true );
153 }
154
155
156
157
158
159
160
161
162
163 public DAOUtil( String strSQL, Plugin plugin, boolean bLogQueries )
164 {
165 this( strSQL, null, plugin, bLogQueries );
166 }
167
168
169
170
171
172
173
174
175
176
177
178 public DAOUtil( String sql, Integer autoGeneratedKeys )
179 {
180 this( sql, autoGeneratedKeys, null, true );
181 }
182
183
184
185
186
187
188
189
190
191
192
193
194
195 public DAOUtil( String strSQL, Integer autoGeneratedKeys, Plugin plugin )
196 {
197 this( strSQL, autoGeneratedKeys, plugin, true );
198 }
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213 public DAOUtil( String strSQL, Integer autoGeneratedKeys, Plugin plugin, boolean bLogQueries )
214 {
215 _bReleased = false;
216 _strSQL = strSQL;
217 _autoGeneratedKeys = autoGeneratedKeys;
218 _bLogQueries = bLogQueries;
219
220 loadPlugin( plugin );
221
222
223
224 _logger = LogManager.getLogger( LOGGER_DEBUG_SQL + _strPluginName );
225
226 if ( _logger.isDebugEnabled( ) )
227 {
228 log( "Module : '" + _strPluginName + "' - SQL Statement : " + ( _bLogQueries ? _strSQL : "(query log disabled)" ) );
229 }
230
231 try
232 {
233 MultiPluginTransaction transaction = TransactionManager.getCurrentTransaction( plugin );
234
235 if ( transaction != null )
236 {
237 _bTransactionnal = true;
238 }
239 else
240 {
241
242
243 if ( TransactionSynchronizationManager.isSynchronizationActive( ) )
244 {
245 _bTransactionnal = true;
246
247 DataSource ds = AppConnectionService.getPoolManager( ).getDataSource( _connectionService.getPoolName( ) );
248 _connection = DataSourceUtils.getConnection( ds );
249
250 if ( _logger.isDebugEnabled( ) )
251 {
252 _logger.debug( "Transactionnal context is used for pool " + _connectionService.getPoolName( ) );
253 }
254 }
255 else
256 {
257
258 _connection = _connectionService.getConnection( );
259 }
260 }
261
262 createStatement( transaction );
263 }
264 catch( SQLException e )
265 {
266 free( );
267 throw new AppException( getErrorMessage( e ), e );
268 }
269 }
270
271 private void createStatement( MultiPluginTransaction transaction ) throws SQLException
272 {
273 if ( transaction != null )
274 {
275 if ( _autoGeneratedKeys != null )
276 {
277 _statement = transaction.prepareStatement( _strSQL, _autoGeneratedKeys, _bLogQueries );
278 }
279 else
280 {
281 _statement = transaction.prepareStatement( _strSQL, _bLogQueries );
282 }
283 }
284 else
285 if ( _connection != null )
286 {
287 if ( _autoGeneratedKeys != null )
288 {
289 _statement = _connection.prepareStatement( _strSQL, _autoGeneratedKeys );
290 }
291 else
292 {
293 _statement = _connection.prepareStatement( _strSQL );
294 }
295 }
296 else
297 {
298 throw new AppException( "Database access error for component '" + _strPluginName + "'. Please check plugin installation and db.properties." );
299 }
300 }
301
302 private void loadPlugin( Plugin plugin )
303 {
304 if ( plugin != null )
305 {
306 _strPluginName = plugin.getName( );
307 _connectionService = plugin.getConnectionService( );
308 }
309 else
310 {
311 _strPluginName = DEFAULT_MODULE_NAME;
312 _connectionService = AppConnectionService.getDefaultConnectionService( );
313 }
314
315 if ( _connectionService == null )
316 {
317 throw new NoDatabaseException( "Database access error. Please check component installations and db.properties." );
318 }
319 }
320
321
322
323
324
325
326
327
328 private String getErrorMessage( Exception e )
329 {
330 StringBuilder sbError = new StringBuilder( "DAOUtil error : " );
331 sbError.append( e.getMessage( ) );
332 sbError.append( " - SQL statement : " );
333 sbError.append( " - Plugin : " );
334 sbError.append( _strPluginName );
335
336 return sbError.toString( );
337 }
338
339
340
341
342 public void executeUpdate( )
343 {
344 try
345 {
346 _statement.executeUpdate( );
347 if ( _autoGeneratedKeys != null && _autoGeneratedKeys.equals( Statement.RETURN_GENERATED_KEYS ) )
348 {
349 _generatedKeysResultSet = _statement.getGeneratedKeys( );
350 }
351 }
352 catch( SQLException e )
353 {
354 free( );
355 throw new AppException( getErrorMessage( e ), e );
356 }
357 }
358
359
360
361
362 public void executeQuery( )
363 {
364 try
365 {
366 _resultSet = _statement.executeQuery( );
367 }
368 catch( SQLException e )
369 {
370 free( );
371 throw new AppException( getErrorMessage( e ), e );
372 }
373 }
374
375
376
377
378
379
380
381 private void log( String strMessage )
382 {
383 if ( _logger.isDebugEnabled( ) )
384 {
385 _sbLogs.append( strMessage );
386 }
387 }
388
389
390
391
392
393
394
395
396
397 private void logParameter( Object oName, Object oValue )
398 {
399 if ( _logger.isDebugEnabled( ) )
400 {
401 Object [ ] args = {
402 oName, oValue
403 };
404 log( MessageFormat.format( "\n Index : ''{0}'' Value : ''{1}'' ", args ) );
405 }
406 }
407
408
409
410
411 public final void free( )
412 {
413 if ( !_bReleased )
414 {
415 _logger.debug( _sbLogs );
416 }
417
418 try
419 {
420
421 if ( _statement != null )
422 {
423 _statement.close( );
424 }
425 if ( _arrays != null )
426 {
427 for ( Array array : _arrays )
428 {
429 array.free( );
430 }
431 }
432 }
433 catch( SQLException e )
434 {
435 throw new AppException( e.getMessage( ), e );
436 }
437 finally
438 {
439
440
441 if ( ( _connectionService != null ) && !_bTransactionnal )
442 {
443 _connectionService.freeConnection( _connection );
444 _connectionService = null;
445 }
446
447 _bReleased = true;
448 }
449 }
450
451
452
453
454
455
456 public boolean isLast( )
457 {
458 try
459 {
460 return _resultSet.isLast( );
461 }
462 catch( SQLException e )
463 {
464 free( );
465 throw new AppException( getErrorMessage( e ), e );
466 }
467 }
468
469
470
471
472
473
474
475
476
477 public void setDate( int nIndex, Date date )
478 {
479 try
480 {
481 _statement.setDate( nIndex, date );
482 logParameter( nIndex, date );
483 }
484 catch( SQLException e )
485 {
486 free( );
487 throw new AppException( getErrorMessage( e ), e );
488 }
489 }
490
491
492
493
494
495
496
497
498
499
500
501
502
503 public void setDate( int nIndex, Date date, Calendar calendar )
504 {
505 try
506 {
507 _statement.setDate( nIndex, date, calendar );
508 logParameter( nIndex, date );
509 }
510 catch( SQLException e )
511 {
512 free( );
513 throw new AppException( getErrorMessage( e ), e );
514 }
515 }
516
517
518
519
520
521
522
523
524
525 public void setTime( int nIndex, Time time )
526 {
527 try
528 {
529 _statement.setTime( nIndex, time );
530 logParameter( nIndex, time );
531 }
532 catch( SQLException e )
533 {
534 free( );
535 throw new AppException( getErrorMessage( e ), e );
536 }
537 }
538
539
540
541
542
543
544
545
546
547
548
549
550
551 public void setTime( int nIndex, Time time, Calendar calendar )
552 {
553 try
554 {
555 _statement.setTime( nIndex, time, calendar );
556 logParameter( nIndex, time );
557 }
558 catch( SQLException e )
559 {
560 free( );
561 throw new AppException( getErrorMessage( e ), e );
562 }
563 }
564
565
566
567
568
569
570
571
572
573
574
575 public void setBinaryStream( int nIndex, InputStream iStream, int nBlength )
576 {
577 try
578 {
579 _statement.setBinaryStream( nIndex, iStream, nBlength );
580 }
581 catch( SQLException e )
582 {
583 free( );
584 throw new AppException( getErrorMessage( e ), e );
585 }
586 }
587
588
589
590
591
592
593
594
595
596
597
598
599
600 public void setBinaryStream( int nIndex, InputStream iStream, long nBlength )
601 {
602 try
603 {
604 _statement.setBinaryStream( nIndex, iStream, nBlength );
605 }
606 catch( SQLException e )
607 {
608 free( );
609 throw new AppException( getErrorMessage( e ), e );
610 }
611 }
612
613
614
615
616
617
618
619
620
621
622
623 public void setBinaryStream( int nIndex, InputStream iStream )
624 {
625 try
626 {
627 _statement.setBinaryStream( nIndex, iStream );
628 }
629 catch( SQLException e )
630 {
631 free( );
632 throw new AppException( getErrorMessage( e ), e );
633 }
634 }
635
636
637
638
639
640
641
642
643 public InputStream getBinaryStream( int nIndex )
644 {
645 try
646 {
647 return _resultSet.getBinaryStream( nIndex );
648 }
649 catch( SQLException e )
650 {
651 free( );
652 throw new AppException( getErrorMessage( e ), e );
653 }
654 }
655
656
657
658
659
660
661
662
663 public Blob getBlob( int nIndex )
664 {
665 try
666 {
667 return _resultSet.getBlob( nIndex );
668 }
669 catch( SQLException e )
670 {
671 free( );
672 throw new AppException( getErrorMessage( e ), e );
673 }
674 }
675
676
677
678
679
680
681
682
683
684 public Blob getBlob( String strColumnName )
685 {
686 try
687 {
688 return _resultSet.getBlob( strColumnName );
689 }
690 catch( SQLException e )
691 {
692 free( );
693 throw new AppException( getErrorMessage( e ), e );
694 }
695 }
696
697
698
699
700
701
702
703
704
705
706
707 public void setBlob( int nIndex, InputStream stream )
708 {
709 try
710 {
711 _statement.setBlob( nIndex, stream );
712 }
713 catch( SQLException e )
714 {
715 free( );
716 throw new AppException( getErrorMessage( e ), e );
717 }
718 }
719
720
721
722
723
724
725
726
727
728
729
730
731
732 public void setBlob( int nIndex, InputStream stream, long nLength )
733 {
734 try
735 {
736 _statement.setBlob( nIndex, stream, nLength );
737 }
738 catch( SQLException e )
739 {
740 free( );
741 throw new AppException( getErrorMessage( e ), e );
742 }
743 }
744
745
746
747
748
749
750
751
752
753
754
755 public void setBlob( int nIndex, Blob blob )
756 {
757 try
758 {
759 _statement.setBlob( nIndex, blob );
760 }
761 catch( SQLException e )
762 {
763 free( );
764 throw new AppException( getErrorMessage( e ), e );
765 }
766 }
767
768
769
770
771
772
773
774
775
776 public byte [ ] getBytes( int nIndex )
777 {
778 try
779 {
780 return _resultSet.getBytes( nIndex );
781 }
782 catch( SQLException e )
783 {
784 free( );
785 throw new AppException( getErrorMessage( e ), e );
786 }
787 }
788
789
790
791
792
793
794
795
796
797 public byte [ ] getBytes( String strColumnName )
798 {
799 try
800 {
801 return _resultSet.getBytes( strColumnName );
802 }
803 catch( SQLException e )
804 {
805 free( );
806 throw new AppException( getErrorMessage( e ), e );
807 }
808 }
809
810
811
812
813
814
815
816
817
818
819 public byte getByte( int nIndex )
820 {
821 try
822 {
823 return _resultSet.getByte( nIndex );
824 }
825 catch( SQLException e )
826 {
827 free( );
828 throw new AppException( getErrorMessage( e ), e );
829 }
830 }
831
832
833
834
835
836
837
838
839
840
841 public byte getByte( String strColumnName )
842 {
843 try
844 {
845 return _resultSet.getByte( strColumnName );
846 }
847 catch( SQLException e )
848 {
849 free( );
850 throw new AppException( getErrorMessage( e ), e );
851 }
852 }
853
854
855
856
857
858
859
860
861
862 public void setInt( int nIndex, int nValue )
863 {
864 try
865 {
866 _statement.setInt( nIndex, nValue );
867 logParameter( nIndex, nValue );
868 }
869 catch( SQLException e )
870 {
871 free( );
872 throw new AppException( getErrorMessage( e ), e );
873 }
874 }
875
876
877
878
879
880
881
882
883
884 public void setBoolean( int nIndex, boolean bValue )
885 {
886 try
887 {
888 _statement.setInt( nIndex, ( bValue ) ? 1 : 0 );
889 logParameter( nIndex, bValue );
890 }
891 catch( SQLException e )
892 {
893 free( );
894 throw new AppException( getErrorMessage( e ), e );
895 }
896 }
897
898
899
900
901
902
903
904
905
906
907
908 public void setByte( int nIndex, byte bValue )
909 {
910 try
911 {
912 _statement.setByte( nIndex, bValue );
913 logParameter( nIndex, bValue );
914 }
915 catch( SQLException e )
916 {
917 free( );
918 throw new AppException( getErrorMessage( e ), e );
919 }
920 }
921
922
923
924
925
926
927
928
929
930 public void setBytes( int nIndex, byte [ ] tbValue )
931 {
932 try
933 {
934 _statement.setBytes( nIndex, tbValue );
935 }
936 catch( SQLException e )
937 {
938 free( );
939 throw new AppException( getErrorMessage( e ), e );
940 }
941 }
942
943
944
945
946
947
948
949
950
951 public void setString( int nIndex, String strValue )
952 {
953 try
954 {
955 _statement.setString( nIndex, strValue );
956 logParameter( nIndex, strValue );
957 }
958 catch( SQLException e )
959 {
960 free( );
961 throw new AppException( getErrorMessage( e ), e );
962 }
963 }
964
965
966
967
968
969
970
971
972
973 public void setTimestamp( int nIndex, Timestamp ts )
974 {
975 try
976 {
977 _statement.setTimestamp( nIndex, ts );
978 logParameter( nIndex, ts );
979 }
980 catch( SQLException e )
981 {
982 free( );
983 throw new AppException( getErrorMessage( e ), e );
984 }
985 }
986
987
988
989
990
991
992
993
994
995
996
997
998
999 public void setTimestamp( int nIndex, Timestamp ts, Calendar calendar )
1000 {
1001 try
1002 {
1003 _statement.setTimestamp( nIndex, ts, calendar );
1004 logParameter( nIndex, ts );
1005 }
1006 catch( SQLException e )
1007 {
1008 free( );
1009 throw new AppException( getErrorMessage( e ), e );
1010 }
1011 }
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021 public void setDouble( int nIndex, double dValue )
1022 {
1023 try
1024 {
1025 _statement.setDouble( nIndex, dValue );
1026 logParameter( nIndex, dValue );
1027 }
1028 catch( SQLException e )
1029 {
1030 free( );
1031 throw new AppException( getErrorMessage( e ), e );
1032 }
1033 }
1034
1035
1036
1037
1038
1039
1040
1041 public void setDoubleNull( int nIndex )
1042 {
1043 try
1044 {
1045 _statement.setNull( nIndex, Types.DOUBLE );
1046 logParameter( nIndex, "null" );
1047 }
1048 catch( SQLException e )
1049 {
1050 free( );
1051 throw new AppException( getErrorMessage( e ), e );
1052 }
1053 }
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063 public Date getDate( int nIndex )
1064 {
1065 try
1066 {
1067 return _resultSet.getDate( nIndex );
1068 }
1069 catch( SQLException e )
1070 {
1071 free( );
1072 throw new AppException( getErrorMessage( e ), e );
1073 }
1074 }
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084 public Date getDate( String strColumnName )
1085 {
1086 try
1087 {
1088 return _resultSet.getDate( strColumnName );
1089 }
1090 catch( SQLException e )
1091 {
1092 free( );
1093 throw new AppException( getErrorMessage( e ), e );
1094 }
1095 }
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108 public Date getDate( int nIndex, Calendar calendar )
1109 {
1110 try
1111 {
1112 return _resultSet.getDate( nIndex, calendar );
1113 }
1114 catch( SQLException e )
1115 {
1116 free( );
1117 throw new AppException( getErrorMessage( e ), e );
1118 }
1119 }
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132 public Date getDate( String strColumnName, Calendar calendar )
1133 {
1134 try
1135 {
1136 return _resultSet.getDate( strColumnName, calendar );
1137 }
1138 catch( SQLException e )
1139 {
1140 free( );
1141 throw new AppException( getErrorMessage( e ), e );
1142 }
1143 }
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153 public Time getTime( int nIndex )
1154 {
1155 try
1156 {
1157 return _resultSet.getTime( nIndex );
1158 }
1159 catch( SQLException e )
1160 {
1161 free( );
1162 throw new AppException( getErrorMessage( e ), e );
1163 }
1164 }
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174 public Time getTime( String strColumnName )
1175 {
1176 try
1177 {
1178 return _resultSet.getTime( strColumnName );
1179 }
1180 catch( SQLException e )
1181 {
1182 free( );
1183 throw new AppException( getErrorMessage( e ), e );
1184 }
1185 }
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198 public Time getTime( int nIndex, Calendar calendar )
1199 {
1200 try
1201 {
1202 return _resultSet.getTime( nIndex, calendar );
1203 }
1204 catch( SQLException e )
1205 {
1206 free( );
1207 throw new AppException( getErrorMessage( e ), e );
1208 }
1209 }
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222 public Time getTime( String strColumnName, Calendar calendar )
1223 {
1224 try
1225 {
1226 return _resultSet.getTime( strColumnName, calendar );
1227 }
1228 catch( SQLException e )
1229 {
1230 free( );
1231 throw new AppException( getErrorMessage( e ), e );
1232 }
1233 }
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243 public int getInt( int nIndex )
1244 {
1245 try
1246 {
1247 return _resultSet.getInt( nIndex );
1248 }
1249 catch( SQLException e )
1250 {
1251 free( );
1252 throw new AppException( getErrorMessage( e ), e );
1253 }
1254 }
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264 public int getInt( String strColumnName )
1265 {
1266 try
1267 {
1268 return _resultSet.getInt( strColumnName );
1269 }
1270 catch( SQLException e )
1271 {
1272 free( );
1273 throw new AppException( getErrorMessage( e ), e );
1274 }
1275 }
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285 public boolean getBoolean( int nIndex )
1286 {
1287 try
1288 {
1289 return ( _resultSet.getInt( nIndex ) != 0 );
1290 }
1291 catch( SQLException e )
1292 {
1293 free( );
1294 throw new AppException( getErrorMessage( e ), e );
1295 }
1296 }
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306 public boolean getBoolean( String strColumnName )
1307 {
1308 try
1309 {
1310 return ( _resultSet.getInt( strColumnName ) != 0 );
1311 }
1312 catch( SQLException e )
1313 {
1314 free( );
1315 throw new AppException( getErrorMessage( e ), e );
1316 }
1317 }
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327 public String getString( int nIndex )
1328 {
1329 try
1330 {
1331 return _resultSet.getString( nIndex );
1332 }
1333 catch( SQLException e )
1334 {
1335 free( );
1336 throw new AppException( getErrorMessage( e ), e );
1337 }
1338 }
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348 public String getString( String strColumnName )
1349 {
1350 try
1351 {
1352 return _resultSet.getString( strColumnName );
1353 }
1354 catch( SQLException e )
1355 {
1356 free( );
1357 throw new AppException( getErrorMessage( e ), e );
1358 }
1359 }
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369 public Timestamp getTimestamp( int nIndex )
1370 {
1371 try
1372 {
1373 return _resultSet.getTimestamp( nIndex );
1374 }
1375 catch( SQLException e )
1376 {
1377 free( );
1378 throw new AppException( getErrorMessage( e ), e );
1379 }
1380 }
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390 public Timestamp getTimestamp( String strColumnName )
1391 {
1392 try
1393 {
1394 return _resultSet.getTimestamp( strColumnName );
1395 }
1396 catch( SQLException e )
1397 {
1398 free( );
1399 throw new AppException( getErrorMessage( e ), e );
1400 }
1401 }
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414 public Timestamp getTimestamp( int nIndex, Calendar calendar )
1415 {
1416 try
1417 {
1418 return _resultSet.getTimestamp( nIndex, calendar );
1419 }
1420 catch( SQLException e )
1421 {
1422 free( );
1423 throw new AppException( getErrorMessage( e ), e );
1424 }
1425 }
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438 public Timestamp getTimestamp( String strColumnName, Calendar calendar )
1439 {
1440 try
1441 {
1442 return _resultSet.getTimestamp( strColumnName, calendar );
1443 }
1444 catch( SQLException e )
1445 {
1446 free( );
1447 throw new AppException( getErrorMessage( e ), e );
1448 }
1449 }
1450
1451
1452
1453
1454
1455
1456
1457
1458 public double getDouble( String strColumnName )
1459 {
1460 try
1461 {
1462 return _resultSet.getDouble( strColumnName );
1463 }
1464 catch( SQLException e )
1465 {
1466 free( );
1467 throw new AppException( getErrorMessage( e ), e );
1468 }
1469 }
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479 public double getDouble( int nIndex )
1480 {
1481 try
1482 {
1483 return _resultSet.getDouble( nIndex );
1484 }
1485 catch( SQLException e )
1486 {
1487 free( );
1488 throw new AppException( getErrorMessage( e ), e );
1489 }
1490 }
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500 public Object getObject( int nIndex )
1501 {
1502 try
1503 {
1504 return _resultSet.getObject( nIndex );
1505 }
1506 catch( SQLException e )
1507 {
1508 free( );
1509 throw new AppException( getErrorMessage( e ), e );
1510 }
1511 }
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526 public <T> T getObject( int nIndex, Class<T> type )
1527 {
1528 try
1529 {
1530 return _resultSet.getObject( nIndex, type );
1531 }
1532 catch( SQLException e )
1533 {
1534 free( );
1535 throw new AppException( getErrorMessage( e ), e );
1536 }
1537 }
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550 public Object getObject( int nIndex, java.util.Map<String, Class<?>> map )
1551 {
1552 try
1553 {
1554 return _resultSet.getObject( nIndex, map );
1555 }
1556 catch( SQLException e )
1557 {
1558 free( );
1559 throw new AppException( getErrorMessage( e ), e );
1560 }
1561 }
1562
1563
1564
1565
1566
1567
1568 public ResultSet getResultSet( )
1569 {
1570 return _resultSet;
1571 }
1572
1573
1574
1575
1576
1577
1578
1579 public ResultSet getGeneratedKeysResultSet( )
1580 {
1581 return _generatedKeysResultSet;
1582 }
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592 public Object getObject( String strColumnName )
1593 {
1594 try
1595 {
1596 return _resultSet.getObject( strColumnName );
1597 }
1598 catch( SQLException e )
1599 {
1600 free( );
1601 throw new AppException( getErrorMessage( e ), e );
1602 }
1603 }
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619 public <T> T getObject( String strColumnName, Class<T> type )
1620 {
1621 try
1622 {
1623 return _resultSet.getObject( strColumnName, type );
1624 }
1625 catch( SQLException e )
1626 {
1627 free( );
1628 throw new AppException( getErrorMessage( e ), e );
1629 }
1630 }
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643 public Object getObject( String strColumnName, java.util.Map<String, Class<?>> map )
1644 {
1645 try
1646 {
1647 return _resultSet.getObject( strColumnName, map );
1648 }
1649 catch( SQLException e )
1650 {
1651 free( );
1652 throw new AppException( getErrorMessage( e ), e );
1653 }
1654 }
1655
1656
1657
1658
1659
1660
1661 public boolean next( )
1662 {
1663 try
1664 {
1665 return _resultSet.next( );
1666 }
1667 catch( SQLException e )
1668 {
1669 free( );
1670 throw new AppException( getErrorMessage( e ), e );
1671 }
1672 }
1673
1674
1675
1676
1677
1678
1679
1680 public boolean nextGeneratedKey( )
1681 {
1682 try
1683 {
1684 return _generatedKeysResultSet.next( );
1685 }
1686 catch( SQLException e )
1687 {
1688 free( );
1689 throw new AppException( getErrorMessage( e ), e );
1690 }
1691 }
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702 public byte getGeneratedKeyByte( int nIndex )
1703 {
1704 try
1705 {
1706 return _generatedKeysResultSet.getByte( nIndex );
1707 }
1708 catch( SQLException e )
1709 {
1710 free( );
1711 throw new AppException( getErrorMessage( e ), e );
1712 }
1713 }
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724 public short getGeneratedKeyShort( int nIndex )
1725 {
1726 try
1727 {
1728 return _generatedKeysResultSet.getShort( nIndex );
1729 }
1730 catch( SQLException e )
1731 {
1732 free( );
1733 throw new AppException( getErrorMessage( e ), e );
1734 }
1735 }
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746 public int getGeneratedKeyInt( int nIndex )
1747 {
1748 try
1749 {
1750 return _generatedKeysResultSet.getInt( nIndex );
1751 }
1752 catch( SQLException e )
1753 {
1754 free( );
1755 throw new AppException( getErrorMessage( e ), e );
1756 }
1757 }
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768 public long getGeneratedKeyLong( int nIndex )
1769 {
1770 try
1771 {
1772 return _generatedKeysResultSet.getLong( nIndex );
1773 }
1774 catch( SQLException e )
1775 {
1776 free( );
1777 throw new AppException( getErrorMessage( e ), e );
1778 }
1779 }
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790 public BigDecimal getGeneratedKeyBigDecimal( int nIndex )
1791 {
1792 try
1793 {
1794 return _generatedKeysResultSet.getBigDecimal( nIndex );
1795 }
1796 catch( SQLException e )
1797 {
1798 free( );
1799 throw new AppException( getErrorMessage( e ), e );
1800 }
1801 }
1802
1803
1804
1805
1806
1807
1808
1809 public void setIntNull( int nIndex )
1810 {
1811 try
1812 {
1813 _statement.setNull( nIndex, Types.INTEGER );
1814 logParameter( nIndex, "null" );
1815 }
1816 catch( SQLException e )
1817 {
1818 free( );
1819 throw new AppException( getErrorMessage( e ), e );
1820 }
1821 }
1822
1823
1824
1825
1826
1827
1828
1829 public void setLongNull( int nIndex )
1830 {
1831 try
1832 {
1833 _statement.setNull( nIndex, Types.BIGINT );
1834 logParameter( nIndex, "null" );
1835 }
1836 catch( SQLException e )
1837 {
1838 free( );
1839 throw new AppException( getErrorMessage( e ), e );
1840 }
1841 }
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851 public void setLong( int nIndex, long lValue )
1852 {
1853 try
1854 {
1855 _statement.setLong( nIndex, lValue );
1856 logParameter( nIndex, lValue );
1857 }
1858 catch( SQLException e )
1859 {
1860 free( );
1861 throw new AppException( getErrorMessage( e ), e );
1862 }
1863 }
1864
1865
1866
1867
1868
1869
1870
1871
1872 public long getLong( int nIndex )
1873 {
1874 try
1875 {
1876 return _resultSet.getLong( nIndex );
1877 }
1878 catch( SQLException e )
1879 {
1880 free( );
1881 throw new AppException( getErrorMessage( e ), e );
1882 }
1883 }
1884
1885
1886
1887
1888
1889
1890
1891
1892 public long getLong( String strColumnName )
1893 {
1894 try
1895 {
1896 return _resultSet.getLong( strColumnName );
1897 }
1898 catch( SQLException e )
1899 {
1900 free( );
1901 throw new AppException( getErrorMessage( e ), e );
1902 }
1903 }
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918 public void setArray( int nIndex, String strTypename, Object [ ] elements )
1919 {
1920 try
1921 {
1922 Array x = _connection.createArrayOf( strTypename, elements );
1923 registerArray( x );
1924 _statement.setArray( nIndex, x );
1925 }
1926 catch( SQLException e )
1927 {
1928 free( );
1929 throw new AppException( getErrorMessage( e ), e );
1930 }
1931 }
1932
1933
1934
1935
1936
1937
1938
1939 private void registerArray( Array array )
1940 {
1941 if ( _arrays == null )
1942 {
1943 _arrays = new ArrayList<>( );
1944 }
1945 _arrays.add( array );
1946 }
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957 public Array getArray( int nIndex )
1958 {
1959 try
1960 {
1961 Array res = _resultSet.getArray( nIndex );
1962 registerArray( res );
1963 return res;
1964 }
1965 catch( SQLException e )
1966 {
1967 free( );
1968 throw new AppException( getErrorMessage( e ), e );
1969 }
1970 }
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981 public Array getArray( String strColumnName )
1982 {
1983 try
1984 {
1985 Array res = _resultSet.getArray( strColumnName );
1986 registerArray( res );
1987 return res;
1988 }
1989 catch( SQLException e )
1990 {
1991 free( );
1992 throw new AppException( getErrorMessage( e ), e );
1993 }
1994 }
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006 public void setAsciiStream( int nIndex, InputStream stream )
2007 {
2008 try
2009 {
2010 _statement.setAsciiStream( nIndex, stream );
2011 }
2012 catch( SQLException e )
2013 {
2014 free( );
2015 throw new AppException( getErrorMessage( e ), e );
2016 }
2017 }
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031 public void setAsciiStream( int nIndex, InputStream stream, int nLength )
2032 {
2033 try
2034 {
2035 _statement.setAsciiStream( nIndex, stream, nLength );
2036 }
2037 catch( SQLException e )
2038 {
2039 free( );
2040 throw new AppException( getErrorMessage( e ), e );
2041 }
2042 }
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056 public void setAsciiStream( int nIndex, InputStream stream, long lLength )
2057 {
2058 try
2059 {
2060 _statement.setAsciiStream( nIndex, stream, lLength );
2061 }
2062 catch( SQLException e )
2063 {
2064 free( );
2065 throw new AppException( getErrorMessage( e ), e );
2066 }
2067 }
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078 public InputStream getAsciiString( int nIndex )
2079 {
2080 try
2081 {
2082 return _resultSet.getAsciiStream( nIndex );
2083 }
2084 catch( SQLException e )
2085 {
2086 free( );
2087 throw new AppException( getErrorMessage( e ), e );
2088 }
2089 }
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100 public InputStream getAsciiString( String strColumnName )
2101 {
2102 try
2103 {
2104 return _resultSet.getAsciiStream( strColumnName );
2105 }
2106 catch( SQLException e )
2107 {
2108 free( );
2109 throw new AppException( getErrorMessage( e ), e );
2110 }
2111 }
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123 public void setBigDecimal( int nIndex, BigDecimal value )
2124 {
2125 try
2126 {
2127 _statement.setBigDecimal( nIndex, value );
2128 logParameter( nIndex, value );
2129 }
2130 catch( SQLException e )
2131 {
2132 free( );
2133 throw new AppException( getErrorMessage( e ), e );
2134 }
2135 }
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146 public BigDecimal getBigDecimal( int nIndex )
2147 {
2148 try
2149 {
2150 return _resultSet.getBigDecimal( nIndex );
2151 }
2152 catch( SQLException e )
2153 {
2154 free( );
2155 throw new AppException( getErrorMessage( e ), e );
2156 }
2157 }
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168 public BigDecimal getBigDecimal( String strColumnName )
2169 {
2170 try
2171 {
2172 return _resultSet.getBigDecimal( strColumnName );
2173 }
2174 catch( SQLException e )
2175 {
2176 free( );
2177 throw new AppException( getErrorMessage( e ), e );
2178 }
2179 }
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191 public void setCharacterStream( int nIndex, Reader stream )
2192 {
2193 try
2194 {
2195 _statement.setCharacterStream( nIndex, stream );
2196 }
2197 catch( SQLException e )
2198 {
2199 free( );
2200 throw new AppException( getErrorMessage( e ), e );
2201 }
2202 }
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216 public void setCharacterStream( int nIndex, Reader stream, int nLength )
2217 {
2218 try
2219 {
2220 _statement.setCharacterStream( nIndex, stream, nLength );
2221 }
2222 catch( SQLException e )
2223 {
2224 free( );
2225 throw new AppException( getErrorMessage( e ), e );
2226 }
2227 }
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241 public void setCharacterStream( int nIndex, Reader stream, long nLength )
2242 {
2243 try
2244 {
2245 _statement.setCharacterStream( nIndex, stream, nLength );
2246 }
2247 catch( SQLException e )
2248 {
2249 free( );
2250 throw new AppException( getErrorMessage( e ), e );
2251 }
2252 }
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263 public Reader getCharacterStream( int nIndex )
2264 {
2265 try
2266 {
2267 return _resultSet.getCharacterStream( nIndex );
2268 }
2269 catch( SQLException e )
2270 {
2271 free( );
2272 throw new AppException( getErrorMessage( e ), e );
2273 }
2274 }
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285 public Reader getCharacterStream( String strColumnName )
2286 {
2287 try
2288 {
2289 return _resultSet.getCharacterStream( strColumnName );
2290 }
2291 catch( SQLException e )
2292 {
2293 free( );
2294 throw new AppException( getErrorMessage( e ), e );
2295 }
2296 }
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308 public void setClob( int nIndex, Reader stream )
2309 {
2310 try
2311 {
2312 _statement.setClob( nIndex, stream );
2313 }
2314 catch( SQLException e )
2315 {
2316 free( );
2317 throw new AppException( getErrorMessage( e ), e );
2318 }
2319 }
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333 public void setClob( int nIndex, Reader stream, long nLength )
2334 {
2335 try
2336 {
2337 _statement.setClob( nIndex, stream, nLength );
2338 }
2339 catch( SQLException e )
2340 {
2341 free( );
2342 throw new AppException( getErrorMessage( e ), e );
2343 }
2344 }
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356 public void setClob( int nIndex, Clob clob )
2357 {
2358 try
2359 {
2360 _statement.setClob( nIndex, clob );
2361 }
2362 catch( SQLException e )
2363 {
2364 free( );
2365 throw new AppException( getErrorMessage( e ), e );
2366 }
2367 }
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378 public Clob getClob( int nIndex )
2379 {
2380 try
2381 {
2382 return _resultSet.getClob( nIndex );
2383 }
2384 catch( SQLException e )
2385 {
2386 free( );
2387 throw new AppException( getErrorMessage( e ), e );
2388 }
2389 }
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400 public Clob getClob( String strColumnName )
2401 {
2402 try
2403 {
2404 return _resultSet.getClob( strColumnName );
2405 }
2406 catch( SQLException e )
2407 {
2408 free( );
2409 throw new AppException( getErrorMessage( e ), e );
2410 }
2411 }
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423 public void setNClob( int nIndex, Reader stream )
2424 {
2425 try
2426 {
2427 _statement.setNClob( nIndex, stream );
2428 }
2429 catch( SQLException e )
2430 {
2431 free( );
2432 throw new AppException( getErrorMessage( e ), e );
2433 }
2434 }
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448 public void setNClob( int nIndex, Reader stream, long nLength )
2449 {
2450 try
2451 {
2452 _statement.setNClob( nIndex, stream, nLength );
2453 }
2454 catch( SQLException e )
2455 {
2456 free( );
2457 throw new AppException( getErrorMessage( e ), e );
2458 }
2459 }
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471 public void setClob( int nIndex, NClob clob )
2472 {
2473 try
2474 {
2475 _statement.setNClob( nIndex, clob );
2476 }
2477 catch( SQLException e )
2478 {
2479 free( );
2480 throw new AppException( getErrorMessage( e ), e );
2481 }
2482 }
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493 public NClob getNClob( int nIndex )
2494 {
2495 try
2496 {
2497 return _resultSet.getNClob( nIndex );
2498 }
2499 catch( SQLException e )
2500 {
2501 free( );
2502 throw new AppException( getErrorMessage( e ), e );
2503 }
2504 }
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515 public NClob getNClob( String strColumnName )
2516 {
2517 try
2518 {
2519 return _resultSet.getNClob( strColumnName );
2520 }
2521 catch( SQLException e )
2522 {
2523 free( );
2524 throw new AppException( getErrorMessage( e ), e );
2525 }
2526 }
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538 public void setFloat( int nIndex, float fValue )
2539 {
2540 try
2541 {
2542 _statement.setFloat( nIndex, fValue );
2543 logParameter( nIndex, fValue );
2544 }
2545 catch( SQLException e )
2546 {
2547 free( );
2548 throw new AppException( getErrorMessage( e ), e );
2549 }
2550 }
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561 public float getFloat( String strColumnName )
2562 {
2563 try
2564 {
2565 return _resultSet.getFloat( strColumnName );
2566 }
2567 catch( SQLException e )
2568 {
2569 free( );
2570 throw new AppException( getErrorMessage( e ), e );
2571 }
2572 }
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583 public float getFloat( int nIndex )
2584 {
2585 try
2586 {
2587 return _resultSet.getFloat( nIndex );
2588 }
2589 catch( SQLException e )
2590 {
2591 free( );
2592 throw new AppException( getErrorMessage( e ), e );
2593 }
2594 }
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606 public void setNCharacterStream( int nIndex, Reader stream )
2607 {
2608 try
2609 {
2610 _statement.setNCharacterStream( nIndex, stream );
2611 }
2612 catch( SQLException e )
2613 {
2614 free( );
2615 throw new AppException( getErrorMessage( e ), e );
2616 }
2617 }
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631 public void setNCharacterStream( int nIndex, Reader stream, long nLength )
2632 {
2633 try
2634 {
2635 _statement.setNCharacterStream( nIndex, stream, nLength );
2636 }
2637 catch( SQLException e )
2638 {
2639 free( );
2640 throw new AppException( getErrorMessage( e ), e );
2641 }
2642 }
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653 public Reader getNCharacterStream( int nIndex )
2654 {
2655 try
2656 {
2657 return _resultSet.getNCharacterStream( nIndex );
2658 }
2659 catch( SQLException e )
2660 {
2661 free( );
2662 throw new AppException( getErrorMessage( e ), e );
2663 }
2664 }
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675 public Reader getNCharacterStream( String strColumnName )
2676 {
2677 try
2678 {
2679 return _resultSet.getNCharacterStream( strColumnName );
2680 }
2681 catch( SQLException e )
2682 {
2683 free( );
2684 throw new AppException( getErrorMessage( e ), e );
2685 }
2686 }
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698 public void setNString( int nIndex, String strValue )
2699 {
2700 try
2701 {
2702 _statement.setNString( nIndex, strValue );
2703 }
2704 catch( SQLException e )
2705 {
2706 free( );
2707 throw new AppException( getErrorMessage( e ), e );
2708 }
2709 }
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720 public String getNString( int nIndex )
2721 {
2722 try
2723 {
2724 return _resultSet.getNString( nIndex );
2725 }
2726 catch( SQLException e )
2727 {
2728 free( );
2729 throw new AppException( getErrorMessage( e ), e );
2730 }
2731 }
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742 public String getNString( String strColumnName )
2743 {
2744 try
2745 {
2746 return _resultSet.getNString( strColumnName );
2747 }
2748 catch( SQLException e )
2749 {
2750 free( );
2751 throw new AppException( getErrorMessage( e ), e );
2752 }
2753 }
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765 public void setNull( int nIndex, int nType )
2766 {
2767 try
2768 {
2769 _statement.setNull( nIndex, nType );
2770 logParameter( nIndex, "null" );
2771 }
2772 catch( SQLException e )
2773 {
2774 free( );
2775 throw new AppException( getErrorMessage( e ), e );
2776 }
2777 }
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791 public void setNull( int nIndex, int nType, String strTypeName )
2792 {
2793 try
2794 {
2795 _statement.setNull( nIndex, nType, strTypeName );
2796 logParameter( nIndex, "null" );
2797 }
2798 catch( SQLException e )
2799 {
2800 free( );
2801 throw new AppException( getErrorMessage( e ), e );
2802 }
2803 }
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815 public void setObject( int nIndex, Object value )
2816 {
2817 try
2818 {
2819 _statement.setObject( nIndex, value );
2820 logParameter( nIndex, value );
2821 }
2822 catch( SQLException e )
2823 {
2824 free( );
2825 throw new AppException( getErrorMessage( e ), e );
2826 }
2827 }
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841 public void setObject( int nIndex, Object value, int nType )
2842 {
2843 try
2844 {
2845 _statement.setObject( nIndex, value, nType );
2846 logParameter( nIndex, value );
2847 }
2848 catch( SQLException e )
2849 {
2850 free( );
2851 throw new AppException( getErrorMessage( e ), e );
2852 }
2853 }
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869 public void setObject( int nIndex, Object value, int nType, int nScaleOrLength )
2870 {
2871 try
2872 {
2873 _statement.setObject( nIndex, value, nType, nScaleOrLength );
2874 logParameter( nIndex, value );
2875 }
2876 catch( SQLException e )
2877 {
2878 free( );
2879 throw new AppException( getErrorMessage( e ), e );
2880 }
2881 }
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892 public Ref getRef( int nIndex )
2893 {
2894 try
2895 {
2896 return _resultSet.getRef( nIndex );
2897 }
2898 catch( SQLException e )
2899 {
2900 free( );
2901 throw new AppException( getErrorMessage( e ), e );
2902 }
2903 }
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914 public Ref getRef( String strColumnName )
2915 {
2916 try
2917 {
2918 return _resultSet.getRef( strColumnName );
2919 }
2920 catch( SQLException e )
2921 {
2922 free( );
2923 throw new AppException( getErrorMessage( e ), e );
2924 }
2925 }
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937 public void setRef( int nIndex, Ref ref )
2938 {
2939 try
2940 {
2941 _statement.setRef( nIndex, ref );
2942 logParameter( nIndex, ref );
2943 }
2944 catch( SQLException e )
2945 {
2946 free( );
2947 throw new AppException( getErrorMessage( e ), e );
2948 }
2949 }
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961 public void setRowId( int nIndex, RowId rowId )
2962 {
2963 try
2964 {
2965 _statement.setRowId( nIndex, rowId );
2966 logParameter( nIndex, rowId );
2967 }
2968 catch( SQLException e )
2969 {
2970 free( );
2971 throw new AppException( getErrorMessage( e ), e );
2972 }
2973 }
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984 public RowId getRowId( int nIndex )
2985 {
2986 try
2987 {
2988 return _resultSet.getRowId( nIndex );
2989 }
2990 catch( SQLException e )
2991 {
2992 free( );
2993 throw new AppException( getErrorMessage( e ), e );
2994 }
2995 }
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006 public RowId getRowId( String strColumnName )
3007 {
3008 try
3009 {
3010 return _resultSet.getRowId( strColumnName );
3011 }
3012 catch( SQLException e )
3013 {
3014 free( );
3015 throw new AppException( getErrorMessage( e ), e );
3016 }
3017 }
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029 public void setShort( int nIndex, short shortValue )
3030 {
3031 try
3032 {
3033 _statement.setShort( nIndex, shortValue );
3034 logParameter( nIndex, shortValue );
3035 }
3036 catch( SQLException e )
3037 {
3038 free( );
3039 throw new AppException( getErrorMessage( e ), e );
3040 }
3041 }
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052 public short getShort( String strColumnName )
3053 {
3054 try
3055 {
3056 return _resultSet.getShort( strColumnName );
3057 }
3058 catch( SQLException e )
3059 {
3060 free( );
3061 throw new AppException( getErrorMessage( e ), e );
3062 }
3063 }
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074 public short getShort( int nIndex )
3075 {
3076 try
3077 {
3078 return _resultSet.getShort( nIndex );
3079 }
3080 catch( SQLException e )
3081 {
3082 free( );
3083 throw new AppException( getErrorMessage( e ), e );
3084 }
3085 }
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097 public void setSQLXML( int nIndex, SQLXML value )
3098 {
3099 try
3100 {
3101 _statement.setSQLXML( nIndex, value );
3102 logParameter( nIndex, value );
3103 }
3104 catch( SQLException e )
3105 {
3106 free( );
3107 throw new AppException( getErrorMessage( e ), e );
3108 }
3109 }
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120 public SQLXML getSQLXML( String strColumnName )
3121 {
3122 try
3123 {
3124 return _resultSet.getSQLXML( strColumnName );
3125 }
3126 catch( SQLException e )
3127 {
3128 free( );
3129 throw new AppException( getErrorMessage( e ), e );
3130 }
3131 }
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142 public SQLXML getSQLXML( int nIndex )
3143 {
3144 try
3145 {
3146 return _resultSet.getSQLXML( nIndex );
3147 }
3148 catch( SQLException e )
3149 {
3150 free( );
3151 throw new AppException( getErrorMessage( e ), e );
3152 }
3153 }
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165 public void setURL( int nIndex, URL url )
3166 {
3167 try
3168 {
3169 _statement.setURL( nIndex, url );
3170 logParameter( nIndex, url );
3171 }
3172 catch( SQLException e )
3173 {
3174 free( );
3175 throw new AppException( getErrorMessage( e ), e );
3176 }
3177 }
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188 public URL getURL( String strColumnName )
3189 {
3190 try
3191 {
3192 return _resultSet.getURL( strColumnName );
3193 }
3194 catch( SQLException e )
3195 {
3196 free( );
3197 throw new AppException( getErrorMessage( e ), e );
3198 }
3199 }
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210 public URL getURL( int nIndex )
3211 {
3212 try
3213 {
3214 return _resultSet.getURL( nIndex );
3215 }
3216 catch( SQLException e )
3217 {
3218 free( );
3219 throw new AppException( getErrorMessage( e ), e );
3220 }
3221 }
3222
3223
3224
3225
3226
3227
3228 public void addBatch( )
3229 {
3230 try
3231 {
3232 _statement.addBatch( );
3233 }
3234 catch( SQLException e )
3235 {
3236 free( );
3237 throw new AppException( getErrorMessage( e ), e );
3238 }
3239 }
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254 public void addBatch( String sql )
3255 {
3256 try
3257 {
3258 _statement.addBatch( sql );
3259 }
3260 catch( SQLException e )
3261 {
3262 free( );
3263 throw new AppException( getErrorMessage( e ), e );
3264 }
3265 }
3266
3267
3268
3269
3270
3271
3272
3273
3274 void clearBatch( )
3275 {
3276
3277 try
3278 {
3279 _statement.clearBatch( );
3280 }
3281 catch( SQLException e )
3282 {
3283 free( );
3284 throw new AppException( getErrorMessage( e ), e );
3285 }
3286 }
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297 public void clearParameters( )
3298 {
3299 try
3300 {
3301 _statement.clearParameters( );
3302 }
3303 catch( SQLException e )
3304 {
3305 free( );
3306 throw new AppException( getErrorMessage( e ), e );
3307 }
3308 }
3309
3310
3311
3312
3313
3314
3315
3316
3317 public int [ ] executeBatch( )
3318 {
3319 try
3320 {
3321 return _statement.executeBatch( );
3322 }
3323 catch( SQLException e )
3324 {
3325 free( );
3326 throw new AppException( getErrorMessage( e ), e );
3327 }
3328 }
3329
3330
3331
3332
3333 @Override
3334 protected void finalize( ) throws Throwable
3335 {
3336 if ( !_bReleased )
3337 {
3338 free( );
3339 AppLogService.error(
3340 "A call to DAOUtil.free() seems to be missing or an unexpected exception has occured during the use of a DAOUtil object - plugin : {} - SQL statement : {}",
3341 _strPluginName, _strSQL );
3342 }
3343
3344 super.finalize( );
3345 }
3346
3347
3348
3349
3350 @Override
3351 public void close( )
3352 {
3353 free( );
3354 }
3355 }