1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <string_view>
24 #include <sal/macros.h>
25 #include <java/sql/DatabaseMetaData.hxx>
26 #include <java/sql/Connection.hxx>
27 #include <java/sql/ResultSet.hxx>
28 #include <java/sql/SQLException.hxx>
29 #include <java/tools.hxx>
30 #include <java/lang/String.hxx>
31 #include <FDatabaseMetaDataResultSet.hxx>
32 #include <comphelper/types.hxx>
33 #include <TPrivilegesResultSet.hxx>
34 #include <strings.hxx>
36 using namespace ::comphelper
;
38 using namespace connectivity
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::sdbc
;
42 jclass
java_sql_DatabaseMetaData::theClass
= nullptr;
44 java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
46 SDBThreadAttach::releaseRef();
49 jclass
java_sql_DatabaseMetaData::getMyClass() const
51 // the class must be fetched only once, therefore static
53 theClass
= findMyClass("java/sql/DatabaseMetaData");
57 java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv
* pEnv
, jobject myObj
, java_sql_Connection
& _rConnection
)
58 :ODatabaseMetaDataBase( &_rConnection
,_rConnection
.getConnectionInfo() )
59 ,java_lang_Object( pEnv
, myObj
)
60 ,m_pConnection( &_rConnection
)
61 ,m_aLogger( _rConnection
.getLogger() )
63 SDBThreadAttach::addRef();
67 Reference
< XResultSet
> java_sql_DatabaseMetaData::impl_getTypeInfo_throw( )
69 static jmethodID
mID(nullptr);
70 return impl_callResultSetMethod( "getTypeInfo", mID
);
73 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getCatalogs( )
75 static jmethodID
mID(nullptr);
76 return impl_callResultSetMethod( "getCatalogs", mID
);
79 OUString
java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( )
81 static jmethodID
mID(nullptr);
82 return impl_callStringMethod( "getCatalogSeparator", mID
);
85 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getSchemas( )
87 static jmethodID
mID(nullptr);
88 return impl_callResultSetMethod( "getSchemas", mID
);
91 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getColumnPrivileges(
92 const Any
& catalog
, const OUString
& schema
, const OUString
& table
, const OUString
& columnNamePattern
)
94 static jmethodID
mID(nullptr);
95 return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID
, catalog
, schema
, table
, &columnNamePattern
);
98 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getColumns(
99 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
, const OUString
& columnNamePattern
)
101 static jmethodID
mID(nullptr);
102 return impl_callResultSetMethodWithStrings( "getColumns", mID
, catalog
, schemaPattern
, tableNamePattern
, &columnNamePattern
);
106 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTables(
107 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
, const Sequence
< OUString
>& _types
)
109 static const char * const cMethodName
= "getTables";
111 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
113 jobject
out(nullptr);
114 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
117 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
119 static jmethodID
mID(nullptr);
120 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
121 OSL_VERIFY( !isExceptionOccurred(t
.pEnv
) );
125 sal_Int32 typeFilterCount
= _types
.getLength();
126 if ( typeFilterCount
)
128 jobjectArray pObjArray
= t
.pEnv
->NewObjectArray( static_cast<jsize
>(typeFilterCount
), java_lang_String::st_getMyClass(), nullptr );
129 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
130 const OUString
* typeFilter
= _types
.getConstArray();
131 bool bIncludeAllTypes
= false;
132 for ( sal_Int32 i
=0; i
<typeFilterCount
; ++i
, ++typeFilter
)
134 if ( *typeFilter
== "%" )
136 bIncludeAllTypes
= true;
139 jstring aT
= convertwchar_tToJavaString( t
.pEnv
, *typeFilter
);
140 t
.pEnv
->SetObjectArrayElement( pObjArray
, static_cast<jsize
>(i
), aT
);
141 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
144 if ( bIncludeAllTypes
)
146 // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types"
147 // is represented by the table type being <null/>
148 t
.pEnv
->DeleteLocalRef( pObjArray
);
149 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
153 args
[3].l
= pObjArray
;
156 // if we are to display "all catalogs", then respect m_aCatalogRestriction
157 Any
aCatalogFilter( catalog
);
158 if ( !aCatalogFilter
.hasValue() )
159 aCatalogFilter
= m_pConnection
->getCatalogRestriction();
160 // similar for schema
162 if ( schemaPattern
== "%" )
163 aSchemaFilter
= m_pConnection
->getSchemaRestriction();
165 aSchemaFilter
<<= schemaPattern
;
167 args
[0].l
= aCatalogFilter
.hasValue() ? convertwchar_tToJavaString( t
.pEnv
, ::comphelper::getString( aCatalogFilter
) ) : nullptr;
168 args
[1].l
= aSchemaFilter
.hasValue() ? convertwchar_tToJavaString( t
.pEnv
, ::comphelper::getString( aSchemaFilter
) ) : nullptr;
169 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,tableNamePattern
);
170 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
, args
[1].l
,args
[2].l
,args
[3].l
);
171 jthrowable jThrow
= t
.pEnv
->ExceptionOccurred();
173 t
.pEnv
->ExceptionClear();// we have to clear the exception here because we want to handle it below
174 if ( aCatalogFilter
.hasValue() )
176 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
177 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
181 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
182 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
184 if(!tableNamePattern
.isEmpty())
186 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
187 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
189 //for(INT16 i=0;i<len;i++)
192 t
.pEnv
->DeleteLocalRef( static_cast<jobjectArray
>(args
[3].l
) );
193 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
198 if ( t
.pEnv
->IsInstanceOf( jThrow
,java_sql_SQLException_BASE::st_getMyClass() ) )
200 java_sql_SQLException_BASE
aException( t
.pEnv
, jThrow
);
201 SQLException
e( aException
.getMessage(),
203 aException
.getSQLState(),
204 aException
.getErrorCode(),
215 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, cMethodName
);
216 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
219 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getProcedureColumns(
220 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& procedureNamePattern
, const OUString
& columnNamePattern
)
222 static jmethodID
mID(nullptr);
223 return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID
, catalog
, schemaPattern
, procedureNamePattern
, &columnNamePattern
);
226 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getProcedures( const Any
&
227 catalog
, const OUString
& schemaPattern
, const OUString
& procedureNamePattern
)
229 static jmethodID
mID(nullptr);
230 return impl_callResultSetMethodWithStrings( "getProcedures", mID
, catalog
, schemaPattern
, procedureNamePattern
);
233 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getVersionColumns(
234 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
236 static jmethodID
mID(nullptr);
237 return impl_callResultSetMethodWithStrings( "getVersionColumns", mID
, catalog
, schema
, table
);
240 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( )
242 static jmethodID
mID(nullptr);
243 return impl_callIntMethod_ThrowSQL("getMaxBinaryLiteralLength", mID
);
246 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxRowSize( )
248 static jmethodID
mID(nullptr);
249 return impl_callIntMethod_ThrowSQL("getMaxRowSize", mID
);
252 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCatalogNameLength( )
254 static jmethodID
mID(nullptr);
255 return impl_callIntMethod_ThrowSQL("getMaxCatalogNameLength", mID
);
258 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCharLiteralLength( )
260 static jmethodID
mID(nullptr);
261 return impl_callIntMethod_ThrowSQL("getMaxCharLiteralLength", mID
);
264 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnNameLength( )
266 static jmethodID
mID(nullptr);
267 return impl_callIntMethod_ThrowSQL("getMaxColumnNameLength", mID
);
270 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInIndex( )
272 static jmethodID
mID(nullptr);
273 return impl_callIntMethod_ThrowSQL("getMaxColumnsInIndex", mID
);
276 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCursorNameLength( )
278 static jmethodID
mID(nullptr);
279 return impl_callIntMethod_ThrowSQL("getMaxCursorNameLength", mID
);
282 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxConnections( )
284 static jmethodID
mID(nullptr);
285 return impl_callIntMethod_ThrowSQL("getMaxConnections", mID
);
288 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInTable( )
290 static jmethodID
mID(nullptr);
291 return impl_callIntMethod_ThrowSQL("getMaxColumnsInTable", mID
);
294 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxStatementLength( )
296 static jmethodID
mID(nullptr);
297 return impl_callIntMethod_ThrowSQL("getMaxStatementLength", mID
);
300 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxTableNameLength( )
302 static jmethodID
mID(nullptr);
303 return impl_callIntMethod_ThrowSQL("getMaxTableNameLength", mID
);
306 sal_Int32
java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( )
308 static jmethodID
mID(nullptr);
309 return impl_callIntMethod_ThrowSQL("getMaxTablesInSelect", mID
);
312 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getExportedKeys(
313 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
315 static jmethodID
mID(nullptr);
316 return impl_callResultSetMethodWithStrings( "getExportedKeys", mID
, catalog
, schema
, table
);
319 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getImportedKeys(
320 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
322 static jmethodID
mID(nullptr);
323 return impl_callResultSetMethodWithStrings( "getImportedKeys", mID
, catalog
, schema
, table
);
326 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getPrimaryKeys(
327 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
329 static jmethodID
mID(nullptr);
330 return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID
, catalog
, schema
, table
);
333 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getIndexInfo(
334 const Any
& catalog
, const OUString
& schema
, const OUString
& table
,
335 sal_Bool unique
, sal_Bool approximate
)
337 static const char * const cMethodName
= "getIndexInfo";
339 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
341 jobject
out(nullptr);
342 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
345 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
347 static jmethodID
mID(nullptr);
348 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
351 args
[0].l
= catalog
.hasValue() ? convertwchar_tToJavaString(t
.pEnv
,comphelper::getString(catalog
)) : nullptr;
352 args
[1].l
= schema
.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t
.pEnv
,schema
);
353 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,table
);
355 args
[4].z
= approximate
;
356 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
,args
[1].l
,args
[2].l
,args
[3].z
,args
[4].z
);
359 if(catalog
.hasValue())
360 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
362 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
364 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
365 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
370 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, cMethodName
);
371 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
374 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getBestRowIdentifier(
375 const Any
& catalog
, const OUString
& schema
, const OUString
& table
, sal_Int32 scope
,
378 static const char * const cMethodName
= "getBestRowIdentifier";
380 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
382 jobject
out(nullptr);
383 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
386 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
388 static jmethodID
mID(nullptr);
389 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
392 args
[0].l
= catalog
.hasValue() ? convertwchar_tToJavaString(t
.pEnv
,comphelper::getString(catalog
)) : nullptr;
393 args
[1].l
= schema
.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t
.pEnv
,schema
);
394 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,table
);
395 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
,args
[1].l
,args
[2].l
,scope
,nullable
);
398 if(catalog
.hasValue())
399 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
401 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
403 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
404 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
410 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, cMethodName
);
411 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
414 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTablePrivileges(
415 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
)
417 if ( m_pConnection
->isIgnoreDriverPrivilegesEnabled() )
418 return new OResultSetPrivileges(this,catalog
,schemaPattern
,tableNamePattern
);
420 static jmethodID
mID(nullptr);
421 Reference
< XResultSet
> xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID
, catalog
, schemaPattern
, tableNamePattern
) );
425 // we have to check the result columns for the tables privileges
426 Reference
< XResultSetMetaDataSupplier
> xMetaSup(xReturn
,UNO_QUERY
);
429 Reference
< XResultSetMetaData
> xMeta
= xMetaSup
->getMetaData();
430 if ( xMeta
.is() && xMeta
->getColumnCount() != 7 )
432 // here we know that the count of column doesn't match
433 std::map
<sal_Int32
,sal_Int32
> aColumnMatching
;
434 static const std::u16string_view sPrivs
[] = {
444 OUString sColumnName
;
445 sal_Int32 nCount
= xMeta
->getColumnCount();
446 for (sal_Int32 i
= 1 ; i
<= nCount
; ++i
)
448 sColumnName
= xMeta
->getColumnName(i
);
449 for (size_t j
= 0 ; j
< std::size(sPrivs
); ++j
)
451 if ( sPrivs
[j
] == sColumnName
)
453 aColumnMatching
.emplace(i
,j
+1);
459 // fill our own resultset
460 rtl::Reference
<ODatabaseMetaDataResultSet
> pNewPrivRes
= new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges
);
461 Reference
< XResultSet
> xTemp
= xReturn
;
462 xReturn
= pNewPrivRes
;
463 ODatabaseMetaDataResultSet::ORows aRows
;
464 Reference
< XRow
> xRow(xTemp
,UNO_QUERY
);
467 ODatabaseMetaDataResultSet::ORow
aRow(8);
468 while ( xRow
.is() && xTemp
->next() )
470 for (const auto& [nCol
, nPriv
] : aColumnMatching
)
472 sValue
= xRow
->getString(nCol
);
473 if ( xRow
->wasNull() )
474 aRow
[nPriv
] = ODatabaseMetaDataResultSet::getEmptyValue();
476 aRow
[nPriv
] = new ORowSetValueDecorator(sValue
);
479 aRows
.push_back(aRow
);
481 pNewPrivRes
->setRows(std::move(aRows
));
488 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getCrossReference(
489 const Any
& primaryCatalog
, const OUString
& primarySchema
,
490 const OUString
& primaryTable
, const Any
& foreignCatalog
,
491 const OUString
& foreignSchema
, const OUString
& foreignTable
)
493 static const char * const cMethodName
= "getCrossReference";
494 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
496 jobject
out(nullptr);
497 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
499 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;";
501 static jmethodID
mID(nullptr);
502 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
505 args
[0].l
= primaryCatalog
.hasValue() ? convertwchar_tToJavaString(t
.pEnv
,comphelper::getString(primaryCatalog
)) : nullptr;
506 args
[1].l
= primarySchema
.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t
.pEnv
,primarySchema
);
507 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,primaryTable
);
508 args
[3].l
= foreignCatalog
.hasValue() ? convertwchar_tToJavaString(t
.pEnv
,comphelper::getString(foreignCatalog
)) : nullptr;
509 args
[4].l
= foreignSchema
.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t
.pEnv
,foreignSchema
);
510 args
[5].l
= convertwchar_tToJavaString(t
.pEnv
,foreignTable
);
511 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
,args
[2].l
,args
[2].l
,args
[3].l
,args
[4].l
,args
[5].l
);
514 if(primaryCatalog
.hasValue())
515 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
517 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
518 if(!primaryTable
.isEmpty())
519 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
520 if(foreignCatalog
.hasValue())
521 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[3].l
));
523 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[4].l
));
524 if(!foreignTable
.isEmpty())
525 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[5].l
));
526 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
532 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, cMethodName
);
533 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
537 bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
539 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
540 bool out( java_lang_Object::callBooleanMethod(_pMethodName
,_inout_MethodID
) );
541 m_aLogger
.log
< const char*, bool>( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, out
);
546 OUString
java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
548 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
550 const OUString
sReturn( callStringMethod(_pMethodName
,_inout_MethodID
) );
551 if ( m_aLogger
.isLoggable( LogLevel::FINEST
) )
553 OUString
sLoggedResult( sReturn
);
554 if ( sLoggedResult
.isEmpty() )
555 sLoggedResult
= "<empty string>";
556 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, sLoggedResult
);
562 sal_Int32
java_sql_DatabaseMetaData::impl_callIntMethod_ThrowSQL(const char* _pMethodName
, jmethodID
& _inout_MethodID
)
564 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
565 sal_Int32
out( callIntMethod_ThrowSQL(_pMethodName
,_inout_MethodID
) );
566 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, out
);
570 sal_Int32
java_sql_DatabaseMetaData::impl_callIntMethod_ThrowRuntime(const char* _pMethodName
, jmethodID
& _inout_MethodID
)
572 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
573 sal_Int32
out( callIntMethod_ThrowRuntime(_pMethodName
,_inout_MethodID
) );
574 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, out
);
578 bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName
, jmethodID
& _inout_MethodID
, sal_Int32 _nArgument
)
580 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG1
, _pMethodName
, _nArgument
);
582 bool out( callBooleanMethodWithIntArg(_pMethodName
,_inout_MethodID
,_nArgument
) );
584 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, out
);
589 Reference
< XResultSet
> java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
592 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
593 jobject
out(callResultSetMethod(t
.env(),_pMethodName
,_inout_MethodID
));
594 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, _pMethodName
);
595 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
599 Reference
< XResultSet
> java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings( const char* _pMethodName
, jmethodID
& _inout_MethodID
,
600 const Any
& _rCatalog
, const OUString
& _rSchemaPattern
, const OUString
& _rLeastPattern
,
601 const OUString
* _pOptionalAdditionalString
)
603 bool bCatalog
= _rCatalog
.hasValue();
605 _rCatalog
>>= sCatalog
;
607 bool bSchema
= _rSchemaPattern
.toChar() != '%';
610 if ( m_aLogger
.isLoggable( LogLevel::FINEST
) )
612 OUString sCatalogLog
= bCatalog
? sCatalog
: u
"null"_ustr
;
613 OUString sSchemaLog
= bSchema
? _rSchemaPattern
: u
"null"_ustr
;
614 if ( _pOptionalAdditionalString
)
615 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG4
, _pMethodName
, sCatalogLog
, sSchemaLog
, _rLeastPattern
, *_pOptionalAdditionalString
);
617 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG3
, _pMethodName
, sCatalogLog
, sSchemaLog
, _rLeastPattern
);
620 jobject
out(nullptr);
623 OSL_ENSURE( t
.pEnv
, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java environment anymore!" );
626 const char* pSignature
= _pOptionalAdditionalString
627 ? "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"
628 : "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
630 obtainMethodId_throwSQL(t
.pEnv
, _pMethodName
,pSignature
, _inout_MethodID
);
636 // convert parameters
637 args
[0].l
= bCatalog
? convertwchar_tToJavaString( t
.pEnv
, sCatalog
) : nullptr;
638 args
[1].l
= bSchema
? convertwchar_tToJavaString( t
.pEnv
, _rSchemaPattern
) : nullptr;
639 args
[2].l
= convertwchar_tToJavaString( t
.pEnv
, _rLeastPattern
);
640 args
[3].l
= _pOptionalAdditionalString
? convertwchar_tToJavaString( t
.pEnv
, *_pOptionalAdditionalString
) : nullptr;
642 // actually do the call
643 if ( _pOptionalAdditionalString
)
644 out
= t
.pEnv
->CallObjectMethod( object
, _inout_MethodID
, args
[0].l
, args
[1].l
, args
[2].l
, args
[3].l
);
646 out
= t
.pEnv
->CallObjectMethod( object
, _inout_MethodID
, args
[0].l
, args
[1].l
, args
[2].l
);
650 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[0].l
) );
652 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[1].l
) );
654 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[2].l
) );
656 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[3].l
) );
658 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
665 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_SUCCESS
, _pMethodName
);
666 return new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
);
670 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
672 static jmethodID
mID(nullptr);
673 return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID
);
676 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
678 static jmethodID
mID(nullptr);
679 return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID
);
682 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( )
684 static jmethodID
mID(nullptr);
685 return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID
);
688 bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
690 static jmethodID
mID(nullptr);
691 return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID
);
694 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( )
696 static jmethodID
mID(nullptr);
697 return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID
);
700 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
702 static jmethodID
mID(nullptr);
703 return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID
);
706 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( )
708 static jmethodID
mID(nullptr);
709 return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID
);
712 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
714 static jmethodID
mID(nullptr);
715 return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID
);
718 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
720 static jmethodID
mID(nullptr);
721 return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID
);
724 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxIndexLength( )
726 static jmethodID
mID(nullptr);
727 return impl_callIntMethod_ThrowSQL("getMaxIndexLength", mID
);
730 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsNonNullableColumns( )
732 static jmethodID
mID(nullptr);
733 return impl_callBooleanMethod( "supportsNonNullableColumns", mID
);
736 OUString SAL_CALL
java_sql_DatabaseMetaData::getCatalogTerm( )
738 static jmethodID
mID(nullptr);
739 return impl_callStringMethod( "getCatalogTerm", mID
);
742 OUString
java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( )
744 static jmethodID
mID(nullptr);
745 return impl_callStringMethod( "getIdentifierQuoteString", mID
);
748 OUString SAL_CALL
java_sql_DatabaseMetaData::getExtraNameCharacters( )
750 static jmethodID
mID(nullptr);
751 return impl_callStringMethod( "getExtraNameCharacters", mID
);
754 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( )
756 static jmethodID
mID(nullptr);
757 return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID
);
760 bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( )
762 static jmethodID
mID(nullptr);
763 return impl_callBooleanMethod( "isCatalogAtStart", mID
);
766 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( )
768 static jmethodID
mID(nullptr);
769 return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID
);
772 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( )
774 static jmethodID
mID(nullptr);
775 return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID
);
778 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( )
780 static jmethodID
mID(nullptr);
781 return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID
);
784 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
786 static jmethodID
mID(nullptr);
787 return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID
);
790 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsPositionedDelete( )
792 static jmethodID
mID(nullptr);
793 return impl_callBooleanMethod( "supportsPositionedDelete", mID
);
796 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsPositionedUpdate( )
798 static jmethodID
mID(nullptr);
799 return impl_callBooleanMethod( "supportsPositionedUpdate", mID
);
802 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( )
804 static jmethodID
mID(nullptr);
805 return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID
);
808 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( )
810 static jmethodID
mID(nullptr);
811 return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID
);
814 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( )
816 static jmethodID
mID(nullptr);
817 return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID
);
820 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( )
822 static jmethodID
mID(nullptr);
823 return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID
);
826 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level
)
828 static jmethodID
mID(nullptr);
829 return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID
, level
);
832 bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
834 static jmethodID
mID(nullptr);
835 return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID
);
838 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92FullSQL( )
840 static jmethodID
mID(nullptr);
841 return impl_callBooleanMethod( "supportsANSI92FullSQL", mID
);
844 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( )
846 static jmethodID
mID(nullptr);
847 return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID
);
850 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( )
852 static jmethodID
mID(nullptr);
853 return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID
);
856 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( )
858 static jmethodID
mID(nullptr);
859 return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID
);
862 bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
864 static jmethodID
mID(nullptr);
865 return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID
);
868 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
870 static jmethodID
mID(nullptr);
871 return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID
);
874 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( )
876 static jmethodID
mID(nullptr);
877 return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID
);
880 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
882 static jmethodID
mID(nullptr);
883 return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID
);
886 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOuterJoins( )
888 static jmethodID
mID(nullptr);
889 return impl_callBooleanMethod( "supportsOuterJoins", mID
);
892 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTableTypes( )
894 static jmethodID
mID(nullptr);
895 return impl_callResultSetMethod( "getTableTypes", mID
);
898 sal_Int32
java_sql_DatabaseMetaData::impl_getMaxStatements_throw( )
900 static jmethodID
mID(nullptr);
901 return impl_callIntMethod_ThrowSQL("getMaxStatements", mID
);
904 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxProcedureNameLength( )
906 static jmethodID
mID(nullptr);
907 return impl_callIntMethod_ThrowSQL("getMaxProcedureNameLength", mID
);
910 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxSchemaNameLength( )
912 static jmethodID
mID(nullptr);
913 return impl_callIntMethod_ThrowSQL("getMaxSchemaNameLength", mID
);
916 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTransactions( )
918 static jmethodID
mID(nullptr);
919 return impl_callBooleanMethod( "supportsTransactions", mID
);
923 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::allProceduresAreCallable( )
925 static jmethodID
mID(nullptr);
926 return impl_callBooleanMethod( "allProceduresAreCallable", mID
);
929 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsStoredProcedures( )
931 static jmethodID
mID(nullptr);
932 return impl_callBooleanMethod( "supportsStoredProcedures", mID
);
935 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSelectForUpdate( )
937 static jmethodID
mID(nullptr);
938 return impl_callBooleanMethod( "supportsSelectForUpdate", mID
);
941 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::allTablesAreSelectable( )
943 static jmethodID
mID(nullptr);
944 return impl_callBooleanMethod( "allTablesAreSelectable", mID
);
947 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::isReadOnly( )
949 static jmethodID
mID(nullptr);
950 return impl_callBooleanMethod( "isReadOnly", mID
);
953 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::usesLocalFiles( )
955 static jmethodID
mID(nullptr);
956 return impl_callBooleanMethod( "usesLocalFiles", mID
);
959 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::usesLocalFilePerTable( )
961 static jmethodID
mID(nullptr);
962 return impl_callBooleanMethod( "usesLocalFilePerTable", mID
);
965 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTypeConversion( )
967 static jmethodID
mID(nullptr);
968 return impl_callBooleanMethod( "supportsTypeConversion", mID
);
971 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullPlusNonNullIsNull( )
973 static jmethodID
mID(nullptr);
974 return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID
);
977 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsColumnAliasing( )
979 static jmethodID
mID(nullptr);
980 return impl_callBooleanMethod( "supportsColumnAliasing", mID
);
983 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTableCorrelationNames( )
985 static jmethodID
mID(nullptr);
986 return impl_callBooleanMethod( "supportsTableCorrelationNames", mID
);
989 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType
, sal_Int32 toType
)
991 static const char* const pMethodName
= "supportsConvert";
992 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG2
, pMethodName
, fromType
, toType
);
998 static jmethodID
mID(nullptr);
999 obtainMethodId_throwSQL(t
.pEnv
, pMethodName
,"(II)Z", mID
);
1000 out
= t
.pEnv
->CallBooleanMethod( object
, mID
, fromType
, toType
);
1001 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
1004 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, pMethodName
, out
);
1008 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( )
1010 static jmethodID
mID(nullptr);
1011 return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID
);
1014 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupBy( )
1016 static jmethodID
mID(nullptr);
1017 return impl_callBooleanMethod( "supportsGroupBy", mID
);
1020 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( )
1022 static jmethodID
mID(nullptr);
1023 return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID
);
1026 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupByUnrelated( )
1028 static jmethodID
mID(nullptr);
1029 return impl_callBooleanMethod( "supportsGroupByUnrelated", mID
);
1032 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMultipleTransactions( )
1034 static jmethodID
mID(nullptr);
1035 return impl_callBooleanMethod( "supportsMultipleTransactions", mID
);
1038 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMultipleResultSets( )
1040 static jmethodID
mID(nullptr);
1041 return impl_callBooleanMethod( "supportsMultipleResultSets", mID
);
1044 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsLikeEscapeClause( )
1046 static jmethodID
mID(nullptr);
1047 return impl_callBooleanMethod( "supportsLikeEscapeClause", mID
);
1050 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOrderByUnrelated( )
1052 static jmethodID
mID(nullptr);
1053 return impl_callBooleanMethod( "supportsOrderByUnrelated", mID
);
1056 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsUnion( )
1058 static jmethodID
mID(nullptr);
1059 return impl_callBooleanMethod( "supportsUnion", mID
);
1062 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsUnionAll( )
1064 static jmethodID
mID(nullptr);
1065 return impl_callBooleanMethod( "supportsUnionAll", mID
);
1068 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( )
1070 static jmethodID
mID(nullptr);
1071 return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID
);
1074 bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1076 static jmethodID
mID(nullptr);
1077 return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID
);
1080 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedAtEnd( )
1082 static jmethodID
mID(nullptr);
1083 return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID
);
1086 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedAtStart( )
1088 static jmethodID
mID(nullptr);
1089 return impl_callBooleanMethod( "nullsAreSortedAtStart", mID
);
1092 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedHigh( )
1094 static jmethodID
mID(nullptr);
1095 return impl_callBooleanMethod( "nullsAreSortedHigh", mID
);
1098 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedLow( )
1100 static jmethodID
mID(nullptr);
1101 return impl_callBooleanMethod( "nullsAreSortedLow", mID
);
1104 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( )
1106 static jmethodID
mID(nullptr);
1107 return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID
);
1110 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
1112 static jmethodID
mID(nullptr);
1113 return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID
);
1116 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( )
1118 static jmethodID
mID(nullptr);
1119 return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID
);
1122 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
1124 static jmethodID
mID(nullptr);
1125 return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID
);
1128 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( )
1130 static jmethodID
mID(nullptr);
1131 return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID
);
1134 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( )
1136 static jmethodID
mID(nullptr);
1137 return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID
);
1140 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInExists( )
1142 static jmethodID
mID(nullptr);
1143 return impl_callBooleanMethod( "supportsSubqueriesInExists", mID
);
1146 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInIns( )
1148 static jmethodID
mID(nullptr);
1149 return impl_callBooleanMethod( "supportsSubqueriesInIns", mID
);
1152 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( )
1154 static jmethodID
mID(nullptr);
1155 return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID
);
1158 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( )
1160 static jmethodID
mID(nullptr);
1161 return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID
);
1164 OUString SAL_CALL
java_sql_DatabaseMetaData::getURL( )
1166 OUString sURL
= m_pConnection
->getURL();
1167 if ( sURL
.isEmpty() )
1169 static jmethodID
mID(nullptr);
1170 sURL
= impl_callStringMethod( "getURL", mID
);
1175 OUString SAL_CALL
java_sql_DatabaseMetaData::getUserName( )
1177 static jmethodID
mID(nullptr);
1178 return impl_callStringMethod( "getUserName", mID
);
1181 OUString SAL_CALL
java_sql_DatabaseMetaData::getDriverName( )
1183 static jmethodID
mID(nullptr);
1184 return impl_callStringMethod( "getDriverName", mID
);
1187 OUString SAL_CALL
java_sql_DatabaseMetaData::getDriverVersion( )
1189 static jmethodID
mID(nullptr);
1190 return impl_callStringMethod( "getDriverVersion", mID
);
1193 OUString SAL_CALL
java_sql_DatabaseMetaData::getDatabaseProductVersion( )
1195 static jmethodID
mID(nullptr);
1196 return impl_callStringMethod( "getDatabaseProductVersion", mID
);
1199 OUString SAL_CALL
java_sql_DatabaseMetaData::getDatabaseProductName( )
1201 static jmethodID
mID(nullptr);
1202 return impl_callStringMethod( "getDatabaseProductName", mID
);
1205 OUString SAL_CALL
java_sql_DatabaseMetaData::getProcedureTerm( )
1207 static jmethodID
mID(nullptr);
1208 return impl_callStringMethod( "getProcedureTerm", mID
);
1211 OUString SAL_CALL
java_sql_DatabaseMetaData::getSchemaTerm( )
1213 static jmethodID
mID(nullptr);
1214 return impl_callStringMethod( "getSchemaTerm", mID
);
1217 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDriverMajorVersion( )
1219 static jmethodID
mID(nullptr);
1220 return impl_callIntMethod_ThrowRuntime("getDriverMajorVersion", mID
);
1223 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDefaultTransactionIsolation( )
1225 static jmethodID
mID(nullptr);
1226 return impl_callIntMethod_ThrowSQL("getDefaultTransactionIsolation", mID
);
1229 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDriverMinorVersion( )
1231 static jmethodID
mID(nullptr);
1232 return impl_callIntMethod_ThrowRuntime("getDriverMinorVersion", mID
);
1235 OUString SAL_CALL
java_sql_DatabaseMetaData::getSQLKeywords( )
1237 static jmethodID
mID(nullptr);
1238 return impl_callStringMethod( "getSQLKeywords", mID
);
1241 OUString SAL_CALL
java_sql_DatabaseMetaData::getSearchStringEscape( )
1243 static jmethodID
mID(nullptr);
1244 return impl_callStringMethod( "getSearchStringEscape", mID
);
1247 OUString SAL_CALL
java_sql_DatabaseMetaData::getStringFunctions( )
1249 static jmethodID
mID(nullptr);
1250 return impl_callStringMethod( "getStringFunctions", mID
);
1253 OUString SAL_CALL
java_sql_DatabaseMetaData::getTimeDateFunctions( )
1255 static jmethodID
mID(nullptr);
1256 return impl_callStringMethod( "getTimeDateFunctions", mID
);
1259 OUString SAL_CALL
java_sql_DatabaseMetaData::getSystemFunctions( )
1261 static jmethodID
mID(nullptr);
1262 return impl_callStringMethod( "getSystemFunctions", mID
);
1265 OUString SAL_CALL
java_sql_DatabaseMetaData::getNumericFunctions( )
1267 static jmethodID
mID(nullptr);
1268 return impl_callStringMethod( "getNumericFunctions", mID
);
1271 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( )
1273 static jmethodID
mID(nullptr);
1274 return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID
);
1277 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCoreSQLGrammar( )
1279 static jmethodID
mID(nullptr);
1280 return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID
);
1283 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( )
1285 static jmethodID
mID(nullptr);
1286 return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID
);
1289 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsFullOuterJoins( )
1291 static jmethodID
mID(nullptr);
1292 return impl_callBooleanMethod( "supportsFullOuterJoins", mID
);
1295 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsLimitedOuterJoins( )
1297 static jmethodID
mID(nullptr);
1298 return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID
);
1301 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( )
1303 static jmethodID
mID(nullptr);
1304 return impl_callIntMethod_ThrowSQL("getMaxColumnsInGroupBy", mID
);
1307 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( )
1309 static jmethodID
mID(nullptr);
1310 return impl_callIntMethod_ThrowSQL("getMaxColumnsInOrderBy", mID
);
1313 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInSelect( )
1315 static jmethodID
mID(nullptr);
1316 return impl_callIntMethod_ThrowSQL("getMaxColumnsInSelect", mID
);
1319 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxUserNameLength( )
1321 static jmethodID
mID(nullptr);
1322 return impl_callIntMethod_ThrowSQL("getMaxUserNameLength", mID
);
1325 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType
)
1327 static jmethodID
mID(nullptr);
1328 return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID
, setType
);
1331 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32 concurrency
)
1333 static const char* const pMethodName
= "supportsResultSetConcurrency";
1334 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG2
, pMethodName
, setType
, concurrency
);
1340 static jmethodID
mID(nullptr);
1341 obtainMethodId_throwSQL(t
.pEnv
, pMethodName
,"(II)Z", mID
);
1342 out
= t
.pEnv
->CallBooleanMethod( object
, mID
, setType
, concurrency
);
1343 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
1346 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, pMethodName
, out
);
1350 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType
)
1352 static jmethodID
mID(nullptr);
1353 return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID
, setType
);
1356 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType
)
1358 static jmethodID
mID(nullptr);
1359 return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID
, setType
);
1362 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType
)
1364 static jmethodID
mID(nullptr);
1365 return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID
, setType
);
1368 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType
)
1370 static jmethodID
mID(nullptr);
1371 return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID
, setType
);
1374 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType
)
1376 static jmethodID
mID(nullptr);
1377 return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID
, setType
);
1380 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType
)
1382 static jmethodID
mID(nullptr);
1383 return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID
, setType
);
1386 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType
)
1388 static jmethodID
mID(nullptr);
1389 return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID
, setType
);
1392 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType
)
1394 static jmethodID
mID(nullptr);
1395 return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID
, setType
);
1398 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType
)
1400 static jmethodID
mID(nullptr);
1401 return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID
, setType
);
1404 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsBatchUpdates( )
1406 static jmethodID
mID(nullptr);
1407 return impl_callBooleanMethod( "supportsBatchUpdates", mID
);
1410 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getUDTs(
1411 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& typeNamePattern
,
1412 const Sequence
< sal_Int32
>& types
)
1414 jobject
out(nullptr);
1415 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
1419 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/sql/ResultSet;";
1420 static const char * const cMethodName
= "getUDTs";
1421 // dismiss Java-Call
1422 static jmethodID
mID(nullptr);
1423 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
1426 // initialize temporary Variable
1427 args
[0].l
= catalog
.hasValue() ? convertwchar_tToJavaString(t
.pEnv
,comphelper::getString(catalog
)) : nullptr;
1428 args
[1].l
= schemaPattern
.toChar() == '%' ? nullptr : convertwchar_tToJavaString(t
.pEnv
,schemaPattern
);
1429 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,typeNamePattern
);
1430 jintArray pArray
= t
.pEnv
->NewIntArray(types
.getLength());
1431 jint
* typesData
= reinterpret_cast<jint
*>(
1432 const_cast<sal_Int32
*>(types
.getConstArray()));
1433 // 4th param of Set*ArrayRegion changed from pointer to non-const to
1434 // pointer to const between <http://docs.oracle.com/javase/6/docs/
1435 // technotes/guides/jni/spec/functions.html#wp22933> and
1436 // <http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/
1437 // functions.html#wp22933>; work around that difference in a way
1438 // that doesn't trigger loplugin:redundantcast
1439 t
.pEnv
->SetIntArrayRegion(pArray
,0,types
.getLength(),typesData
);
1442 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
, args
[1].l
,args
[2].l
,args
[3].l
);
1444 if(catalog
.hasValue())
1445 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
1446 if(!schemaPattern
.isEmpty())
1447 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
1448 if(!typeNamePattern
.isEmpty())
1449 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
1451 t
.pEnv
->DeleteLocalRef(static_cast<jintArray
>(args
[3].l
));
1452 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
1456 return out
? new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
) : nullptr;
1460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */