1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <sal/macros.h>
21 #include <java/sql/DatabaseMetaData.hxx>
22 #include <java/sql/Connection.hxx>
23 #include <java/sql/ResultSet.hxx>
24 #include <java/tools.hxx>
25 #include <java/lang/String.hxx>
26 #include <connectivity/CommonTools.hxx>
27 #include <FDatabaseMetaDataResultSet.hxx>
28 #include <comphelper/types.hxx>
29 #include <TPrivilegesResultSet.hxx>
30 #include <strings.hxx>
31
32 using namespace ::comphelper;
33
34 using namespace connectivity;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::sdbc;
38 using namespace ::com::sun::star::container;
39 using namespace ::com::sun::star::lang;
40
41 jclass java_sql_DatabaseMetaData::theClass = nullptr;
42
~java_sql_DatabaseMetaData()43 java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
44 {
45 SDBThreadAttach::releaseRef();
46 }
47
getMyClass() const48 jclass java_sql_DatabaseMetaData::getMyClass() const
49 {
50 // the class must be fetched only once, therefore static
51 if( !theClass )
52 theClass = findMyClass("java/sql/DatabaseMetaData");
53 return theClass;
54 }
55
java_sql_DatabaseMetaData(JNIEnv * pEnv,jobject myObj,java_sql_Connection & _rConnection)56 java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rConnection )
57 :ODatabaseMetaDataBase( &_rConnection,_rConnection.getConnectionInfo() )
58 ,java_lang_Object( pEnv, myObj )
59 ,m_pConnection( &_rConnection )
60 ,m_aLogger( _rConnection.getLogger() )
61 {
62 SDBThreadAttach::addRef();
63 }
64
65
impl_getTypeInfo_throw()66 Reference< XResultSet > java_sql_DatabaseMetaData::impl_getTypeInfo_throw( )
67 {
68 static jmethodID mID(nullptr);
69 return impl_callResultSetMethod( "getTypeInfo", mID );
70 }
71
getCatalogs()72 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCatalogs( )
73 {
74 static jmethodID mID(nullptr);
75 return impl_callResultSetMethod( "getCatalogs", mID );
76 }
77
impl_getCatalogSeparator_throw()78 OUString java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( )
79 {
80 static jmethodID mID(nullptr);
81 return impl_callStringMethod( "getCatalogSeparator", mID );
82 }
83
getSchemas()84 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getSchemas( )
85 {
86 static jmethodID mID(nullptr);
87 return impl_callResultSetMethod( "getSchemas", mID );
88 }
89
getColumnPrivileges(const Any & catalog,const OUString & schema,const OUString & table,const OUString & columnNamePattern)90 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges(
91 const Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern )
92 {
93 static jmethodID mID(nullptr);
94 return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID, catalog, schema, table, &columnNamePattern );
95 }
96
getColumns(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern,const OUString & columnNamePattern)97 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns(
98 const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern )
99 {
100 static jmethodID mID(nullptr);
101 return impl_callResultSetMethodWithStrings( "getColumns", mID, catalog, schemaPattern, tableNamePattern, &columnNamePattern );
102 }
103
104
getTables(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern,const Sequence<OUString> & _types)105 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
106 const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const Sequence< OUString >& _types )
107 {
108 static const char * const cMethodName = "getTables";
109
110 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
111
112 jobject out(nullptr);
113 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
114
115 {
116 static const char * const cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
117 // execute Java-Call
118 static jmethodID mID(nullptr);
119 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
120 OSL_VERIFY( !isExceptionOccurred(t.pEnv) );
121 jvalue args[4];
122
123 args[3].l = nullptr;
124 sal_Int32 typeFilterCount = _types.getLength();
125 if ( typeFilterCount )
126 {
127 jobjectArray pObjArray = t.pEnv->NewObjectArray( static_cast<jsize>(typeFilterCount), java_lang_String::st_getMyClass(), nullptr );
128 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
129 const OUString* typeFilter = _types.getConstArray();
130 bool bIncludeAllTypes = false;
131 for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter )
132 {
133 if ( *typeFilter == "%" )
134 {
135 bIncludeAllTypes = true;
136 break;
137 }
138 jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter );
139 t.pEnv->SetObjectArrayElement( pObjArray, static_cast<jsize>(i), aT );
140 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
141 }
142
143 if ( bIncludeAllTypes )
144 {
145 // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types"
146 // is represented by the table type being <null/>
147 t.pEnv->DeleteLocalRef( pObjArray );
148 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
149 }
150 else
151 {
152 args[3].l = pObjArray;
153 }
154 }
155 // if we are to display "all catalogs", then respect m_aCatalogRestriction
156 Any aCatalogFilter( catalog );
157 if ( !aCatalogFilter.hasValue() )
158 aCatalogFilter = m_pConnection->getCatalogRestriction();
159 // similar for schema
160 Any aSchemaFilter;
161 if ( schemaPattern == "%" )
162 aSchemaFilter = m_pConnection->getSchemaRestriction();
163 else
164 aSchemaFilter <<= schemaPattern;
165
166 args[0].l = aCatalogFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aCatalogFilter ) ) : nullptr;
167 args[1].l = aSchemaFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aSchemaFilter ) ) : nullptr;
168 args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern);
169 out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
170 jthrowable jThrow = t.pEnv->ExceptionOccurred();
171 if ( jThrow )
172 t.pEnv->ExceptionClear();// we have to clear the exception here because we want to handle it below
173 if ( aCatalogFilter.hasValue() )
174 {
175 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
176 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
177 }
178 if(args[1].l)
179 {
180 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
181 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
182 }
183 if(!tableNamePattern.isEmpty())
184 {
185 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l));
186 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
187 }
188 //for(INT16 i=0;i<len;i++)
189 if ( args[3].l )
190 {
191 t.pEnv->DeleteLocalRef( static_cast<jobjectArray>(args[3].l) );
192 OSL_VERIFY( !isExceptionOccurred( t.pEnv ) );
193 }
194
195 if ( jThrow )
196 {
197 if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) )
198 {
199 java_sql_SQLException_BASE aException( t.pEnv, jThrow );
200 SQLException e( aException.getMessage(),
201 *this,
202 aException.getSQLState(),
203 aException.getErrorCode(),
204 Any()
205 );
206 throw e;
207 }
208 }
209 }
210
211 if ( !out )
212 return nullptr;
213
214 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
215 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
216 }
217
getProcedureColumns(const Any & catalog,const OUString & schemaPattern,const OUString & procedureNamePattern,const OUString & columnNamePattern)218 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedureColumns(
219 const Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern )
220 {
221 static jmethodID mID(nullptr);
222 return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID, catalog, schemaPattern, procedureNamePattern, &columnNamePattern );
223 }
224
getProcedures(const Any & catalog,const OUString & schemaPattern,const OUString & procedureNamePattern)225 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedures( const Any&
226 catalog, const OUString& schemaPattern, const OUString& procedureNamePattern )
227 {
228 static jmethodID mID(nullptr);
229 return impl_callResultSetMethodWithStrings( "getProcedures", mID, catalog, schemaPattern, procedureNamePattern );
230 }
231
getVersionColumns(const Any & catalog,const OUString & schema,const OUString & table)232 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns(
233 const Any& catalog, const OUString& schema, const OUString& table )
234 {
235 static jmethodID mID(nullptr);
236 return impl_callResultSetMethodWithStrings( "getVersionColumns", mID, catalog, schema, table );
237 }
238
getMaxBinaryLiteralLength()239 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( )
240 {
241 static jmethodID mID(nullptr);
242 return impl_callIntMethod_ThrowSQL("getMaxBinaryLiteralLength", mID);
243 }
244
getMaxRowSize()245 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( )
246 {
247 static jmethodID mID(nullptr);
248 return impl_callIntMethod_ThrowSQL("getMaxRowSize", mID);
249 }
250
getMaxCatalogNameLength()251 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( )
252 {
253 static jmethodID mID(nullptr);
254 return impl_callIntMethod_ThrowSQL("getMaxCatalogNameLength", mID);
255 }
256
getMaxCharLiteralLength()257 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( )
258 {
259 static jmethodID mID(nullptr);
260 return impl_callIntMethod_ThrowSQL("getMaxCharLiteralLength", mID);
261 }
262
getMaxColumnNameLength()263 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( )
264 {
265 static jmethodID mID(nullptr);
266 return impl_callIntMethod_ThrowSQL("getMaxColumnNameLength", mID);
267 }
268
getMaxColumnsInIndex()269 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( )
270 {
271 static jmethodID mID(nullptr);
272 return impl_callIntMethod_ThrowSQL("getMaxColumnsInIndex", mID);
273 }
274
getMaxCursorNameLength()275 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( )
276 {
277 static jmethodID mID(nullptr);
278 return impl_callIntMethod_ThrowSQL("getMaxCursorNameLength", mID);
279 }
280
getMaxConnections()281 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( )
282 {
283 static jmethodID mID(nullptr);
284 return impl_callIntMethod_ThrowSQL("getMaxConnections", mID);
285 }
286
getMaxColumnsInTable()287 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( )
288 {
289 static jmethodID mID(nullptr);
290 return impl_callIntMethod_ThrowSQL("getMaxColumnsInTable", mID);
291 }
292
getMaxStatementLength()293 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( )
294 {
295 static jmethodID mID(nullptr);
296 return impl_callIntMethod_ThrowSQL("getMaxStatementLength", mID);
297 }
298
getMaxTableNameLength()299 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( )
300 {
301 static jmethodID mID(nullptr);
302 return impl_callIntMethod_ThrowSQL("getMaxTableNameLength", mID);
303 }
304
impl_getMaxTablesInSelect_throw()305 sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( )
306 {
307 static jmethodID mID(nullptr);
308 return impl_callIntMethod_ThrowSQL("getMaxTablesInSelect", mID);
309 }
310
getExportedKeys(const Any & catalog,const OUString & schema,const OUString & table)311 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys(
312 const Any& catalog, const OUString& schema, const OUString& table )
313 {
314 static jmethodID mID(nullptr);
315 return impl_callResultSetMethodWithStrings( "getExportedKeys", mID, catalog, schema, table );
316 }
317
getImportedKeys(const Any & catalog,const OUString & schema,const OUString & table)318 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getImportedKeys(
319 const Any& catalog, const OUString& schema, const OUString& table )
320 {
321 static jmethodID mID(nullptr);
322 return impl_callResultSetMethodWithStrings( "getImportedKeys", mID, catalog, schema, table );
323 }
324
getPrimaryKeys(const Any & catalog,const OUString & schema,const OUString & table)325 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getPrimaryKeys(
326 const Any& catalog, const OUString& schema, const OUString& table )
327 {
328 static jmethodID mID(nullptr);
329 return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID, catalog, schema, table );
330 }
331
getIndexInfo(const Any & catalog,const OUString & schema,const OUString & table,sal_Bool unique,sal_Bool approximate)332 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo(
333 const Any& catalog, const OUString& schema, const OUString& table,
334 sal_Bool unique, sal_Bool approximate )
335 {
336 static const char * const cMethodName = "getIndexInfo";
337
338 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
339
340 jobject out(nullptr);
341 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
342
343 {
344 static const char * const cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
345 // execute Java-Call
346 static jmethodID mID(nullptr);
347 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
348 jvalue args[5];
349 // convert Parameter
350 args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : nullptr;
351 args[1].l = schema.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t.pEnv,schema);
352 args[2].l = convertwchar_tToJavaString(t.pEnv,table);
353 args[3].z = unique;
354 args[4].z = approximate;
355 out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z );
356
357 // and clean up
358 if(catalog.hasValue())
359 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
360 if(args[1].l)
361 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
362 if(!table.isEmpty())
363 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l));
364 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
365 }
366 if ( !out )
367 return nullptr;
368
369 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
370 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
371 }
372
getBestRowIdentifier(const Any & catalog,const OUString & schema,const OUString & table,sal_Int32 scope,sal_Bool nullable)373 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier(
374 const Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope,
375 sal_Bool nullable )
376 {
377 static const char * const cMethodName = "getBestRowIdentifier";
378
379 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
380
381 jobject out(nullptr);
382 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
383
384 {
385 static const char * const cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
386 // execute Java-Call
387 static jmethodID mID(nullptr);
388 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
389 jvalue args[3];
390 // convert Parameter
391 args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : nullptr;
392 args[1].l = schema.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t.pEnv,schema);
393 args[2].l = convertwchar_tToJavaString(t.pEnv,table);
394 out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable);
395
396 // and cleanup
397 if(catalog.hasValue())
398 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
399 if(args[1].l)
400 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
401 if(!table.isEmpty())
402 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l));
403 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
404 }
405
406 if ( !out )
407 return nullptr;
408
409 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
410 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
411 }
412
getTablePrivileges(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern)413 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges(
414 const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern )
415 {
416 if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
417 return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
418
419 static jmethodID mID(nullptr);
420 Reference< XResultSet > xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID, catalog, schemaPattern, tableNamePattern ) );
421
422 if ( xReturn.is() )
423 {
424 // we have to check the result columns for the tables privileges
425 Reference< XResultSetMetaDataSupplier > xMetaSup(xReturn,UNO_QUERY);
426 if ( xMetaSup.is() )
427 {
428 Reference< XResultSetMetaData> xMeta = xMetaSup->getMetaData();
429 if ( xMeta.is() && xMeta->getColumnCount() != 7 )
430 {
431 // here we know that the count of column doesn't match
432 std::map<sal_Int32,sal_Int32> aColumnMatching;
433 static const OUStringLiteral sPrivs[] = {
434 "TABLE_CAT",
435 "TABLE_SCHEM",
436 "TABLE_NAME",
437 "GRANTOR",
438 "GRANTEE",
439 "PRIVILEGE",
440 "IS_GRANTABLE"
441 };
442
443 OUString sColumnName;
444 sal_Int32 nCount = xMeta->getColumnCount();
445 for (sal_Int32 i = 1 ; i <= nCount ; ++i)
446 {
447 sColumnName = xMeta->getColumnName(i);
448 for (size_t j = 0 ; j < SAL_N_ELEMENTS(sPrivs); ++j)
449 {
450 if ( sPrivs[j] == sColumnName )
451 {
452 aColumnMatching.emplace(i,j+1);
453 break;
454 }
455 }
456
457 }
458 // fill our own resultset
459 ODatabaseMetaDataResultSet* pNewPrivRes = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
460 Reference< XResultSet > xTemp = xReturn;
461 xReturn = pNewPrivRes;
462 ODatabaseMetaDataResultSet::ORows aRows;
463 Reference< XRow > xRow(xTemp,UNO_QUERY);
464 OUString sValue;
465
466 ODatabaseMetaDataResultSet::ORow aRow(8);
467 while ( xRow.is() && xTemp->next() )
468 {
469 for (const auto& [nCol, nPriv] : aColumnMatching)
470 {
471 sValue = xRow->getString(nCol);
472 if ( xRow->wasNull() )
473 aRow[nPriv] = ODatabaseMetaDataResultSet::getEmptyValue();
474 else
475 aRow[nPriv] = new ORowSetValueDecorator(sValue);
476 }
477
478 aRows.push_back(aRow);
479 }
480 pNewPrivRes->setRows(aRows);
481 }
482 }
483 }
484 return xReturn;
485 }
486
getCrossReference(const Any & primaryCatalog,const OUString & primarySchema,const OUString & primaryTable,const Any & foreignCatalog,const OUString & foreignSchema,const OUString & foreignTable)487 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference(
488 const Any& primaryCatalog, const OUString& primarySchema,
489 const OUString& primaryTable, const Any& foreignCatalog,
490 const OUString& foreignSchema, const OUString& foreignTable )
491 {
492 static const char * const cMethodName = "getCrossReference";
493 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
494
495 jobject out(nullptr);
496 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
497 {
498 static const char * const cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
499 // execute Java-Call
500 static jmethodID mID(nullptr);
501 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
502 jvalue args[6];
503 // convert Parameter
504 args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(primaryCatalog)) : nullptr;
505 args[1].l = primarySchema.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t.pEnv,primarySchema);
506 args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable);
507 args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(foreignCatalog)) : nullptr;
508 args[4].l = foreignSchema.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t.pEnv,foreignSchema);
509 args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable);
510 out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l );
511
512 // and clean up
513 if(primaryCatalog.hasValue())
514 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
515 if(args[1].l)
516 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
517 if(!primaryTable.isEmpty())
518 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l));
519 if(foreignCatalog.hasValue())
520 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[3].l));
521 if(args[4].l)
522 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[4].l));
523 if(!foreignTable.isEmpty())
524 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[5].l));
525 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
526 }
527
528 if ( !out )
529 return nullptr;
530
531 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
532 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
533 }
534
535
impl_callBooleanMethod(const char * _pMethodName,jmethodID & _inout_MethodID)536 bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
537 {
538 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
539 bool out( java_lang_Object::callBooleanMethod(_pMethodName,_inout_MethodID) );
540 m_aLogger.log< const sal_Char*, bool>( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
541 return out;
542 }
543
544
impl_callStringMethod(const char * _pMethodName,jmethodID & _inout_MethodID)545 OUString java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
546 {
547 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
548
549 const OUString sReturn( callStringMethod(_pMethodName,_inout_MethodID) );
550 if ( m_aLogger.isLoggable( LogLevel::FINEST ) )
551 {
552 OUString sLoggedResult( sReturn );
553 if ( sLoggedResult.isEmpty() )
554 sLoggedResult = "<empty string>";
555 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, sLoggedResult );
556 }
557
558 return sReturn;
559 }
560
impl_callIntMethod_ThrowSQL(const char * _pMethodName,jmethodID & _inout_MethodID)561 sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod_ThrowSQL(const char* _pMethodName, jmethodID& _inout_MethodID)
562 {
563 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
564 sal_Int32 out( callIntMethod_ThrowSQL(_pMethodName,_inout_MethodID) );
565 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
566 return out;
567 }
568
impl_callIntMethod_ThrowRuntime(const char * _pMethodName,jmethodID & _inout_MethodID)569 sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod_ThrowRuntime(const char* _pMethodName, jmethodID& _inout_MethodID)
570 {
571 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
572 sal_Int32 out( callIntMethod_ThrowRuntime(_pMethodName,_inout_MethodID) );
573 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
574 return out;
575 }
576
impl_callBooleanMethodWithIntArg(const char * _pMethodName,jmethodID & _inout_MethodID,sal_Int32 _nArgument)577 bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument )
578 {
579 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG1, _pMethodName, _nArgument );
580
581 bool out( callBooleanMethodWithIntArg(_pMethodName,_inout_MethodID,_nArgument) );
582
583 m_aLogger.log< const sal_Char*, bool >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
584 return out;
585 }
586
587
impl_callResultSetMethod(const char * _pMethodName,jmethodID & _inout_MethodID)588 Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
589 {
590 SDBThreadAttach t;
591 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
592 jobject out(callResultSetMethod(t.env(),_pMethodName,_inout_MethodID));
593 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName );
594 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
595 }
596
597
impl_callResultSetMethodWithStrings(const char * _pMethodName,jmethodID & _inout_MethodID,const Any & _rCatalog,const OUString & _rSchemaPattern,const OUString & _rLeastPattern,const OUString * _pOptionalAdditionalString)598 Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings( const char* _pMethodName, jmethodID& _inout_MethodID,
599 const Any& _rCatalog, const OUString& _rSchemaPattern, const OUString& _rLeastPattern,
600 const OUString* _pOptionalAdditionalString )
601 {
602 bool bCatalog = _rCatalog.hasValue();
603 OUString sCatalog;
604 _rCatalog >>= sCatalog;
605
606 bool bSchema = _rSchemaPattern.toChar() != '%';
607
608 // log the call
609 if ( m_aLogger.isLoggable( LogLevel::FINEST ) )
610 {
611 OUString sCatalogLog = bCatalog ? sCatalog : OUString( "null" );
612 OUString sSchemaLog = bSchema ? _rSchemaPattern : OUString( "null" );
613 if ( _pOptionalAdditionalString )
614 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG4, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern, *_pOptionalAdditionalString );
615 else
616 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG3, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern );
617 }
618
619 jobject out(nullptr);
620
621 SDBThreadAttach t;
622 OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java environment anymore!" );
623
624 {
625 const char* pSignature = _pOptionalAdditionalString
626 ? "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"
627 : "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
628 // obtain method ID
629 obtainMethodId_throwSQL(t.pEnv, _pMethodName,pSignature, _inout_MethodID);
630
631 // call method
632
633 {
634 jvalue args[4];
635 // convert parameters
636 args[0].l = bCatalog ? convertwchar_tToJavaString( t.pEnv, sCatalog ) : nullptr;
637 args[1].l = bSchema ? convertwchar_tToJavaString( t.pEnv, _rSchemaPattern ) : nullptr;
638 args[2].l = convertwchar_tToJavaString( t.pEnv, _rLeastPattern );
639 args[3].l = _pOptionalAdditionalString ? convertwchar_tToJavaString( t.pEnv, *_pOptionalAdditionalString ) : nullptr;
640
641 // actually do the call
642 if ( _pOptionalAdditionalString )
643 out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l, args[3].l );
644 else
645 out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l );
646
647 // clean up
648 if ( args[0].l )
649 t.pEnv->DeleteLocalRef( static_cast<jstring>(args[0].l) );
650 if ( args[1].l )
651 t.pEnv->DeleteLocalRef( static_cast<jstring>(args[1].l) );
652 if ( args[2].l )
653 t.pEnv->DeleteLocalRef( static_cast<jstring>(args[2].l) );
654 if ( args[3].l )
655 t.pEnv->DeleteLocalRef( static_cast<jstring>(args[3].l) );
656
657 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
658 }
659 }
660
661 if ( !out )
662 return nullptr;
663
664 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName );
665 return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
666 }
667
668
doesMaxRowSizeIncludeBlobs()669 sal_Bool SAL_CALL java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
670 {
671 static jmethodID mID(nullptr);
672 return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID );
673 }
674
storesLowerCaseQuotedIdentifiers()675 sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
676 {
677 static jmethodID mID(nullptr);
678 return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID );
679 }
680
storesLowerCaseIdentifiers()681 sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( )
682 {
683 static jmethodID mID(nullptr);
684 return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID );
685 }
686
impl_storesMixedCaseQuotedIdentifiers_throw()687 bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
688 {
689 static jmethodID mID(nullptr);
690 return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID );
691 }
692
storesMixedCaseIdentifiers()693 sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( )
694 {
695 static jmethodID mID(nullptr);
696 return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID );
697 }
698
storesUpperCaseQuotedIdentifiers()699 sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
700 {
701 static jmethodID mID(nullptr);
702 return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID );
703 }
704
storesUpperCaseIdentifiers()705 sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( )
706 {
707 static jmethodID mID(nullptr);
708 return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID );
709 }
710
impl_supportsAlterTableWithAddColumn_throw()711 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
712 {
713 static jmethodID mID(nullptr);
714 return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID );
715 }
716
impl_supportsAlterTableWithDropColumn_throw()717 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
718 {
719 static jmethodID mID(nullptr);
720 return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID );
721 }
722
getMaxIndexLength()723 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( )
724 {
725 static jmethodID mID(nullptr);
726 return impl_callIntMethod_ThrowSQL("getMaxIndexLength", mID);
727 }
728
supportsNonNullableColumns()729 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( )
730 {
731 static jmethodID mID(nullptr);
732 return impl_callBooleanMethod( "supportsNonNullableColumns", mID );
733 }
734
getCatalogTerm()735 OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogTerm( )
736 {
737 static jmethodID mID(nullptr);
738 return impl_callStringMethod( "getCatalogTerm", mID );
739 }
740
impl_getIdentifierQuoteString_throw()741 OUString java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( )
742 {
743 static jmethodID mID(nullptr);
744 return impl_callStringMethod( "getIdentifierQuoteString", mID );
745 }
746
getExtraNameCharacters()747 OUString SAL_CALL java_sql_DatabaseMetaData::getExtraNameCharacters( )
748 {
749 static jmethodID mID(nullptr);
750 return impl_callStringMethod( "getExtraNameCharacters", mID );
751 }
752
supportsDifferentTableCorrelationNames()753 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( )
754 {
755 static jmethodID mID(nullptr);
756 return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID );
757 }
758
impl_isCatalogAtStart_throw()759 bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( )
760 {
761 static jmethodID mID(nullptr);
762 return impl_callBooleanMethod( "isCatalogAtStart", mID );
763 }
764
dataDefinitionIgnoredInTransactions()765 sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( )
766 {
767 static jmethodID mID(nullptr);
768 return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID );
769 }
770
dataDefinitionCausesTransactionCommit()771 sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( )
772 {
773 static jmethodID mID(nullptr);
774 return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID );
775 }
776
supportsDataManipulationTransactionsOnly()777 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( )
778 {
779 static jmethodID mID(nullptr);
780 return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID );
781 }
782
supportsDataDefinitionAndDataManipulationTransactions()783 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
784 {
785 static jmethodID mID(nullptr);
786 return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID );
787 }
788
supportsPositionedDelete()789 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedDelete( )
790 {
791 static jmethodID mID(nullptr);
792 return impl_callBooleanMethod( "supportsPositionedDelete", mID );
793 }
794
supportsPositionedUpdate()795 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedUpdate( )
796 {
797 static jmethodID mID(nullptr);
798 return impl_callBooleanMethod( "supportsPositionedUpdate", mID );
799 }
800
supportsOpenStatementsAcrossRollback()801 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( )
802 {
803 static jmethodID mID(nullptr);
804 return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID );
805 }
806
supportsOpenStatementsAcrossCommit()807 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( )
808 {
809 static jmethodID mID(nullptr);
810 return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID );
811 }
812
supportsOpenCursorsAcrossCommit()813 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( )
814 {
815 static jmethodID mID(nullptr);
816 return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID );
817 }
818
supportsOpenCursorsAcrossRollback()819 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( )
820 {
821 static jmethodID mID(nullptr);
822 return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID );
823 }
824
supportsTransactionIsolationLevel(sal_Int32 level)825 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level )
826 {
827 static jmethodID mID(nullptr);
828 return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID, level );
829 }
830
impl_supportsSchemasInDataManipulation_throw()831 bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
832 {
833 static jmethodID mID(nullptr);
834 return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID );
835 }
836
supportsANSI92FullSQL()837 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92FullSQL( )
838 {
839 static jmethodID mID(nullptr);
840 return impl_callBooleanMethod( "supportsANSI92FullSQL", mID );
841 }
842
supportsANSI92EntryLevelSQL()843 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( )
844 {
845 static jmethodID mID(nullptr);
846 return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID );
847 }
848
supportsIntegrityEnhancementFacility()849 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( )
850 {
851 static jmethodID mID(nullptr);
852 return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID );
853 }
854
supportsSchemasInIndexDefinitions()855 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( )
856 {
857 static jmethodID mID(nullptr);
858 return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID );
859 }
860
impl_supportsSchemasInTableDefinitions_throw()861 bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
862 {
863 static jmethodID mID(nullptr);
864 return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID );
865 }
866
impl_supportsCatalogsInTableDefinitions_throw()867 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
868 {
869 static jmethodID mID(nullptr);
870 return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID );
871 }
872
supportsCatalogsInIndexDefinitions()873 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( )
874 {
875 static jmethodID mID(nullptr);
876 return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID );
877 }
878
impl_supportsCatalogsInDataManipulation_throw()879 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
880 {
881 static jmethodID mID(nullptr);
882 return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID );
883 }
884
supportsOuterJoins()885 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOuterJoins( )
886 {
887 static jmethodID mID(nullptr);
888 return impl_callBooleanMethod( "supportsOuterJoins", mID );
889 }
890
getTableTypes()891 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( )
892 {
893 static jmethodID mID(nullptr);
894 return impl_callResultSetMethod( "getTableTypes", mID );
895 }
896
impl_getMaxStatements_throw()897 sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( )
898 {
899 static jmethodID mID(nullptr);
900 return impl_callIntMethod_ThrowSQL("getMaxStatements", mID);
901 }
902
getMaxProcedureNameLength()903 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( )
904 {
905 static jmethodID mID(nullptr);
906 return impl_callIntMethod_ThrowSQL("getMaxProcedureNameLength", mID);
907 }
908
getMaxSchemaNameLength()909 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( )
910 {
911 static jmethodID mID(nullptr);
912 return impl_callIntMethod_ThrowSQL("getMaxSchemaNameLength", mID);
913 }
914
supportsTransactions()915 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( )
916 {
917 static jmethodID mID(nullptr);
918 return impl_callBooleanMethod( "supportsTransactions", mID );
919 }
920
921
allProceduresAreCallable()922 sal_Bool SAL_CALL java_sql_DatabaseMetaData::allProceduresAreCallable( )
923 {
924 static jmethodID mID(nullptr);
925 return impl_callBooleanMethod( "allProceduresAreCallable", mID );
926 }
927
supportsStoredProcedures()928 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsStoredProcedures( )
929 {
930 static jmethodID mID(nullptr);
931 return impl_callBooleanMethod( "supportsStoredProcedures", mID );
932 }
933
supportsSelectForUpdate()934 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSelectForUpdate( )
935 {
936 static jmethodID mID(nullptr);
937 return impl_callBooleanMethod( "supportsSelectForUpdate", mID );
938 }
939
allTablesAreSelectable()940 sal_Bool SAL_CALL java_sql_DatabaseMetaData::allTablesAreSelectable( )
941 {
942 static jmethodID mID(nullptr);
943 return impl_callBooleanMethod( "allTablesAreSelectable", mID );
944 }
945
isReadOnly()946 sal_Bool SAL_CALL java_sql_DatabaseMetaData::isReadOnly( )
947 {
948 static jmethodID mID(nullptr);
949 return impl_callBooleanMethod( "isReadOnly", mID );
950 }
951
usesLocalFiles()952 sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFiles( )
953 {
954 static jmethodID mID(nullptr);
955 return impl_callBooleanMethod( "usesLocalFiles", mID );
956 }
957
usesLocalFilePerTable()958 sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFilePerTable( )
959 {
960 static jmethodID mID(nullptr);
961 return impl_callBooleanMethod( "usesLocalFilePerTable", mID );
962 }
963
supportsTypeConversion()964 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTypeConversion( )
965 {
966 static jmethodID mID(nullptr);
967 return impl_callBooleanMethod( "supportsTypeConversion", mID );
968 }
969
nullPlusNonNullIsNull()970 sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullPlusNonNullIsNull( )
971 {
972 static jmethodID mID(nullptr);
973 return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID );
974 }
975
supportsColumnAliasing()976 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsColumnAliasing( )
977 {
978 static jmethodID mID(nullptr);
979 return impl_callBooleanMethod( "supportsColumnAliasing", mID );
980 }
981
supportsTableCorrelationNames()982 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTableCorrelationNames( )
983 {
984 static jmethodID mID(nullptr);
985 return impl_callBooleanMethod( "supportsTableCorrelationNames", mID );
986 }
987
supportsConvert(sal_Int32 fromType,sal_Int32 toType)988 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType )
989 {
990 static const char* const pMethodName = "supportsConvert";
991 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, fromType, toType );
992
993 bool out( false );
994 SDBThreadAttach t;
995
996 {
997 static jmethodID mID(nullptr);
998 obtainMethodId_throwSQL(t.pEnv, pMethodName,"(II)Z", mID);
999 out = t.pEnv->CallBooleanMethod( object, mID, fromType, toType );
1000 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
1001 }
1002
1003 m_aLogger.log< const sal_Char*, bool >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
1004 return out;
1005 }
1006
supportsExpressionsInOrderBy()1007 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( )
1008 {
1009 static jmethodID mID(nullptr);
1010 return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID );
1011 }
1012
supportsGroupBy()1013 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupBy( )
1014 {
1015 static jmethodID mID(nullptr);
1016 return impl_callBooleanMethod( "supportsGroupBy", mID );
1017 }
1018
supportsGroupByBeyondSelect()1019 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( )
1020 {
1021 static jmethodID mID(nullptr);
1022 return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID );
1023 }
1024
supportsGroupByUnrelated()1025 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByUnrelated( )
1026 {
1027 static jmethodID mID(nullptr);
1028 return impl_callBooleanMethod( "supportsGroupByUnrelated", mID );
1029 }
1030
supportsMultipleTransactions()1031 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleTransactions( )
1032 {
1033 static jmethodID mID(nullptr);
1034 return impl_callBooleanMethod( "supportsMultipleTransactions", mID );
1035 }
1036
supportsMultipleResultSets()1037 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleResultSets( )
1038 {
1039 static jmethodID mID(nullptr);
1040 return impl_callBooleanMethod( "supportsMultipleResultSets", mID );
1041 }
1042
supportsLikeEscapeClause()1043 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLikeEscapeClause( )
1044 {
1045 static jmethodID mID(nullptr);
1046 return impl_callBooleanMethod( "supportsLikeEscapeClause", mID );
1047 }
1048
supportsOrderByUnrelated()1049 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOrderByUnrelated( )
1050 {
1051 static jmethodID mID(nullptr);
1052 return impl_callBooleanMethod( "supportsOrderByUnrelated", mID );
1053 }
1054
supportsUnion()1055 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnion( )
1056 {
1057 static jmethodID mID(nullptr);
1058 return impl_callBooleanMethod( "supportsUnion", mID );
1059 }
1060
supportsUnionAll()1061 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnionAll( )
1062 {
1063 static jmethodID mID(nullptr);
1064 return impl_callBooleanMethod( "supportsUnionAll", mID );
1065 }
1066
supportsMixedCaseIdentifiers()1067 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( )
1068 {
1069 static jmethodID mID(nullptr);
1070 return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID );
1071 }
1072
impl_supportsMixedCaseQuotedIdentifiers_throw()1073 bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1074 {
1075 static jmethodID mID(nullptr);
1076 return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID );
1077 }
1078
nullsAreSortedAtEnd()1079 sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtEnd( )
1080 {
1081 static jmethodID mID(nullptr);
1082 return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID );
1083 }
1084
nullsAreSortedAtStart()1085 sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtStart( )
1086 {
1087 static jmethodID mID(nullptr);
1088 return impl_callBooleanMethod( "nullsAreSortedAtStart", mID );
1089 }
1090
nullsAreSortedHigh()1091 sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedHigh( )
1092 {
1093 static jmethodID mID(nullptr);
1094 return impl_callBooleanMethod( "nullsAreSortedHigh", mID );
1095 }
1096
nullsAreSortedLow()1097 sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedLow( )
1098 {
1099 static jmethodID mID(nullptr);
1100 return impl_callBooleanMethod( "nullsAreSortedLow", mID );
1101 }
1102
supportsSchemasInProcedureCalls()1103 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( )
1104 {
1105 static jmethodID mID(nullptr);
1106 return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID );
1107 }
1108
supportsSchemasInPrivilegeDefinitions()1109 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
1110 {
1111 static jmethodID mID(nullptr);
1112 return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID );
1113 }
1114
supportsCatalogsInProcedureCalls()1115 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( )
1116 {
1117 static jmethodID mID(nullptr);
1118 return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID );
1119 }
1120
supportsCatalogsInPrivilegeDefinitions()1121 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
1122 {
1123 static jmethodID mID(nullptr);
1124 return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID );
1125 }
1126
supportsCorrelatedSubqueries()1127 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( )
1128 {
1129 static jmethodID mID(nullptr);
1130 return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID );
1131 }
1132
supportsSubqueriesInComparisons()1133 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( )
1134 {
1135 static jmethodID mID(nullptr);
1136 return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID );
1137 }
1138
supportsSubqueriesInExists()1139 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInExists( )
1140 {
1141 static jmethodID mID(nullptr);
1142 return impl_callBooleanMethod( "supportsSubqueriesInExists", mID );
1143 }
1144
supportsSubqueriesInIns()1145 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInIns( )
1146 {
1147 static jmethodID mID(nullptr);
1148 return impl_callBooleanMethod( "supportsSubqueriesInIns", mID );
1149 }
1150
supportsSubqueriesInQuantifieds()1151 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( )
1152 {
1153 static jmethodID mID(nullptr);
1154 return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID );
1155 }
1156
supportsANSI92IntermediateSQL()1157 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( )
1158 {
1159 static jmethodID mID(nullptr);
1160 return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID );
1161 }
1162
getURL()1163 OUString SAL_CALL java_sql_DatabaseMetaData::getURL( )
1164 {
1165 OUString sURL = m_pConnection->getURL();
1166 if ( sURL.isEmpty() )
1167 {
1168 static jmethodID mID(nullptr);
1169 sURL = impl_callStringMethod( "getURL", mID );
1170 }
1171 return sURL;
1172 }
1173
getUserName()1174 OUString SAL_CALL java_sql_DatabaseMetaData::getUserName( )
1175 {
1176 static jmethodID mID(nullptr);
1177 return impl_callStringMethod( "getUserName", mID );
1178 }
1179
getDriverName()1180 OUString SAL_CALL java_sql_DatabaseMetaData::getDriverName( )
1181 {
1182 static jmethodID mID(nullptr);
1183 return impl_callStringMethod( "getDriverName", mID );
1184 }
1185
getDriverVersion()1186 OUString SAL_CALL java_sql_DatabaseMetaData::getDriverVersion( )
1187 {
1188 static jmethodID mID(nullptr);
1189 return impl_callStringMethod( "getDriverVersion", mID );
1190 }
1191
getDatabaseProductVersion()1192 OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductVersion( )
1193 {
1194 static jmethodID mID(nullptr);
1195 return impl_callStringMethod( "getDatabaseProductVersion", mID );
1196 }
1197
getDatabaseProductName()1198 OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductName( )
1199 {
1200 static jmethodID mID(nullptr);
1201 return impl_callStringMethod( "getDatabaseProductName", mID );
1202 }
1203
getProcedureTerm()1204 OUString SAL_CALL java_sql_DatabaseMetaData::getProcedureTerm( )
1205 {
1206 static jmethodID mID(nullptr);
1207 return impl_callStringMethod( "getProcedureTerm", mID );
1208 }
1209
getSchemaTerm()1210 OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( )
1211 {
1212 static jmethodID mID(nullptr);
1213 return impl_callStringMethod( "getSchemaTerm", mID );
1214 }
1215
getDriverMajorVersion()1216 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( )
1217 {
1218 static jmethodID mID(nullptr);
1219 return impl_callIntMethod_ThrowRuntime("getDriverMajorVersion", mID);
1220 }
1221
getDefaultTransactionIsolation()1222 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( )
1223 {
1224 static jmethodID mID(nullptr);
1225 return impl_callIntMethod_ThrowSQL("getDefaultTransactionIsolation", mID);
1226 }
1227
getDriverMinorVersion()1228 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( )
1229 {
1230 static jmethodID mID(nullptr);
1231 return impl_callIntMethod_ThrowRuntime("getDriverMinorVersion", mID);
1232 }
1233
getSQLKeywords()1234 OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( )
1235 {
1236 static jmethodID mID(nullptr);
1237 return impl_callStringMethod( "getSQLKeywords", mID );
1238 }
1239
getSearchStringEscape()1240 OUString SAL_CALL java_sql_DatabaseMetaData::getSearchStringEscape( )
1241 {
1242 static jmethodID mID(nullptr);
1243 return impl_callStringMethod( "getSearchStringEscape", mID );
1244 }
1245
getStringFunctions()1246 OUString SAL_CALL java_sql_DatabaseMetaData::getStringFunctions( )
1247 {
1248 static jmethodID mID(nullptr);
1249 return impl_callStringMethod( "getStringFunctions", mID );
1250 }
1251
getTimeDateFunctions()1252 OUString SAL_CALL java_sql_DatabaseMetaData::getTimeDateFunctions( )
1253 {
1254 static jmethodID mID(nullptr);
1255 return impl_callStringMethod( "getTimeDateFunctions", mID );
1256 }
1257
getSystemFunctions()1258 OUString SAL_CALL java_sql_DatabaseMetaData::getSystemFunctions( )
1259 {
1260 static jmethodID mID(nullptr);
1261 return impl_callStringMethod( "getSystemFunctions", mID );
1262 }
1263
getNumericFunctions()1264 OUString SAL_CALL java_sql_DatabaseMetaData::getNumericFunctions( )
1265 {
1266 static jmethodID mID(nullptr);
1267 return impl_callStringMethod( "getNumericFunctions", mID );
1268 }
1269
supportsExtendedSQLGrammar()1270 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( )
1271 {
1272 static jmethodID mID(nullptr);
1273 return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID );
1274 }
1275
supportsCoreSQLGrammar()1276 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCoreSQLGrammar( )
1277 {
1278 static jmethodID mID(nullptr);
1279 return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID );
1280 }
1281
supportsMinimumSQLGrammar()1282 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( )
1283 {
1284 static jmethodID mID(nullptr);
1285 return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID );
1286 }
1287
supportsFullOuterJoins()1288 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsFullOuterJoins( )
1289 {
1290 static jmethodID mID(nullptr);
1291 return impl_callBooleanMethod( "supportsFullOuterJoins", mID );
1292 }
1293
supportsLimitedOuterJoins()1294 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( )
1295 {
1296 static jmethodID mID(nullptr);
1297 return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID );
1298 }
1299
getMaxColumnsInGroupBy()1300 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( )
1301 {
1302 static jmethodID mID(nullptr);
1303 return impl_callIntMethod_ThrowSQL("getMaxColumnsInGroupBy", mID);
1304 }
1305
getMaxColumnsInOrderBy()1306 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( )
1307 {
1308 static jmethodID mID(nullptr);
1309 return impl_callIntMethod_ThrowSQL("getMaxColumnsInOrderBy", mID);
1310 }
1311
getMaxColumnsInSelect()1312 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( )
1313 {
1314 static jmethodID mID(nullptr);
1315 return impl_callIntMethod_ThrowSQL("getMaxColumnsInSelect", mID);
1316 }
1317
getMaxUserNameLength()1318 sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( )
1319 {
1320 static jmethodID mID(nullptr);
1321 return impl_callIntMethod_ThrowSQL("getMaxUserNameLength", mID);
1322 }
1323
supportsResultSetType(sal_Int32 setType)1324 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType )
1325 {
1326 static jmethodID mID(nullptr);
1327 return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID, setType );
1328 }
1329
supportsResultSetConcurrency(sal_Int32 setType,sal_Int32 concurrency)1330 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency )
1331 {
1332 static const char* const pMethodName = "supportsResultSetConcurrency";
1333 m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, setType, concurrency );
1334
1335 bool out( false );
1336 SDBThreadAttach t;
1337
1338 {
1339 static jmethodID mID(nullptr);
1340 obtainMethodId_throwSQL(t.pEnv, pMethodName,"(II)Z", mID);
1341 out = t.pEnv->CallBooleanMethod( object, mID, setType, concurrency);
1342 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
1343 }
1344
1345 m_aLogger.log< const sal_Char*, bool >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
1346 return out;
1347 }
1348
ownUpdatesAreVisible(sal_Int32 setType)1349 sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType )
1350 {
1351 static jmethodID mID(nullptr);
1352 return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID, setType );
1353 }
1354
ownDeletesAreVisible(sal_Int32 setType)1355 sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType )
1356 {
1357 static jmethodID mID(nullptr);
1358 return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID, setType );
1359 }
1360
ownInsertsAreVisible(sal_Int32 setType)1361 sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType )
1362 {
1363 static jmethodID mID(nullptr);
1364 return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID, setType );
1365 }
1366
othersUpdatesAreVisible(sal_Int32 setType)1367 sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType )
1368 {
1369 static jmethodID mID(nullptr);
1370 return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID, setType );
1371 }
1372
othersDeletesAreVisible(sal_Int32 setType)1373 sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType )
1374 {
1375 static jmethodID mID(nullptr);
1376 return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID, setType );
1377 }
1378
othersInsertsAreVisible(sal_Int32 setType)1379 sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType )
1380 {
1381 static jmethodID mID(nullptr);
1382 return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID, setType );
1383 }
1384
updatesAreDetected(sal_Int32 setType)1385 sal_Bool SAL_CALL java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType )
1386 {
1387 static jmethodID mID(nullptr);
1388 return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID, setType );
1389 }
1390
deletesAreDetected(sal_Int32 setType)1391 sal_Bool SAL_CALL java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType )
1392 {
1393 static jmethodID mID(nullptr);
1394 return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID, setType );
1395 }
1396
insertsAreDetected(sal_Int32 setType)1397 sal_Bool SAL_CALL java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType )
1398 {
1399 static jmethodID mID(nullptr);
1400 return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID, setType );
1401 }
1402
supportsBatchUpdates()1403 sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsBatchUpdates( )
1404 {
1405 static jmethodID mID(nullptr);
1406 return impl_callBooleanMethod( "supportsBatchUpdates", mID );
1407 }
1408
getUDTs(const Any & catalog,const OUString & schemaPattern,const OUString & typeNamePattern,const Sequence<sal_Int32> & types)1409 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getUDTs(
1410 const Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern,
1411 const Sequence< sal_Int32 >& types )
1412 {
1413 jobject out(nullptr);
1414 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
1415 {
1416
1417
1418 static const char * const cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/sql/ResultSet;";
1419 static const char * const cMethodName = "getUDTs";
1420 // dismiss Java-Call
1421 static jmethodID mID(nullptr);
1422 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
1423 {
1424 jvalue args[4];
1425 // initialize temporary Variable
1426 args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : nullptr;
1427 args[1].l = schemaPattern.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t.pEnv,schemaPattern);
1428 args[2].l = convertwchar_tToJavaString(t.pEnv,typeNamePattern);
1429 jintArray pArray = t.pEnv->NewIntArray(types.getLength());
1430 jint * typesData = reinterpret_cast<jint *>(
1431 const_cast<sal_Int32 *>(types.getConstArray()));
1432 // 4th param of Set*ArrayRegion changed from pointer to non-const to
1433 // pointer to const between <http://docs.oracle.com/javase/6/docs/
1434 // technotes/guides/jni/spec/functions.html#wp22933> and
1435 // <http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/
1436 // functions.html#wp22933>; work around that difference in a way
1437 // that doesn't trigger loplugin:redundantcast
1438 t.pEnv->SetIntArrayRegion(pArray,0,types.getLength(),typesData);
1439 args[3].l = pArray;
1440
1441 out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
1442
1443 if(catalog.hasValue())
1444 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
1445 if(!schemaPattern.isEmpty())
1446 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
1447 if(!typeNamePattern.isEmpty())
1448 t.pEnv->DeleteLocalRef(static_cast<jstring>(args[2].l));
1449 if(args[3].l)
1450 t.pEnv->DeleteLocalRef(static_cast<jintArray>(args[3].l));
1451 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
1452 }
1453 }
1454
1455 return out ? new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection ) : nullptr;
1456 }
1457
1458
1459 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1460