24#include <com/sun/star/sdbc/DriverPropertyInfo.hpp>
25#include <com/sun/star/sdbc/SQLException.hpp>
26#include <com/sun/star/container/XNameAccess.hpp>
28#include <osl/diagnose.h>
37void java_util_Properties::setProperty(
const OUString& key,
const OUString&
value)
47 static const char *
const cSignature =
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;";
48 static const char *
const cMethodName =
"setProperty";
50 static jmethodID mID(
nullptr);
52 jobject out =
t.pEnv->CallObjectMethod(
object, mID,
args[0].l,
args[1].l);
54 t.pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[1].l));
55 t.pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[0].l));
58 t.pEnv->DeleteLocalRef(out);
83 static const char *
const cSignature =
"()V";
85 static jmethodID mID(
nullptr);
89 t.pEnv->DeleteLocalRef( tempObj );
95 OSL_ENSURE(pEnv,
"Environment is NULL!");
96 jstring pStr = pEnv->NewString(
97 reinterpret_cast<jchar
const *
>(_rTemp.getStr()), _rTemp.getLength());
98 pEnv->ExceptionClear();
99 OSL_ENSURE(pStr,
"Could not create a jsstring object!");
107 const PropertyValue* pBegin = info.getConstArray();
108 const PropertyValue* pEnd = pBegin + info.getLength();
110 for(;pBegin != pEnd;++pBegin)
115 if ( pBegin->Name !=
"JavaDriverClass"
116 && pBegin->Name !=
"JavaDriverClassPath"
117 && pBegin->Name !=
"SystemProperties"
118 && pBegin->Name !=
"CharSet"
119 && pBegin->Name !=
"AppendTableAliasName"
120 && pBegin->Name !=
"AppendTableAliasInSelect"
121 && pBegin->Name !=
"DisplayVersionColumns"
122 && pBegin->Name !=
"GeneratedValues"
123 && pBegin->Name !=
"UseIndexDirectionKeyword"
124 && pBegin->Name !=
"UseKeywordAsBeforeAlias"
125 && pBegin->Name !=
"AddIndexAppendix"
126 && pBegin->Name !=
"FormsCheckRequiredFields"
127 && pBegin->Name !=
"GenerateASBeforeCorrelationName"
128 && pBegin->Name !=
"EscapeDateTime"
129 && pBegin->Name !=
"ParameterNameSubstitution"
130 && pBegin->Name !=
"IsPasswordRequired"
131 && pBegin->Name !=
"IsAutoRetrievingEnabled"
132 && pBegin->Name !=
"AutoRetrievingStatement"
133 && pBegin->Name !=
"UseCatalogInSelect"
134 && pBegin->Name !=
"UseSchemaInSelect"
135 && pBegin->Name !=
"AutoIncrementCreation"
136 && pBegin->Name !=
"Extension"
137 && pBegin->Name !=
"NoNameLengthLimit"
138 && pBegin->Name !=
"EnableSQL92Check"
139 && pBegin->Name !=
"EnableOuterJoinEscape"
140 && pBegin->Name !=
"BooleanComparisonMode"
141 && pBegin->Name !=
"IgnoreCurrency"
142 && pBegin->Name !=
"TypeInfoSettings"
143 && pBegin->Name !=
"IgnoreDriverPrivileges"
144 && pBegin->Name !=
"ImplicitCatalogRestriction"
145 && pBegin->Name !=
"ImplicitSchemaRestriction"
146 && pBegin->Name !=
"SupportsTableCreation"
147 && pBegin->Name !=
"UseJava"
148 && pBegin->Name !=
"Authentication"
149 && pBegin->Name !=
"PreferDosLikeLineEnds"
150 && pBegin->Name !=
"PrimaryKeySupport"
151 && pBegin->Name !=
"RespectDriverResultSetType"
155 OSL_VERIFY( pBegin->Value >>= aStr );
156 pProps->setProperty(pBegin->Name,aStr);
167 jboolean bCopy(
true);
168 const jchar*
pChar = pEnv->GetStringChars(Str,&bCopy);
169 jsize len = pEnv->GetStringLength(Str);
173 pEnv->ReleaseStringChars(Str,
pChar);
174 pEnv->DeleteLocalRef(Str);
183 css::uno::Sequence< OUString > aNames = _rMap->getElementNames();
184 if ( aNames.hasElements() )
195 jthrowable pThrowable = pEnv->ExceptionOccurred();
196 bool bRet = pThrowable !=
nullptr;
199 pEnv->ExceptionClear();
200 pEnv->DeleteLocalRef(pThrowable);
209 if( !
t.pEnv || !
x.is() )
214 static jmethodID mID(
nullptr);
217 static const char *
const cSignature =
"([B)V";
218 mID =
t.pEnv->GetMethodID( clazz,
"<init>", cSignature );
219 OSL_ENSURE( mID, cSignature );
221 throw SQLException();
223 jbyteArray pByteArray =
t.pEnv->NewByteArray(
length);
224 Sequence< sal_Int8 >
aData;
227 memcpy(
t.pEnv->GetByteArrayElements(pByteArray,&
p),
aData.getArray(),
aData.getLength());
228 jobject out =
t.pEnv->NewObject( clazz, mID,pByteArray);
229 t.pEnv->DeleteLocalRef(pByteArray);
236 if( !
t.pEnv || !
x.is() )
241 static jmethodID mID(
nullptr);
244 static const char *
const cSignature =
"([C)V";
245 mID =
t.pEnv->GetMethodID( clazz,
"<init>", cSignature );
246 OSL_ENSURE( mID, cSignature );
248 throw SQLException();
250 jcharArray pCharArray =
t.pEnv->NewCharArray(
length);
251 Sequence< sal_Int8 >
aData;
254 memcpy(
t.pEnv->GetCharArrayElements(pCharArray,&
p),
aData.getArray(),
aData.getLength());
255 jobject out =
t.pEnv->NewObject( clazz, mID,pCharArray);
256 t.pEnv->DeleteLocalRef(pCharArray);
void saveRef(JNIEnv *pEnv, jobject myObj)
static void ThrowSQLException(JNIEnv *pEnv, const css::uno::Reference< css::uno::XInterface > &_rContext)
static jclass findMyClass(const char *_pClassName)
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
virtual jclass getMyClass() const override
virtual ~java_util_Properties() override
constexpr OUStringLiteral aData
jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > &_rMap)
bool isExceptionOccurred(JNIEnv *pEnv)
return if an exception occurred the exception will be cleared.
jobject createCharArrayReader(const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length)
OUString JavaString2String(JNIEnv *pEnv, jstring Str)
jstring convertwchar_tToJavaString(JNIEnv *pEnv, const OUString &Temp)
jobject createByteInputStream(const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length)
std::unique_ptr< java_util_Properties > createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue > &info)