53java_sql_PreparedStatement::java_sql_PreparedStatement( JNIEnv * pEnv,
java_sql_Connection& _rCon,
const OUString&
sql )
78 return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
79 static_cast< XPreparedStatement*
>(
this),
80 static_cast< XParameters*
>(
this),
81 static_cast< XResultSetMetaDataSupplier*
>(
this),
82 static_cast< XPreparedBatchExecution*
>(
this));
99 ::osl::MutexGuard aGuard(
m_aMutex );
104 static jmethodID mID(
nullptr);
111 ::osl::MutexGuard aGuard(
m_aMutex );
117 static jmethodID mID(
nullptr);
124 ::osl::MutexGuard aGuard(
m_aMutex );
131 static const char *
const cSignature =
"(ILjava/lang/String;)V";
132 static const char *
const cMethodName =
"setString";
134 static jmethodID mID(
nullptr);
137 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,str.
get());
153 ::osl::MutexGuard aGuard(
m_aMutex );
158 static jmethodID mID(
nullptr);
168 ::osl::MutexGuard aGuard(
m_aMutex );
173 static jmethodID mID(
nullptr);
181 ::osl::MutexGuard aGuard(
m_aMutex );
186 static jmethodID mID(
nullptr);
194 ::osl::MutexGuard aGuard(
m_aMutex );
200 static jmethodID mID(
nullptr);
208 ::osl::MutexGuard aGuard(
m_aMutex );
214 static jmethodID mID(
nullptr);
222 ::osl::MutexGuard aGuard(
m_aMutex );
227 static jmethodID mID(
nullptr);
235 ::osl::MutexGuard aGuard(
m_aMutex );
240 static jmethodID mID(
nullptr);
248 ::osl::MutexGuard aGuard(
m_aMutex );
253 static jmethodID mID(
nullptr);
261 ::osl::MutexGuard aGuard(
m_aMutex );
266 static jmethodID mID(
nullptr);
274 ::osl::MutexGuard aGuard(
m_aMutex );
279 static jmethodID mID(
nullptr);
287 ::osl::MutexGuard aGuard(
m_aMutex );
292 static jmethodID mID(
nullptr);
324 ::osl::MutexGuard aGuard(
m_aMutex );
332 static const char *
const cSignature =
"(ILjava/lang/Object;II)V";
333 static const char *
const cMethodName =
"setObject";
335 static jmethodID mID(
nullptr);
338 jobject obj =
nullptr;
339 switch(targetSqlType)
341 case DataType::DECIMAL:
342 case DataType::NUMERIC:
346 std::unique_ptr<java_math_BigDecimal> pBigDecimal;
357 const OUString sValue = aValue.
getString();
358 if ( !sValue.isEmpty() )
364 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,pBigDecimal->getJavaObject(),targetSqlType,
scale);
372 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,obj,targetSqlType,
scale);
373 t.pEnv->DeleteLocalRef(obj);
384 ::osl::MutexGuard aGuard(
m_aMutex );
389 static jmethodID mID(
nullptr);
390 callVoidMethod_ThrowSQL<jobject>(
"setObject",
"(ILjava/lang/Object;)V", mID, parameterIndex,
nullptr);
398 const OUString sError(
m_pConnection->getResources().getResourceStringWithSubstitution(
399 STR_UNKNOWN_PARA_TYPE,
400 "$position$", OUString::number(parameterIndex)
410 ::osl::MutexGuard aGuard(
m_aMutex );
415 static jmethodID mID(
nullptr);
423 ::osl::MutexGuard aGuard(
m_aMutex );
431 static const char *
const cSignature =
"(I[B)V";
432 static const char *
const cMethodName =
"setBytes";
434 static jmethodID mID(
nullptr);
436 jbyteArray pByteArray =
t.pEnv->NewByteArray(
x.getLength());
437 jbyte *
pData =
reinterpret_cast<jbyte *
>(
438 const_cast<sal_Int8 *
>(
x.getConstArray()));
445 t.pEnv->SetByteArrayRegion(pByteArray,0,
x.getLength(),
pData);
446 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,pByteArray);
447 t.pEnv->DeleteLocalRef(pByteArray);
456 ::osl::MutexGuard aGuard(
m_aMutex );
460 assert(
t.pEnv &&
"Java environment has been deleted!");
465 static const char *
const cSignature =
"(ILjava/io/InputStream;I)V";
466 static const char *
const cMethodName =
"setCharacterStream";
468 static jmethodID mID(
nullptr);
470 Sequence< sal_Int8 >
aSeq;
473 sal_Int32 actualLength =
aSeq.getLength();
476 jbyteArray pByteArray =
t.pEnv->NewByteArray( actualLength );
477 jbyte * aSeqData =
reinterpret_cast<jbyte *
>(
485 t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,aSeqData);
486 args2[0].l = pByteArray;
488 args2[2].i = actualLength;
490 jclass aClass =
t.pEnv->FindClass(
"java/io/CharArrayInputStream");
491 static jmethodID mID2 =
nullptr;
495 const char *
const cSignatureStream =
"([BII)V";
496 mID2 =
t.pEnv->GetMethodID( aClass,
"<init>", cSignatureStream );
498 jobject tempObj =
nullptr;
500 tempObj =
t.pEnv->NewObjectA( aClass, mID2, args2 );
502 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,tempObj,actualLength);
504 t.pEnv->DeleteLocalRef(pByteArray);
505 t.pEnv->DeleteLocalRef(tempObj);
506 t.pEnv->DeleteLocalRef(aClass);
515 ::osl::MutexGuard aGuard(
m_aMutex );
522 static const char *
const cSignature =
"(ILjava/io/InputStream;I)V";
523 static const char *
const cMethodName =
"setBinaryStream";
525 static jmethodID mID(
nullptr);
528 Sequence< sal_Int8 >
aSeq;
531 sal_Int32 actualLength =
aSeq.getLength();
534 jbyteArray pByteArray =
t.pEnv->NewByteArray(actualLength);
535 jbyte * aSeqData =
reinterpret_cast<jbyte *
>(
543 t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,aSeqData);
544 args2[0].l = pByteArray;
546 args2[2].i = actualLength;
549 jclass aClass =
t.pEnv->FindClass(
"java/io/ByteArrayInputStream");
550 static jmethodID mID2 =
nullptr;
554 const char *
const cSignatureStream =
"([BII)V";
555 mID2 =
t.pEnv->GetMethodID( aClass,
"<init>", cSignatureStream );
557 jobject tempObj =
nullptr;
559 tempObj =
t.pEnv->NewObjectA( aClass, mID2, args2 );
560 t.pEnv->CallVoidMethod(
object, mID, parameterIndex,tempObj,actualLength);
562 t.pEnv->DeleteLocalRef(pByteArray);
563 t.pEnv->DeleteLocalRef(tempObj);
564 t.pEnv->DeleteLocalRef(aClass);
574 ::osl::MutexGuard aGuard(
m_aMutex );
581 static jmethodID mID(
nullptr);
588 ::osl::MutexGuard aGuard(
m_aMutex );
593 static jmethodID mID(
nullptr);
601 ::osl::MutexGuard aGuard(
m_aMutex );
606 static jmethodID mID(
nullptr);
614 ::osl::MutexGuard aGuard(
m_aMutex );
616 css::uno::Sequence< sal_Int32 >
aSeq;
619 static jmethodID mID(
nullptr);
620 jintArray out =
static_cast<jintArray
>(
callObjectMethod(
t.pEnv,
"executeBatch",
"()[I", mID));
624 aSeq.realloc(
t.pEnv->GetArrayLength(out));
625 memcpy(
aSeq.getArray(),
t.pEnv->GetIntArrayElements(out,&
p),
aSeq.getLength());
626 t.pEnv->DeleteLocalRef(out);
633 ::osl::MutexGuard aGuard(
m_aMutex );
637 static jmethodID mID(
nullptr);
638 jobject out =
callObjectMethod(
t.pEnv,
"getMetaData",
"()Ljava/sql/ResultSetMetaData;", mID);
655 ::osl::MutexGuard aGuard(
m_aMutex );
658 if(
object || !_pEnv )
662 static const char *
const cMethodName =
"prepareStatement";
668 jobject out =
nullptr;
669 static jmethodID mID(
nullptr);
672 static const char *
const cSignature =
"(Ljava/lang/String;II)Ljava/sql/PreparedStatement;";
673 mID = _pEnv->GetMethodID(
m_pConnection->getMyClass(), cMethodName, cSignature );
681 static jmethodID mID2 =
nullptr;
684 static const char *
const cSignature2 =
"(Ljava/lang/String;)Ljava/sql/PreparedStatement;";
685 mID2 = _pEnv->GetMethodID(
m_pConnection->getMyClass(), cMethodName, cSignature2 );
688 out = _pEnv->CallObjectMethod(
m_pConnection->getJavaObject(), mID2,
args[0].l );
690 _pEnv->DeleteLocalRef(
static_cast<jstring
>(
args[0].l));
693 object = _pEnv->NewGlobalRef( out );
OUString getString() const
void fill(sal_Int32 _nPos, sal_Int32 _nType, const css::uno::Reference< css::sdbc::XRow > &_xRow)
fetches a single value out of the row
void log(const sal_Int32 _nLogLevel, const OUString &rMessage)
logs a given message, without any arguments, or source class/method names
jobject callObjectMethod(JNIEnv *pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
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
void callVoidMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
static void ThrowLoggedSQLException(const ::comphelper::EventLogger &_rLogger, JNIEnv *pEnvironment, const css::uno::Reference< css::uno::XInterface > &_rxContext)
jobject getJavaObject() const
static jclass findMyClass(const char *_pClassName)
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray > &x) override
virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) override
virtual void SAL_CALL setString(sal_Int32 parameterIndex, const OUString &x) override
virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const css::uno::Any &x, sal_Int32 targetSqlType, sal_Int32 scale) override
virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() override
virtual ~java_sql_PreparedStatement() override
virtual void createStatement(JNIEnv *_pEnv) override
virtual jclass getMyClass() const override
virtual sal_Int32 SAL_CALL executeUpdate() override
virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob > &x) override
virtual sal_Bool SAL_CALL execute() override
virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL clearParameters() override
virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef > &x) override
virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 > &x) override
virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime &x) override
virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString &typeName) override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) override
virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override
virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) override
virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const css::uno::Any &x) override
virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const css::util::Date &x) override
virtual void SAL_CALL clearBatch() override
virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) override
virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const css::util::Time &x) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) override
virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob > &x) override
virtual void SAL_CALL addBatch() override
java::sql::ConnectionLog m_aLogger
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
sal_Int32 m_nResultSetConcurrency
sal_Int32 m_nResultSetType
virtual void SAL_CALL release() noexcept override
rtl::Reference< java_sql_Connection > m_pConnection
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL acquire() noexcept override
helper class to hold a local ref to a JNI object
mutable::osl::Mutex m_aMutex
IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement")
Sequence< sal_Int8 > aSeq
std::unique_ptr< sal_Int32[]> pData
jstring convertwchar_tToJavaString(JNIEnv *pEnv, const OUString &Temp)
void checkDisposed(bool _bThrow)
constexpr OUStringLiteral STR_LOG_TIMESTAMP_PARAMETER
constexpr OUStringLiteral STR_LOG_BINARYSTREAM_PARAMETER
constexpr OUStringLiteral STR_LOG_DATE_PARAMETER
constexpr OUStringLiteral STR_LOG_DOUBLE_PARAMETER
constexpr OUStringLiteral STR_LOG_INT_PARAMETER
constexpr OUStringLiteral STR_LOG_CHARSTREAM_PARAMETER
constexpr OUStringLiteral STR_LOG_STRING_PARAMETER
constexpr OUStringLiteral STR_LOG_EXECUTING_PREPARED_UPDATE
constexpr OUStringLiteral STR_LOG_FLOAT_PARAMETER
constexpr OUStringLiteral STR_LOG_BOOLEAN_PARAMETER
constexpr OUStringLiteral STR_LOG_TIME_PARAMETER
constexpr OUStringLiteral STR_LOG_CLEAR_PARAMETERS
constexpr OUStringLiteral STR_LOG_LONG_PARAMETER
constexpr OUStringLiteral STR_LOG_SHORT_PARAMETER
constexpr OUStringLiteral STR_LOG_EXECUTING_PREPARED
constexpr OUStringLiteral STR_LOG_NULL_PARAMETER
constexpr OUStringLiteral STR_LOG_EXECUTING_PREPARED_QUERY
constexpr OUStringLiteral STR_LOG_BYTES_PARAMETER
constexpr OUStringLiteral STR_LOG_BYTE_PARAMETER
constexpr OUStringLiteral STR_LOG_OBJECT_NULL_PARAMETER