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::beans
;
41 using namespace ::com::sun::star::sdbc
;
42 using namespace ::com::sun::star::container
;
43 using namespace ::com::sun::star::lang
;
45 jclass
java_sql_DatabaseMetaData::theClass
= nullptr;
47 java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
49 SDBThreadAttach::releaseRef();
52 jclass
java_sql_DatabaseMetaData::getMyClass() const
54 // the class must be fetched only once, therefore static
56 theClass
= findMyClass("java/sql/DatabaseMetaData");
60 java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv
* pEnv
, jobject myObj
, java_sql_Connection
& _rConnection
)
61 :ODatabaseMetaDataBase( &_rConnection
,_rConnection
.getConnectionInfo() )
62 ,java_lang_Object( pEnv
, myObj
)
63 ,m_pConnection( &_rConnection
)
64 ,m_aLogger( _rConnection
.getLogger() )
66 SDBThreadAttach::addRef();
70 Reference
< XResultSet
> java_sql_DatabaseMetaData::impl_getTypeInfo_throw( )
72 static jmethodID
mID(nullptr);
73 return impl_callResultSetMethod( "getTypeInfo", mID
);
76 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getCatalogs( )
78 static jmethodID
mID(nullptr);
79 return impl_callResultSetMethod( "getCatalogs", mID
);
82 OUString
java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( )
84 static jmethodID
mID(nullptr);
85 return impl_callStringMethod( "getCatalogSeparator", mID
);
88 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getSchemas( )
90 static jmethodID
mID(nullptr);
91 return impl_callResultSetMethod( "getSchemas", mID
);
94 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getColumnPrivileges(
95 const Any
& catalog
, const OUString
& schema
, const OUString
& table
, const OUString
& columnNamePattern
)
97 static jmethodID
mID(nullptr);
98 return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID
, catalog
, schema
, table
, &columnNamePattern
);
101 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getColumns(
102 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
, const OUString
& columnNamePattern
)
104 static jmethodID
mID(nullptr);
105 return impl_callResultSetMethodWithStrings( "getColumns", mID
, catalog
, schemaPattern
, tableNamePattern
, &columnNamePattern
);
109 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTables(
110 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
, const Sequence
< OUString
>& _types
)
112 static const char * const cMethodName
= "getTables";
114 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
116 jobject
out(nullptr);
117 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
120 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
122 static jmethodID
mID(nullptr);
123 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
124 OSL_VERIFY( !isExceptionOccurred(t
.pEnv
) );
128 sal_Int32 typeFilterCount
= _types
.getLength();
129 if ( typeFilterCount
)
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
)
137 if ( *typeFilter
== "%" )
139 bIncludeAllTypes
= true;
142 jstring aT
= convertwchar_tToJavaString( t
.pEnv
, *typeFilter
);
143 t
.pEnv
->SetObjectArrayElement( pObjArray
, static_cast<jsize
>(i
), aT
);
144 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
147 if ( bIncludeAllTypes
)
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
) );
156 args
[3].l
= pObjArray
;
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
165 if ( schemaPattern
== "%" )
166 aSchemaFilter
= m_pConnection
->getSchemaRestriction();
168 aSchemaFilter
<<= schemaPattern
;
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();
176 t
.pEnv
->ExceptionClear();// we have to clear the exception here because we want to handle it below
177 if ( aCatalogFilter
.hasValue() )
179 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
180 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
184 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
185 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
187 if(!tableNamePattern
.isEmpty())
189 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
190 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
192 //for(INT16 i=0;i<len;i++)
195 t
.pEnv
->DeleteLocalRef( static_cast<jobjectArray
>(args
[3].l
) );
196 OSL_VERIFY( !isExceptionOccurred( t
.pEnv
) );
201 if ( t
.pEnv
->IsInstanceOf( jThrow
,java_sql_SQLException_BASE::st_getMyClass() ) )
203 java_sql_SQLException_BASE
aException( t
.pEnv
, jThrow
);
204 SQLException
e( aException
.getMessage(),
206 aException
.getSQLState(),
207 aException
.getErrorCode(),
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
);
222 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getProcedureColumns(
223 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& procedureNamePattern
, const OUString
& columnNamePattern
)
225 static jmethodID
mID(nullptr);
226 return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID
, catalog
, schemaPattern
, procedureNamePattern
, &columnNamePattern
);
229 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getProcedures( const Any
&
230 catalog
, const OUString
& schemaPattern
, const OUString
& procedureNamePattern
)
232 static jmethodID
mID(nullptr);
233 return impl_callResultSetMethodWithStrings( "getProcedures", mID
, catalog
, schemaPattern
, procedureNamePattern
);
236 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getVersionColumns(
237 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
239 static jmethodID
mID(nullptr);
240 return impl_callResultSetMethodWithStrings( "getVersionColumns", mID
, catalog
, schema
, table
);
243 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( )
245 static jmethodID
mID(nullptr);
246 return impl_callIntMethod_ThrowSQL("getMaxBinaryLiteralLength", mID
);
249 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxRowSize( )
251 static jmethodID
mID(nullptr);
252 return impl_callIntMethod_ThrowSQL("getMaxRowSize", mID
);
255 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCatalogNameLength( )
257 static jmethodID
mID(nullptr);
258 return impl_callIntMethod_ThrowSQL("getMaxCatalogNameLength", mID
);
261 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCharLiteralLength( )
263 static jmethodID
mID(nullptr);
264 return impl_callIntMethod_ThrowSQL("getMaxCharLiteralLength", mID
);
267 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnNameLength( )
269 static jmethodID
mID(nullptr);
270 return impl_callIntMethod_ThrowSQL("getMaxColumnNameLength", mID
);
273 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInIndex( )
275 static jmethodID
mID(nullptr);
276 return impl_callIntMethod_ThrowSQL("getMaxColumnsInIndex", mID
);
279 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxCursorNameLength( )
281 static jmethodID
mID(nullptr);
282 return impl_callIntMethod_ThrowSQL("getMaxCursorNameLength", mID
);
285 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxConnections( )
287 static jmethodID
mID(nullptr);
288 return impl_callIntMethod_ThrowSQL("getMaxConnections", mID
);
291 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInTable( )
293 static jmethodID
mID(nullptr);
294 return impl_callIntMethod_ThrowSQL("getMaxColumnsInTable", mID
);
297 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxStatementLength( )
299 static jmethodID
mID(nullptr);
300 return impl_callIntMethod_ThrowSQL("getMaxStatementLength", mID
);
303 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxTableNameLength( )
305 static jmethodID
mID(nullptr);
306 return impl_callIntMethod_ThrowSQL("getMaxTableNameLength", mID
);
309 sal_Int32
java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( )
311 static jmethodID
mID(nullptr);
312 return impl_callIntMethod_ThrowSQL("getMaxTablesInSelect", mID
);
315 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getExportedKeys(
316 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
318 static jmethodID
mID(nullptr);
319 return impl_callResultSetMethodWithStrings( "getExportedKeys", mID
, catalog
, schema
, table
);
322 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getImportedKeys(
323 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
325 static jmethodID
mID(nullptr);
326 return impl_callResultSetMethodWithStrings( "getImportedKeys", mID
, catalog
, schema
, table
);
329 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getPrimaryKeys(
330 const Any
& catalog
, const OUString
& schema
, const OUString
& table
)
332 static jmethodID
mID(nullptr);
333 return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID
, catalog
, schema
, table
);
336 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getIndexInfo(
337 const Any
& catalog
, const OUString
& schema
, const OUString
& table
,
338 sal_Bool unique
, sal_Bool approximate
)
340 static const char * const cMethodName
= "getIndexInfo";
342 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
344 jobject
out(nullptr);
345 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
348 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
350 static jmethodID
mID(nullptr);
351 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
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
);
356 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,table
);
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
);
362 if(catalog
.hasValue())
363 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
365 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
367 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
368 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
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
);
377 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getBestRowIdentifier(
378 const Any
& catalog
, const OUString
& schema
, const OUString
& table
, sal_Int32 scope
,
381 static const char * const cMethodName
= "getBestRowIdentifier";
383 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
385 jobject
out(nullptr);
386 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
389 static const char * const cSignature
= "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
391 static jmethodID
mID(nullptr);
392 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
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
);
397 args
[2].l
= convertwchar_tToJavaString(t
.pEnv
,table
);
398 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
,args
[1].l
,args
[2].l
,scope
,nullable
);
401 if(catalog
.hasValue())
402 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].l
));
404 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[1].l
));
406 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[2].l
));
407 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
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
);
417 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTablePrivileges(
418 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& tableNamePattern
)
420 if ( m_pConnection
->isIgnoreDriverPrivilegesEnabled() )
421 return new OResultSetPrivileges(this,catalog
,schemaPattern
,tableNamePattern
);
423 static jmethodID
mID(nullptr);
424 Reference
< XResultSet
> xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID
, catalog
, schemaPattern
, tableNamePattern
) );
428 // we have to check the result columns for the tables privileges
429 Reference
< XResultSetMetaDataSupplier
> xMetaSup(xReturn
,UNO_QUERY
);
432 Reference
< XResultSetMetaData
> xMeta
= xMetaSup
->getMetaData();
433 if ( xMeta
.is() && xMeta
->getColumnCount() != 7 )
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
[] = {
447 OUString sColumnName
;
448 sal_Int32 nCount
= xMeta
->getColumnCount();
449 for (sal_Int32 i
= 1 ; i
<= nCount
; ++i
)
451 sColumnName
= xMeta
->getColumnName(i
);
452 for (size_t j
= 0 ; j
< SAL_N_ELEMENTS(sPrivs
); ++j
)
454 if ( sPrivs
[j
] == sColumnName
)
456 aColumnMatching
.emplace(i
,j
+1);
462 // fill our own resultset
463 rtl::Reference
<ODatabaseMetaDataResultSet
> pNewPrivRes
= new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges
);
464 Reference
< XResultSet
> xTemp
= xReturn
;
465 xReturn
= pNewPrivRes
;
466 ODatabaseMetaDataResultSet::ORows aRows
;
467 Reference
< XRow
> xRow(xTemp
,UNO_QUERY
);
470 ODatabaseMetaDataResultSet::ORow
aRow(8);
471 while ( xRow
.is() && xTemp
->next() )
473 for (const auto& [nCol
, nPriv
] : aColumnMatching
)
475 sValue
= xRow
->getString(nCol
);
476 if ( xRow
->wasNull() )
477 aRow
[nPriv
] = ODatabaseMetaDataResultSet::getEmptyValue();
479 aRow
[nPriv
] = new ORowSetValueDecorator(sValue
);
482 aRows
.push_back(aRow
);
484 pNewPrivRes
->setRows(aRows
);
491 Reference
< 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
)
496 static const char * const cMethodName
= "getCrossReference";
497 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, cMethodName
);
499 jobject
out(nullptr);
500 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
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;";
504 static jmethodID
mID(nullptr);
505 obtainMethodId_throwSQL(t
.pEnv
, cMethodName
,cSignature
, mID
);
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
);
517 if(primaryCatalog
.hasValue())
518 t
.pEnv
->DeleteLocalRef(static_cast<jstring
>(args
[0].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
));
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 );
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
);
540 bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
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
);
549 OUString
java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
551 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD
, _pMethodName
);
553 const OUString
sReturn( callStringMethod(_pMethodName
,_inout_MethodID
) );
554 if ( m_aLogger
.isLoggable( LogLevel::FINEST
) )
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
);
565 sal_Int32
java_sql_DatabaseMetaData::impl_callIntMethod_ThrowSQL(const char* _pMethodName
, jmethodID
& _inout_MethodID
)
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
);
573 sal_Int32
java_sql_DatabaseMetaData::impl_callIntMethod_ThrowRuntime(const char* _pMethodName
, jmethodID
& _inout_MethodID
)
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
);
581 bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName
, jmethodID
& _inout_MethodID
, sal_Int32 _nArgument
)
583 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG1
, _pMethodName
, _nArgument
);
585 bool out( callBooleanMethodWithIntArg(_pMethodName
,_inout_MethodID
,_nArgument
) );
587 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, _pMethodName
, out
);
592 Reference
< XResultSet
> java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName
, jmethodID
& _inout_MethodID
)
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
);
602 Reference
< 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
)
606 bool bCatalog
= _rCatalog
.hasValue();
608 _rCatalog
>>= sCatalog
;
610 bool bSchema
= _rSchemaPattern
.toChar() != '%';
613 if ( m_aLogger
.isLoggable( LogLevel::FINEST
) )
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
);
620 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG3
, _pMethodName
, sCatalogLog
, sSchemaLog
, _rLeastPattern
);
623 jobject
out(nullptr);
626 OSL_ENSURE( t
.pEnv
, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java environment anymore!" );
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;";
633 obtainMethodId_throwSQL(t
.pEnv
, _pMethodName
,pSignature
, _inout_MethodID
);
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;
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
);
649 out
= t
.pEnv
->CallObjectMethod( object
, _inout_MethodID
, args
[0].l
, args
[1].l
, args
[2].l
);
653 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[0].l
) );
655 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[1].l
) );
657 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[2].l
) );
659 t
.pEnv
->DeleteLocalRef( static_cast<jstring
>(args
[3].l
) );
661 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
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
);
673 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
675 static jmethodID
mID(nullptr);
676 return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID
);
679 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
681 static jmethodID
mID(nullptr);
682 return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID
);
685 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( )
687 static jmethodID
mID(nullptr);
688 return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID
);
691 bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
693 static jmethodID
mID(nullptr);
694 return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID
);
697 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( )
699 static jmethodID
mID(nullptr);
700 return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID
);
703 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
705 static jmethodID
mID(nullptr);
706 return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID
);
709 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( )
711 static jmethodID
mID(nullptr);
712 return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID
);
715 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
717 static jmethodID
mID(nullptr);
718 return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID
);
721 bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
723 static jmethodID
mID(nullptr);
724 return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID
);
727 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxIndexLength( )
729 static jmethodID
mID(nullptr);
730 return impl_callIntMethod_ThrowSQL("getMaxIndexLength", mID
);
733 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsNonNullableColumns( )
735 static jmethodID
mID(nullptr);
736 return impl_callBooleanMethod( "supportsNonNullableColumns", mID
);
739 OUString SAL_CALL
java_sql_DatabaseMetaData::getCatalogTerm( )
741 static jmethodID
mID(nullptr);
742 return impl_callStringMethod( "getCatalogTerm", mID
);
745 OUString
java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( )
747 static jmethodID
mID(nullptr);
748 return impl_callStringMethod( "getIdentifierQuoteString", mID
);
751 OUString SAL_CALL
java_sql_DatabaseMetaData::getExtraNameCharacters( )
753 static jmethodID
mID(nullptr);
754 return impl_callStringMethod( "getExtraNameCharacters", mID
);
757 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( )
759 static jmethodID
mID(nullptr);
760 return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID
);
763 bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( )
765 static jmethodID
mID(nullptr);
766 return impl_callBooleanMethod( "isCatalogAtStart", mID
);
769 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( )
771 static jmethodID
mID(nullptr);
772 return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID
);
775 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( )
777 static jmethodID
mID(nullptr);
778 return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID
);
781 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( )
783 static jmethodID
mID(nullptr);
784 return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID
);
787 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
789 static jmethodID
mID(nullptr);
790 return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID
);
793 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsPositionedDelete( )
795 static jmethodID
mID(nullptr);
796 return impl_callBooleanMethod( "supportsPositionedDelete", mID
);
799 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsPositionedUpdate( )
801 static jmethodID
mID(nullptr);
802 return impl_callBooleanMethod( "supportsPositionedUpdate", mID
);
805 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( )
807 static jmethodID
mID(nullptr);
808 return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID
);
811 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( )
813 static jmethodID
mID(nullptr);
814 return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID
);
817 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( )
819 static jmethodID
mID(nullptr);
820 return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID
);
823 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( )
825 static jmethodID
mID(nullptr);
826 return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID
);
829 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level
)
831 static jmethodID
mID(nullptr);
832 return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID
, level
);
835 bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
837 static jmethodID
mID(nullptr);
838 return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID
);
841 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92FullSQL( )
843 static jmethodID
mID(nullptr);
844 return impl_callBooleanMethod( "supportsANSI92FullSQL", mID
);
847 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( )
849 static jmethodID
mID(nullptr);
850 return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID
);
853 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( )
855 static jmethodID
mID(nullptr);
856 return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID
);
859 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( )
861 static jmethodID
mID(nullptr);
862 return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID
);
865 bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
867 static jmethodID
mID(nullptr);
868 return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID
);
871 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
873 static jmethodID
mID(nullptr);
874 return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID
);
877 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( )
879 static jmethodID
mID(nullptr);
880 return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID
);
883 bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
885 static jmethodID
mID(nullptr);
886 return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID
);
889 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOuterJoins( )
891 static jmethodID
mID(nullptr);
892 return impl_callBooleanMethod( "supportsOuterJoins", mID
);
895 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getTableTypes( )
897 static jmethodID
mID(nullptr);
898 return impl_callResultSetMethod( "getTableTypes", mID
);
901 sal_Int32
java_sql_DatabaseMetaData::impl_getMaxStatements_throw( )
903 static jmethodID
mID(nullptr);
904 return impl_callIntMethod_ThrowSQL("getMaxStatements", mID
);
907 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxProcedureNameLength( )
909 static jmethodID
mID(nullptr);
910 return impl_callIntMethod_ThrowSQL("getMaxProcedureNameLength", mID
);
913 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxSchemaNameLength( )
915 static jmethodID
mID(nullptr);
916 return impl_callIntMethod_ThrowSQL("getMaxSchemaNameLength", mID
);
919 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTransactions( )
921 static jmethodID
mID(nullptr);
922 return impl_callBooleanMethod( "supportsTransactions", mID
);
926 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::allProceduresAreCallable( )
928 static jmethodID
mID(nullptr);
929 return impl_callBooleanMethod( "allProceduresAreCallable", mID
);
932 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsStoredProcedures( )
934 static jmethodID
mID(nullptr);
935 return impl_callBooleanMethod( "supportsStoredProcedures", mID
);
938 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSelectForUpdate( )
940 static jmethodID
mID(nullptr);
941 return impl_callBooleanMethod( "supportsSelectForUpdate", mID
);
944 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::allTablesAreSelectable( )
946 static jmethodID
mID(nullptr);
947 return impl_callBooleanMethod( "allTablesAreSelectable", mID
);
950 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::isReadOnly( )
952 static jmethodID
mID(nullptr);
953 return impl_callBooleanMethod( "isReadOnly", mID
);
956 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::usesLocalFiles( )
958 static jmethodID
mID(nullptr);
959 return impl_callBooleanMethod( "usesLocalFiles", mID
);
962 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::usesLocalFilePerTable( )
964 static jmethodID
mID(nullptr);
965 return impl_callBooleanMethod( "usesLocalFilePerTable", mID
);
968 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTypeConversion( )
970 static jmethodID
mID(nullptr);
971 return impl_callBooleanMethod( "supportsTypeConversion", mID
);
974 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullPlusNonNullIsNull( )
976 static jmethodID
mID(nullptr);
977 return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID
);
980 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsColumnAliasing( )
982 static jmethodID
mID(nullptr);
983 return impl_callBooleanMethod( "supportsColumnAliasing", mID
);
986 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsTableCorrelationNames( )
988 static jmethodID
mID(nullptr);
989 return impl_callBooleanMethod( "supportsTableCorrelationNames", mID
);
992 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType
, sal_Int32 toType
)
994 static const char* const pMethodName
= "supportsConvert";
995 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG2
, pMethodName
, fromType
, toType
);
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 );
1007 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, pMethodName
, out
);
1011 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( )
1013 static jmethodID
mID(nullptr);
1014 return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID
);
1017 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupBy( )
1019 static jmethodID
mID(nullptr);
1020 return impl_callBooleanMethod( "supportsGroupBy", mID
);
1023 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( )
1025 static jmethodID
mID(nullptr);
1026 return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID
);
1029 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsGroupByUnrelated( )
1031 static jmethodID
mID(nullptr);
1032 return impl_callBooleanMethod( "supportsGroupByUnrelated", mID
);
1035 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMultipleTransactions( )
1037 static jmethodID
mID(nullptr);
1038 return impl_callBooleanMethod( "supportsMultipleTransactions", mID
);
1041 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMultipleResultSets( )
1043 static jmethodID
mID(nullptr);
1044 return impl_callBooleanMethod( "supportsMultipleResultSets", mID
);
1047 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsLikeEscapeClause( )
1049 static jmethodID
mID(nullptr);
1050 return impl_callBooleanMethod( "supportsLikeEscapeClause", mID
);
1053 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsOrderByUnrelated( )
1055 static jmethodID
mID(nullptr);
1056 return impl_callBooleanMethod( "supportsOrderByUnrelated", mID
);
1059 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsUnion( )
1061 static jmethodID
mID(nullptr);
1062 return impl_callBooleanMethod( "supportsUnion", mID
);
1065 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsUnionAll( )
1067 static jmethodID
mID(nullptr);
1068 return impl_callBooleanMethod( "supportsUnionAll", mID
);
1071 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( )
1073 static jmethodID
mID(nullptr);
1074 return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID
);
1077 bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1079 static jmethodID
mID(nullptr);
1080 return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID
);
1083 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedAtEnd( )
1085 static jmethodID
mID(nullptr);
1086 return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID
);
1089 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedAtStart( )
1091 static jmethodID
mID(nullptr);
1092 return impl_callBooleanMethod( "nullsAreSortedAtStart", mID
);
1095 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedHigh( )
1097 static jmethodID
mID(nullptr);
1098 return impl_callBooleanMethod( "nullsAreSortedHigh", mID
);
1101 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::nullsAreSortedLow( )
1103 static jmethodID
mID(nullptr);
1104 return impl_callBooleanMethod( "nullsAreSortedLow", mID
);
1107 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( )
1109 static jmethodID
mID(nullptr);
1110 return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID
);
1113 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
1115 static jmethodID
mID(nullptr);
1116 return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID
);
1119 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( )
1121 static jmethodID
mID(nullptr);
1122 return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID
);
1125 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
1127 static jmethodID
mID(nullptr);
1128 return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID
);
1131 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( )
1133 static jmethodID
mID(nullptr);
1134 return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID
);
1137 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( )
1139 static jmethodID
mID(nullptr);
1140 return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID
);
1143 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInExists( )
1145 static jmethodID
mID(nullptr);
1146 return impl_callBooleanMethod( "supportsSubqueriesInExists", mID
);
1149 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInIns( )
1151 static jmethodID
mID(nullptr);
1152 return impl_callBooleanMethod( "supportsSubqueriesInIns", mID
);
1155 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( )
1157 static jmethodID
mID(nullptr);
1158 return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID
);
1161 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( )
1163 static jmethodID
mID(nullptr);
1164 return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID
);
1167 OUString SAL_CALL
java_sql_DatabaseMetaData::getURL( )
1169 OUString sURL
= m_pConnection
->getURL();
1170 if ( sURL
.isEmpty() )
1172 static jmethodID
mID(nullptr);
1173 sURL
= impl_callStringMethod( "getURL", mID
);
1178 OUString SAL_CALL
java_sql_DatabaseMetaData::getUserName( )
1180 static jmethodID
mID(nullptr);
1181 return impl_callStringMethod( "getUserName", mID
);
1184 OUString SAL_CALL
java_sql_DatabaseMetaData::getDriverName( )
1186 static jmethodID
mID(nullptr);
1187 return impl_callStringMethod( "getDriverName", mID
);
1190 OUString SAL_CALL
java_sql_DatabaseMetaData::getDriverVersion( )
1192 static jmethodID
mID(nullptr);
1193 return impl_callStringMethod( "getDriverVersion", mID
);
1196 OUString SAL_CALL
java_sql_DatabaseMetaData::getDatabaseProductVersion( )
1198 static jmethodID
mID(nullptr);
1199 return impl_callStringMethod( "getDatabaseProductVersion", mID
);
1202 OUString SAL_CALL
java_sql_DatabaseMetaData::getDatabaseProductName( )
1204 static jmethodID
mID(nullptr);
1205 return impl_callStringMethod( "getDatabaseProductName", mID
);
1208 OUString SAL_CALL
java_sql_DatabaseMetaData::getProcedureTerm( )
1210 static jmethodID
mID(nullptr);
1211 return impl_callStringMethod( "getProcedureTerm", mID
);
1214 OUString SAL_CALL
java_sql_DatabaseMetaData::getSchemaTerm( )
1216 static jmethodID
mID(nullptr);
1217 return impl_callStringMethod( "getSchemaTerm", mID
);
1220 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDriverMajorVersion( )
1222 static jmethodID
mID(nullptr);
1223 return impl_callIntMethod_ThrowRuntime("getDriverMajorVersion", mID
);
1226 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDefaultTransactionIsolation( )
1228 static jmethodID
mID(nullptr);
1229 return impl_callIntMethod_ThrowSQL("getDefaultTransactionIsolation", mID
);
1232 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getDriverMinorVersion( )
1234 static jmethodID
mID(nullptr);
1235 return impl_callIntMethod_ThrowRuntime("getDriverMinorVersion", mID
);
1238 OUString SAL_CALL
java_sql_DatabaseMetaData::getSQLKeywords( )
1240 static jmethodID
mID(nullptr);
1241 return impl_callStringMethod( "getSQLKeywords", mID
);
1244 OUString SAL_CALL
java_sql_DatabaseMetaData::getSearchStringEscape( )
1246 static jmethodID
mID(nullptr);
1247 return impl_callStringMethod( "getSearchStringEscape", mID
);
1250 OUString SAL_CALL
java_sql_DatabaseMetaData::getStringFunctions( )
1252 static jmethodID
mID(nullptr);
1253 return impl_callStringMethod( "getStringFunctions", mID
);
1256 OUString SAL_CALL
java_sql_DatabaseMetaData::getTimeDateFunctions( )
1258 static jmethodID
mID(nullptr);
1259 return impl_callStringMethod( "getTimeDateFunctions", mID
);
1262 OUString SAL_CALL
java_sql_DatabaseMetaData::getSystemFunctions( )
1264 static jmethodID
mID(nullptr);
1265 return impl_callStringMethod( "getSystemFunctions", mID
);
1268 OUString SAL_CALL
java_sql_DatabaseMetaData::getNumericFunctions( )
1270 static jmethodID
mID(nullptr);
1271 return impl_callStringMethod( "getNumericFunctions", mID
);
1274 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( )
1276 static jmethodID
mID(nullptr);
1277 return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID
);
1280 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsCoreSQLGrammar( )
1282 static jmethodID
mID(nullptr);
1283 return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID
);
1286 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( )
1288 static jmethodID
mID(nullptr);
1289 return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID
);
1292 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsFullOuterJoins( )
1294 static jmethodID
mID(nullptr);
1295 return impl_callBooleanMethod( "supportsFullOuterJoins", mID
);
1298 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsLimitedOuterJoins( )
1300 static jmethodID
mID(nullptr);
1301 return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID
);
1304 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( )
1306 static jmethodID
mID(nullptr);
1307 return impl_callIntMethod_ThrowSQL("getMaxColumnsInGroupBy", mID
);
1310 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( )
1312 static jmethodID
mID(nullptr);
1313 return impl_callIntMethod_ThrowSQL("getMaxColumnsInOrderBy", mID
);
1316 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxColumnsInSelect( )
1318 static jmethodID
mID(nullptr);
1319 return impl_callIntMethod_ThrowSQL("getMaxColumnsInSelect", mID
);
1322 sal_Int32 SAL_CALL
java_sql_DatabaseMetaData::getMaxUserNameLength( )
1324 static jmethodID
mID(nullptr);
1325 return impl_callIntMethod_ThrowSQL("getMaxUserNameLength", mID
);
1328 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType
)
1330 static jmethodID
mID(nullptr);
1331 return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID
, setType
);
1334 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType
, sal_Int32 concurrency
)
1336 static const char* const pMethodName
= "supportsResultSetConcurrency";
1337 m_aLogger
.log( LogLevel::FINEST
, STR_LOG_META_DATA_METHOD_ARG2
, pMethodName
, setType
, concurrency
);
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 );
1349 m_aLogger
.log
< const char*, bool >( LogLevel::FINEST
, STR_LOG_META_DATA_RESULT
, pMethodName
, out
);
1353 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType
)
1355 static jmethodID
mID(nullptr);
1356 return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID
, setType
);
1359 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType
)
1361 static jmethodID
mID(nullptr);
1362 return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID
, setType
);
1365 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType
)
1367 static jmethodID
mID(nullptr);
1368 return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID
, setType
);
1371 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType
)
1373 static jmethodID
mID(nullptr);
1374 return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID
, setType
);
1377 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType
)
1379 static jmethodID
mID(nullptr);
1380 return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID
, setType
);
1383 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType
)
1385 static jmethodID
mID(nullptr);
1386 return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID
, setType
);
1389 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType
)
1391 static jmethodID
mID(nullptr);
1392 return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID
, setType
);
1395 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType
)
1397 static jmethodID
mID(nullptr);
1398 return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID
, setType
);
1401 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType
)
1403 static jmethodID
mID(nullptr);
1404 return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID
, setType
);
1407 sal_Bool SAL_CALL
java_sql_DatabaseMetaData::supportsBatchUpdates( )
1409 static jmethodID
mID(nullptr);
1410 return impl_callBooleanMethod( "supportsBatchUpdates", mID
);
1413 Reference
< XResultSet
> SAL_CALL
java_sql_DatabaseMetaData::getUDTs(
1414 const Any
& catalog
, const OUString
& schemaPattern
, const OUString
& typeNamePattern
,
1415 const Sequence
< sal_Int32
>& types
)
1417 jobject
out(nullptr);
1418 SDBThreadAttach t
; OSL_ENSURE(t
.pEnv
,"Java environment has been deleted!");
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
);
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
);
1445 out
= t
.pEnv
->CallObjectMethod( object
, mID
, args
[0].l
, args
[1].l
,args
[2].l
,args
[3].l
);
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
));
1454 t
.pEnv
->DeleteLocalRef(static_cast<jintArray
>(args
[3].l
));
1455 ThrowLoggedSQLException( m_aLogger
, t
.pEnv
, *this );
1459 return out
? new java_sql_ResultSet( t
.pEnv
, out
, m_aLogger
,*m_pConnection
) : nullptr;
1463 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */