45jclass java_sql_DatabaseMetaData::theClass =
nullptr;
47java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
63 ,m_pConnection( &_rConnection )
64 ,m_aLogger( _rConnection.getLogger() )
72 static jmethodID mID(
nullptr);
78 static jmethodID mID(
nullptr);
84 static jmethodID mID(
nullptr);
90 static jmethodID mID(
nullptr);
95 const Any& catalog,
const OUString& schema,
const OUString& table,
const OUString& columnNamePattern )
97 static jmethodID mID(
nullptr);
102 const Any& catalog,
const OUString& schemaPattern,
const OUString& tableNamePattern,
const OUString& columnNamePattern )
104 static jmethodID mID(
nullptr);
110 const Any& catalog,
const OUString& schemaPattern,
const OUString& tableNamePattern,
const Sequence< OUString >& _types )
112 static const char *
const cMethodName =
"getTables";
116 jobject out(
nullptr);
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);
128 sal_Int32 typeFilterCount = _types.getLength();
129 if ( typeFilterCount )
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;
143 t.pEnv->SetObjectArrayElement( pObjArray,
static_cast<jsize
>(
i), aT );
147 if ( bIncludeAllTypes )
151 t.pEnv->DeleteLocalRef( pObjArray );
156 args[3].l = pObjArray;
160 Any aCatalogFilter( catalog );
161 if ( !aCatalogFilter.hasValue() )
165 if ( schemaPattern ==
"%" )
168 aSchemaFilter <<= schemaPattern;
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();
177 if ( aCatalogFilter.hasValue() )
179 t.pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[0].l));
184 t.pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[1].l));
187 if(!tableNamePattern.isEmpty())
189 t.pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[2].l));
195 t.pEnv->DeleteLocalRef(
static_cast<jobjectArray
>(
args[3].l) );
223 const Any& catalog,
const OUString& schemaPattern,
const OUString& procedureNamePattern,
const OUString& columnNamePattern )
225 static jmethodID mID(
nullptr);
230 catalog,
const OUString& schemaPattern,
const OUString& procedureNamePattern )
232 static jmethodID mID(
nullptr);
237 const Any& catalog,
const OUString& schema,
const OUString& table )
239 static jmethodID mID(
nullptr);
245 static jmethodID mID(
nullptr);
251 static jmethodID mID(
nullptr);
257 static jmethodID mID(
nullptr);
263 static jmethodID mID(
nullptr);
269 static jmethodID mID(
nullptr);
275 static jmethodID mID(
nullptr);
281 static jmethodID mID(
nullptr);
287 static jmethodID mID(
nullptr);
293 static jmethodID mID(
nullptr);
299 static jmethodID mID(
nullptr);
305 static jmethodID mID(
nullptr);
311 static jmethodID mID(
nullptr);
316 const Any& catalog,
const OUString& schema,
const OUString& table )
318 static jmethodID mID(
nullptr);
323 const Any& catalog,
const OUString& schema,
const OUString& table )
325 static jmethodID mID(
nullptr);
330 const Any& catalog,
const OUString& schema,
const OUString& table )
332 static jmethodID mID(
nullptr);
337 const Any& catalog,
const OUString& schema,
const OUString& table,
340 static const char *
const cMethodName =
"getIndexInfo";
344 jobject out(
nullptr);
348 static const char *
const cSignature =
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
350 static jmethodID mID(
nullptr);
358 args[4].z = approximate;
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));
378 const Any& catalog,
const OUString& schema,
const OUString& table, sal_Int32 scope,
381 static const char *
const cMethodName =
"getBestRowIdentifier";
385 jobject out(
nullptr);
389 static const char *
const cSignature =
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
391 static jmethodID mID(
nullptr);
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));
418 const Any& catalog,
const OUString& schemaPattern,
const OUString& tableNamePattern )
423 static jmethodID mID(
nullptr);
429 Reference< XResultSetMetaDataSupplier > xMetaSup(xReturn,UNO_QUERY);
432 Reference< XResultSetMetaData> xMeta = xMetaSup->getMetaData();
433 if ( xMeta.is() && xMeta->getColumnCount() != 7 )
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 < std::size(sPrivs); ++j)
454 if ( sPrivs[j] == sColumnName )
456 aColumnMatching.emplace(
i,j+1);
464 Reference< XResultSet > xTemp = xReturn;
465 xReturn = pNewPrivRes;
467 Reference< XRow > xRow(xTemp,UNO_QUERY);
471 while ( xRow.is() && xTemp->next() )
473 for (
const auto& [nCol, nPriv] : aColumnMatching)
475 sValue = xRow->getString(nCol);
476 if ( xRow->wasNull() )
482 aRows.push_back(aRow);
484 pNewPrivRes->setRows(std::move(aRows));
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";
499 jobject out(
nullptr);
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);
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));
556 OUString sLoggedResult( sReturn );
557 if ( sLoggedResult.isEmpty() )
558 sLoggedResult =
"<empty string>";
603 const Any& _rCatalog,
const OUString& _rSchemaPattern,
const OUString& _rLeastPattern,
604 const OUString* _pOptionalAdditionalString )
606 bool bCatalog = _rCatalog.hasValue();
610 bool bSchema = _rSchemaPattern.toChar() !=
'%';
615 OUString sCatalogLog = bCatalog ?
sCatalog : OUString(
"null" );
616 OUString sSchemaLog = bSchema ? _rSchemaPattern : OUString(
"null" );
617 if ( _pOptionalAdditionalString )
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;";
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) );
675 static jmethodID mID(
nullptr);
681 static jmethodID mID(
nullptr);
687 static jmethodID mID(
nullptr);
693 static jmethodID mID(
nullptr);
699 static jmethodID mID(
nullptr);
705 static jmethodID mID(
nullptr);
711 static jmethodID mID(
nullptr);
717 static jmethodID mID(
nullptr);
723 static jmethodID mID(
nullptr);
729 static jmethodID mID(
nullptr);
735 static jmethodID mID(
nullptr);
741 static jmethodID mID(
nullptr);
747 static jmethodID mID(
nullptr);
753 static jmethodID mID(
nullptr);
759 static jmethodID mID(
nullptr);
765 static jmethodID mID(
nullptr);
771 static jmethodID mID(
nullptr);
777 static jmethodID mID(
nullptr);
783 static jmethodID mID(
nullptr);
789 static jmethodID mID(
nullptr);
795 static jmethodID mID(
nullptr);
801 static jmethodID mID(
nullptr);
807 static jmethodID mID(
nullptr);
813 static jmethodID mID(
nullptr);
819 static jmethodID mID(
nullptr);
825 static jmethodID mID(
nullptr);
831 static jmethodID mID(
nullptr);
837 static jmethodID mID(
nullptr);
843 static jmethodID mID(
nullptr);
849 static jmethodID mID(
nullptr);
855 static jmethodID mID(
nullptr);
861 static jmethodID mID(
nullptr);
867 static jmethodID mID(
nullptr);
873 static jmethodID mID(
nullptr);
879 static jmethodID mID(
nullptr);
885 static jmethodID mID(
nullptr);
891 static jmethodID mID(
nullptr);
897 static jmethodID mID(
nullptr);
903 static jmethodID mID(
nullptr);
909 static jmethodID mID(
nullptr);
915 static jmethodID mID(
nullptr);
921 static jmethodID mID(
nullptr);
928 static jmethodID mID(
nullptr);
934 static jmethodID mID(
nullptr);
940 static jmethodID mID(
nullptr);
946 static jmethodID mID(
nullptr);
952 static jmethodID mID(
nullptr);
958 static jmethodID mID(
nullptr);
964 static jmethodID mID(
nullptr);
970 static jmethodID mID(
nullptr);
976 static jmethodID mID(
nullptr);
982 static jmethodID mID(
nullptr);
988 static jmethodID mID(
nullptr);
994 static const char*
const pMethodName =
"supportsConvert";
1001 static jmethodID mID(
nullptr);
1003 out =
t.pEnv->CallBooleanMethod(
object, mID, fromType, toType );
1013 static jmethodID mID(
nullptr);
1019 static jmethodID mID(
nullptr);
1025 static jmethodID mID(
nullptr);
1031 static jmethodID mID(
nullptr);
1037 static jmethodID mID(
nullptr);
1043 static jmethodID mID(
nullptr);
1049 static jmethodID mID(
nullptr);
1055 static jmethodID mID(
nullptr);
1061 static jmethodID mID(
nullptr);
1067 static jmethodID mID(
nullptr);
1073 static jmethodID mID(
nullptr);
1079 static jmethodID mID(
nullptr);
1085 static jmethodID mID(
nullptr);
1091 static jmethodID mID(
nullptr);
1097 static jmethodID mID(
nullptr);
1103 static jmethodID mID(
nullptr);
1109 static jmethodID mID(
nullptr);
1115 static jmethodID mID(
nullptr);
1121 static jmethodID mID(
nullptr);
1127 static jmethodID mID(
nullptr);
1133 static jmethodID mID(
nullptr);
1139 static jmethodID mID(
nullptr);
1145 static jmethodID mID(
nullptr);
1151 static jmethodID mID(
nullptr);
1157 static jmethodID mID(
nullptr);
1163 static jmethodID mID(
nullptr);
1170 if ( sURL.isEmpty() )
1172 static jmethodID mID(
nullptr);
1180 static jmethodID mID(
nullptr);
1186 static jmethodID mID(
nullptr);
1192 static jmethodID mID(
nullptr);
1198 static jmethodID mID(
nullptr);
1204 static jmethodID mID(
nullptr);
1210 static jmethodID mID(
nullptr);
1216 static jmethodID mID(
nullptr);
1222 static jmethodID mID(
nullptr);
1228 static jmethodID mID(
nullptr);
1234 static jmethodID mID(
nullptr);
1240 static jmethodID mID(
nullptr);
1246 static jmethodID mID(
nullptr);
1252 static jmethodID mID(
nullptr);
1258 static jmethodID mID(
nullptr);
1264 static jmethodID mID(
nullptr);
1270 static jmethodID mID(
nullptr);
1276 static jmethodID mID(
nullptr);
1282 static jmethodID mID(
nullptr);
1288 static jmethodID mID(
nullptr);
1294 static jmethodID mID(
nullptr);
1300 static jmethodID mID(
nullptr);
1306 static jmethodID mID(
nullptr);
1312 static jmethodID mID(
nullptr);
1318 static jmethodID mID(
nullptr);
1324 static jmethodID mID(
nullptr);
1330 static jmethodID mID(
nullptr);
1336 static const char*
const pMethodName =
"supportsResultSetConcurrency";
1343 static jmethodID mID(
nullptr);
1345 out =
t.pEnv->CallBooleanMethod(
object, mID, setType, concurrency);
1355 static jmethodID mID(
nullptr);
1361 static jmethodID mID(
nullptr);
1367 static jmethodID mID(
nullptr);
1373 static jmethodID mID(
nullptr);
1379 static jmethodID mID(
nullptr);
1385 static jmethodID mID(
nullptr);
1391 static jmethodID mID(
nullptr);
1397 static jmethodID mID(
nullptr);
1403 static jmethodID mID(
nullptr);
1409 static jmethodID mID(
nullptr);
1414 const Any& catalog,
const OUString& schemaPattern,
const OUString& typeNamePattern,
1415 const Sequence< sal_Int32 >& types )
1417 jobject out(
nullptr);
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";
1425 static jmethodID mID(
nullptr);
1433 jintArray pArray =
t.pEnv->NewIntArray(types.getLength());
1434 jint * typesData =
reinterpret_cast<jint *
>(
1435 const_cast<sal_Int32 *
>(types.getConstArray()));
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));
bool isLoggable(const sal_Int32 _nLogLevel) const
ORowSetValueDecorator decorates an ORowSetValue so the value is "refcounted".
void log(const sal_Int32 _nLogLevel, const OUString &rMessage)
logs a given message, without any arguments, or source class/method names
jobject callResultSetMethod(JNIEnv &_rEnv, const char *_pMethodName, jmethodID &_inout_MethodID) const
sal_Int32 callIntMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
bool callBooleanMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
OUString callStringMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
bool callBooleanMethodWithIntArg(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
sal_Int32 callIntMethod_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID) const
static void ThrowLoggedSQLException(const ::comphelper::EventLogger &_rLogger, JNIEnv *pEnvironment, const css::uno::Reference< css::uno::XInterface > &_rxContext)
static jclass findMyClass(const char *_pClassName)
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
static jclass st_getMyClass()
OUString getMessage() const
const css::uno::Any & getCatalogRestriction() const
bool isIgnoreDriverPrivilegesEnabled() const
const css::uno::Any & getSchemaRestriction() const
OUString getSQLState() const
static jclass st_getMyClass()
sal_Int32 getErrorCode() const
OUString getString(const Any &_rAny)
bool isExceptionOccurred(JNIEnv *pEnv)
return if an exception occurred the exception will be cleared.
jstring convertwchar_tToJavaString(JNIEnv *pEnv, const OUString &Temp)
constexpr OUStringLiteral STR_LOG_META_DATA_METHOD_ARG2
constexpr OUStringLiteral STR_LOG_META_DATA_SUCCESS
constexpr OUStringLiteral STR_LOG_META_DATA_RESULT
constexpr OUStringLiteral STR_LOG_META_DATA_METHOD
constexpr OUStringLiteral STR_LOG_META_DATA_METHOD_ARG3
constexpr OUStringLiteral STR_LOG_META_DATA_METHOD_ARG4
constexpr OUStringLiteral STR_LOG_META_DATA_METHOD_ARG1