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