summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/jdbc
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2009-04-23 10:42:05 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2009-04-23 10:42:05 +0000
commitb9392a36645d8632b97ad79240f483b3a1683b61 (patch)
treea7596b538b33f0eb9a47d83a0a19972e72a54da4 /connectivity/source/drivers/jdbc
parentcaae90c2a21d3ed30250ebb79dbcc06737f7356b (diff)
CWS-TOOLING: integrate CWS dbaperf1
2009-04-02 09:12:25 +0200 oj r270372 : CWS-TOOLING: rebase CWS dbaperf1 to trunk@270033 (milestone: DEV300:m45) 2009-03-17 10:20:34 +0100 oj r269577 : add parameter 2009-03-17 10:20:05 +0100 oj r269576 : add parameter 2009-03-12 12:32:24 +0100 oj r269387 : add missing ++ 2009-03-11 12:53:35 +0100 oj r269315 : compile error 2009-03-06 08:52:11 +0100 oj r268968 : #i99264# remove duplicate code 2009-03-06 08:20:08 +0100 oj r268966 : add missingheader 2009-03-06 08:17:41 +0100 oj r268965 : add header 2009-03-06 08:15:07 +0100 oj r268964 : #i99708# remove duplicate code 2009-03-06 07:24:11 +0100 oj r268963 : #i99708# remove duplicate code 2009-03-06 07:22:24 +0100 oj r268962 : #i99708# use tenary operator 2009-03-06 07:19:21 +0100 oj r268961 : remove unused rtl_logs 2009-03-06 07:15:55 +0100 oj r268960 : #i99708# extract getLength from for loop 2009-03-06 07:15:35 +0100 oj r268959 : #i99708# extract getLength from for loop 2009-03-06 07:14:57 +0100 oj r268958 : remove unused rtl_logs 2009-03-06 07:13:01 +0100 oj r268957 : insert DBG_ helper 2009-03-06 07:12:17 +0100 oj r268956 : remove unused rtl_logs 2009-03-06 07:10:26 +0100 oj r268955 : remove unused rtl_logs 2009-03-06 07:04:51 +0100 oj r268954 : #i99708# use tenary operator 2009-03-05 12:04:46 +0100 oj r268895 : comment RTL_LOG out 2009-03-05 09:05:07 +0100 oj r268874 : add rtl logfile 2009-03-04 14:21:18 +0100 oj r268828 : #i99708# make static inplace and some method calls in for loop removed 2009-03-04 14:20:34 +0100 oj r268827 : #i99708# impl double check pattern for getInfohelper 2009-03-02 09:31:42 +0100 oj r268636 : add rtl logfile 2009-03-02 08:18:37 +0100 oj r268633 : add rtl logfile 2009-02-27 11:22:16 +0100 oj r268570 : #i99709# change algorithm for marking objects 2009-02-27 11:17:04 +0100 oj r268568 : #i99708# some improvements to load forms, controls faster and replacement of size() call with !empty() which is much faster 2009-02-24 10:09:35 +0100 sb r268383 : #i99290# no longer care to set a sensible context class loader for native threads attached to the VM 2009-02-23 13:44:04 +0100 oj r268354 : #i76606# seekrow changes 2009-02-23 12:27:30 +0100 oj r268349 : deleted 2009-02-20 15:14:23 +0100 oj r268325 : #i76606# some code changes 2009-02-19 14:15:25 +0100 oj r268284 : #i76606# use of simple prep stmt instead of full blown rowset, when source and dest connection are the same use insert into ... ( select ... ) 2009-02-19 11:27:55 +0100 oj r268265 : #i76606# insert some RTL_LOG and setObject impl 2009-02-18 14:45:37 +0100 oj r268222 : #i99363# insert RTL_LOG 2009-02-18 14:45:18 +0100 oj r268221 : #i99363# insert RTL_LOG 2009-02-18 11:14:54 +0100 oj r268207 : #i99363# call some impl_ methods to avoid duplicate cechCache calls 2009-02-18 11:10:47 +0100 oj r268206 : #i99363# make isCount inline 2009-02-18 10:33:22 +0100 oj r268203 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-18 10:32:57 +0100 oj r268202 : #i99363# use bookmarkable if available and inserted some RTL_LOG 2009-02-17 07:29:05 +0100 oj r267843 : #i96897# remove some dll public 2009-02-16 15:01:04 +0100 oj r267816 : #i96897# remove some dll public 2009-02-16 14:25:53 +0100 oj r267810 : #i99264# remove duplicate code 2009-02-16 14:25:33 +0100 oj r267809 : #i99264# remove duplicate code 2009-02-16 14:24:59 +0100 oj r267808 : #i99264# remove duplicate code 2009-02-13 10:56:17 +0100 oj r267703 : #i99191# comment the contextclassloader 2009-02-13 10:32:40 +0100 oj r267700 : reduce call to resultset meta data 2009-02-13 10:27:31 +0100 oj r267699 : reduce call to resultset meta data 2009-02-13 10:27:08 +0100 oj r267698 : reduce call to resultset meta data
Diffstat (limited to 'connectivity/source/drivers/jdbc')
-rw-r--r--connectivity/source/drivers/jdbc/Array.cxx129
-rw-r--r--connectivity/source/drivers/jdbc/Blob.cxx100
-rw-r--r--connectivity/source/drivers/jdbc/Boolean.cxx33
-rw-r--r--connectivity/source/drivers/jdbc/CallableStatement.cxx472
-rw-r--r--connectivity/source/drivers/jdbc/Class.cxx109
-rw-r--r--connectivity/source/drivers/jdbc/Clob.cxx85
-rw-r--r--connectivity/source/drivers/jdbc/DatabaseMetaData.cxx762
-rw-r--r--connectivity/source/drivers/jdbc/Date.cxx19
-rw-r--r--connectivity/source/drivers/jdbc/DriverManager.cxx113
-rw-r--r--connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx50
-rw-r--r--connectivity/source/drivers/jdbc/Exception.cxx20
-rw-r--r--connectivity/source/drivers/jdbc/InputStream.cxx95
-rw-r--r--connectivity/source/drivers/jdbc/JBigDecimal.cxx34
-rw-r--r--connectivity/source/drivers/jdbc/JConnection.cxx380
-rw-r--r--connectivity/source/drivers/jdbc/JDriver.cxx1
-rw-r--r--connectivity/source/drivers/jdbc/JStatement.cxx716
-rw-r--r--connectivity/source/drivers/jdbc/Object.cxx269
-rw-r--r--connectivity/source/drivers/jdbc/PreparedStatement.cxx540
-rw-r--r--connectivity/source/drivers/jdbc/Reader.cxx95
-rw-r--r--connectivity/source/drivers/jdbc/Ref.cxx41
-rw-r--r--connectivity/source/drivers/jdbc/ResultSet.cxx1346
-rw-r--r--connectivity/source/drivers/jdbc/ResultSetMetaData.cxx468
-rw-r--r--connectivity/source/drivers/jdbc/SQLException.cxx87
-rw-r--r--connectivity/source/drivers/jdbc/SQLWarning.cxx20
-rw-r--r--connectivity/source/drivers/jdbc/String.cxx30
-rw-r--r--connectivity/source/drivers/jdbc/Throwable.cxx90
-rw-r--r--connectivity/source/drivers/jdbc/Timestamp.cxx100
-rw-r--r--connectivity/source/drivers/jdbc/makefile.mk1
-rw-r--r--connectivity/source/drivers/jdbc/tools.cxx40
29 files changed, 1446 insertions, 4799 deletions
diff --git a/connectivity/source/drivers/jdbc/Array.cxx b/connectivity/source/drivers/jdbc/Array.cxx
index 8a1b6e4290a0..ef5e5c681701 100644
--- a/connectivity/source/drivers/jdbc/Array.cxx
+++ b/connectivity/source/drivers/jdbc/Array.cxx
@@ -44,91 +44,43 @@ jclass java_sql_Array::theClass = 0;
java_sql_Array::~java_sql_Array()
{}
-jclass java_sql_Array::getMyClass()
+jclass java_sql_Array::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/sql/Array" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Array");
+
return theClass;
}
-void java_sql_Array::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getBaseTypeName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- aStr = JavaString2String(t.pEnv,out);
- // und aufraeumen
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getBaseTypeName",mID);
}
sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getBaseType";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID );
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getBaseType",mID);
}
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
jobjectArray out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
static const char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;";
static const char * cMethodName = "getArray";
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj);
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(obj);
- } //mID
+ out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
} //t.pEnv
return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
}
@@ -137,21 +89,18 @@ sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc:
{
jobjectArray out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
static const char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;";
static const char * cMethodName = "getArray";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj);
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(obj);
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
} //t.pEnv
return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
}
@@ -160,22 +109,19 @@ sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc:
{
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
// Parameter konvertieren
jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
static const char * cMethodName = "getResultSet";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, obj);
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(obj);
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod( object, mID, obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
// return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
@@ -186,22 +132,19 @@ sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc:
{
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
// Parameter konvertieren
jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
static const char * cMethodName = "getResultSetAtIndex";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, index,count,obj);
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(obj);
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod( object, mID, index,count,obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
// return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx
index b95c2e4ea0ba..364469399f2b 100644
--- a/connectivity/source/drivers/jdbc/Blob.cxx
+++ b/connectivity/source/drivers/jdbc/Blob.cxx
@@ -56,46 +56,28 @@ java_sql_Blob::~java_sql_Blob()
SDBThreadAttach::releaseRef();
}
-jclass java_sql_Blob::getMyClass()
+jclass java_sql_Blob::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/sql/Blob" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Blob");
return theClass;
}
-void java_sql_Blob::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
static const char * cSignature = "()J";
static const char * cMethodName = "length";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallLongMethod( object, mID );
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID );
+ ThrowSQLException(t.pEnv,*this);
} //t.pEnv
return (sal_Int64)out;
}
@@ -104,26 +86,22 @@ sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLEx
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
- if( t.pEnv ){
+ {
// temporaere Variable initialisieren
static const char * cSignature = "(JI)[B";
static const char * cMethodName = "getBytes";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID,pos,count);
- ThrowSQLException(t.pEnv,*this);
- if(out)
- {
- jboolean p = sal_False;
- aSeq.realloc(t.pEnv->GetArrayLength(out));
- memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
- t.pEnv->DeleteLocalRef(out);
- }
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID,pos,count);
+ ThrowSQLException(t.pEnv,*this);
+ if(out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return aSeq;
@@ -131,21 +109,9 @@ sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLEx
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Blob::getBinaryStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/io/InputStream;";
- static const char * cMethodName = "getBinaryStream";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getBinaryStream","()Ljava/io/InputStream;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_io_InputStream( t.pEnv, out );
}
@@ -154,24 +120,20 @@ sal_Int64 SAL_CALL java_sql_Blob::position( const ::com::sun::star::uno::Sequenc
{
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
static const char * cSignature = "([BI)J";
static const char * cMethodName = "position";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength());
- t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),(jbyte*)pattern.getConstArray());
- out = t.pEnv->CallLongMethod( object, mID, pByteArray,start );
- t.pEnv->DeleteLocalRef(pByteArray);
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength());
+ t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),(jbyte*)pattern.getConstArray());
+ out = t.pEnv->CallLongMethod( object, mID, pByteArray,start );
+ t.pEnv->DeleteLocalRef(pByteArray);
+ ThrowSQLException(t.pEnv,*this);
} //t.pEnv
return (sal_Int64)out;
}
diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx
index 5f396e40ccc6..cac868d4792f 100644
--- a/connectivity/source/drivers/jdbc/Boolean.cxx
+++ b/connectivity/source/drivers/jdbc/Boolean.cxx
@@ -41,43 +41,26 @@ jclass java_lang_Boolean::theClass = 0;
java_lang_Boolean::~java_lang_Boolean()
{}
-jclass java_lang_Boolean::getMyClass()
+jclass java_lang_Boolean::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/lang/Boolean"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
+ if( !theClass )
+ {
+ theClass = findMyClass("java/lang/Boolean");
}
return theClass;
}
-void java_lang_Boolean::saveClassRef( jclass pClass )
+java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL )
{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
-java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ){
SDBThreadAttach t;
- if( !t.pEnv )
- return;
- jvalue args[1];
- // Parameter konvertieren
- args[0].z = _par0;
// Java-Call fuer den Konstruktor absetzen
// temporaere Variable initialisieren
static const char * cSignature = "(Z)V";
jobject tempObj;
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
- tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 );
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
// und aufraeumen
diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx
index 921ba6704105..8cea582940d3 100644
--- a/connectivity/source/drivers/jdbc/CallableStatement.cxx
+++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx
@@ -83,78 +83,22 @@ Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) th
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "wasNull";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "wasNull", mID );
}
sal_Bool SAL_CALL java_sql_CallableStatement::getBoolean( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "getBoolean";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex );
}
sal_Int8 SAL_CALL java_sql_CallableStatement::getByte( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jbyte out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)B";
- static const char * cMethodName = "getByte";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallByteMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod;
+ return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex);
}
Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
@@ -163,205 +107,78 @@ Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 co
Sequence< sal_Int8 > aSeq;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex);
+ if (out)
{
- createStatement(t.pEnv);
- static const char * cSignature = "(I)[B";
- static const char * cMethodName = "getBytes";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jbyteArray out(0);
- out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- if (out)
- {
- jboolean p = sal_False;
- aSeq.realloc(t.pEnv->GetArrayLength(out));
- memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
- t.pEnv->DeleteLocalRef(out);
- }
- // und aufraeumen
- } //mID
- } //t.pEnv
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
return aSeq;
}
::com::sun::star::util::Date SAL_CALL java_sql_CallableStatement::getDate( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Date;";
- static const char * cMethodName = "getDate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex);
return out ? static_cast <com::sun::star::util::Date>(java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date();
}
double SAL_CALL java_sql_CallableStatement::getDouble( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jdouble out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)D";
- static const char * cMethodName = "getDouble";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallDoubleMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ double (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod;
+ return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex);
}
float SAL_CALL java_sql_CallableStatement::getFloat( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jfloat out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)F";
- static const char * cMethodName = "getFloat";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallFloatMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod;
+ return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex);
}
sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getInt";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getInt",mID,columnIndex);
}
sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)J";
- static const char * cMethodName = "getLong";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallLongMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod;
+ return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex);
}
Any SAL_CALL java_sql_CallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/Object;";
- static const char * cMethodName = "getObject";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ /*jobject out = */callObjectMethodWithIntArg(t.pEnv,"getObject","(I)Ljava/lang/Object;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return Any(); //out==0 ? 0 : new java_lang_Object( t.pEnv, out );
}
sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jshort out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)S";
- static const char * cMethodName = "getShort";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallShortMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int16)out;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod;
+ return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex);
}
::rtl::OUString SAL_CALL java_sql_CallableStatement::getString( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
@@ -369,74 +186,27 @@ sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getString";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- // und aufraeumen
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getString",mID,columnIndex);
}
::com::sun::star::util::Time SAL_CALL java_sql_CallableStatement::getTime( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Time;";
- static const char * cMethodName = "getTime";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time();
}
::com::sun::star::util::DateTime SAL_CALL java_sql_CallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Timestamp;";
- static const char * cMethodName = "getTimestamp";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime();
}
@@ -446,7 +216,7 @@ void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parame
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
createStatement(t.pEnv);
@@ -454,17 +224,13 @@ void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parame
static const char * cSignature = "(IILjava/lang/String;)V";
static const char * cMethodName = "registerOutParameter";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,typeName);
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str);
- t.pEnv->DeleteLocalRef(str);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jstring str = convertwchar_tToJavaString(t.pEnv,typeName);
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str);
+ t.pEnv->DeleteLocalRef(str);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
}
void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
@@ -472,48 +238,30 @@ void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
createStatement(t.pEnv);
// temporaere Variable initialisieren
static const char * cSignature = "(III)V";
static const char * cMethodName = "registerOutParameter";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,scale);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,scale);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
}
jclass java_sql_CallableStatement::theClass = 0;
-jclass java_sql_CallableStatement::getMyClass()
+jclass java_sql_CallableStatement::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/CallableStatement"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/CallableStatement");
return theClass;
}
-void java_sql_CallableStatement::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
Reference< starsdbc::XBlob > xBlob = getBlob(columnIndex);
@@ -527,99 +275,39 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatem
Reference< starsdbc::XArray > SAL_CALL java_sql_CallableStatement::getArray( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Array;";
- static const char * cMethodName = "getArray";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Array( t.pEnv, out );
}
Reference< starsdbc::XClob > SAL_CALL java_sql_CallableStatement::getClob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Clob;";
- static const char * cMethodName = "getClob";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Clob( t.pEnv, out );
}
Reference< starsdbc::XBlob > SAL_CALL java_sql_CallableStatement::getBlob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Blob;";
- static const char * cMethodName = "getBlob";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Blob( t.pEnv, out );
}
Reference< starsdbc::XRef > SAL_CALL java_sql_CallableStatement::getRef( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Ref;";
- static const char * cMethodName = "getRef";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Ref( t.pEnv, out );
}
@@ -650,7 +338,7 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
// Parameter konvertieren
jstring str = convertwchar_tToJavaString(t.pEnv,m_sSqlStatement);
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
if( mID ){
diff --git a/connectivity/source/drivers/jdbc/Class.cxx b/connectivity/source/drivers/jdbc/Class.cxx
index 6d233f710522..052cd0ef2736 100644
--- a/connectivity/source/drivers/jdbc/Class.cxx
+++ b/connectivity/source/drivers/jdbc/Class.cxx
@@ -44,33 +44,19 @@ jclass java_lang_Class::theClass = 0;
java_lang_Class::~java_lang_Class()
{}
-jclass java_lang_Class::getMyClass()
+jclass java_lang_Class::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/lang/Class"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/lang/Class");
return theClass;
}
-void java_lang_Class::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 )
{
jobject out(NULL);
SDBThreadAttach t;
- if( t.pEnv )
+
{
::rtl::OString sClassName = ::rtl::OUStringToOString(_par0, RTL_TEXTENCODING_JAVA_UTF8);
sClassName = sClassName.replace('.','/');
@@ -81,93 +67,10 @@ java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 )
return out==0 ? NULL : new java_lang_Class( t.pEnv, out );
}
-sal_Bool java_lang_Class::isAssignableFrom( java_lang_Class * _par0 )
-{
- jboolean out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/Class;)Z";
- static const char * cMethodName = "isAssignableFrom";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[1];
- // Parameter konvertieren
- args[0].l = _par0 != NULL ? ((java_lang_Object *)_par0)->getJavaObject() : NULL;
- out = t.pEnv->CallBooleanMethod( object, mID, args[0].l );
- ThrowSQLException(t.pEnv,0);
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
-}
-
-java_lang_Object * java_lang_Class::newInstance()
-{
- jobject out(NULL);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/Object;";
- static const char * cMethodName = "newInstance";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return out==0 ? NULL : new java_lang_Object( t.pEnv, out );
-}
-
jobject java_lang_Class::newInstanceObject()
{
- jobject out(NULL);
SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/Object;";
- static const char * cMethodName = "newInstance";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return out;
-}
-
-::rtl::OUString java_lang_Class::getName()
-{
- SDBThreadAttach t;
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- aStr = JavaString2String(t.pEnv, (jstring)out );
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callObjectMethod(t.pEnv,"newInstance","()Ljava/lang/Object;", mID);
}
diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx
index 8396be5912f3..632504448e06 100644
--- a/connectivity/source/drivers/jdbc/Clob.cxx
+++ b/connectivity/source/drivers/jdbc/Clob.cxx
@@ -51,46 +51,28 @@ java_sql_Clob::~java_sql_Clob()
SDBThreadAttach::releaseRef();
}
-jclass java_sql_Clob::getMyClass()
+jclass java_sql_Clob::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/sql/Clob" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Clob");
return theClass;
}
-void java_sql_Clob::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
static const char * cSignature = "()J";
static const char * cMethodName = "length";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallLongMethod( object, mID );
- ThrowSQLException(t.pEnv,*this);
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID );
+ ThrowSQLException(t.pEnv,*this);
} //t.pEnv
return (sal_Int64)out;
}
@@ -99,20 +81,16 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
::rtl::OUString aStr;
- if( t.pEnv ){
+ {
// temporaere Variable initialisieren
static const char * cSignature = "(JI)Ljava/lang/String;";
static const char * cMethodName = "getSubString";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID,pos,subStringLength);
- ThrowSQLException(t.pEnv,*this);
- aStr = JavaString2String(t.pEnv,out);
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID,pos,subStringLength);
+ ThrowSQLException(t.pEnv,*this);
+ aStr = JavaString2String(t.pEnv,out);
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return aStr;
@@ -120,21 +98,10 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- jobject out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/io/Reader;";
- static const char * cMethodName = "getCharacterStream";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- } //mID
- } //t.pEnv
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID);
+
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_io_Reader( t.pEnv, out );
}
@@ -143,7 +110,7 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sa
{
jlong out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jvalue args[1];
// Parameter konvertieren
@@ -152,15 +119,11 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sa
static const char * cSignature = "(Ljava/lang/String;I)J";
static const char * cMethodName = "position";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallLongMethod( object, mID, args[0].l,start );
- ThrowSQLException(t.pEnv,*this);
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID, args[0].l,start );
+ ThrowSQLException(t.pEnv,*this);
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
} //t.pEnv
return (sal_Int64)out;
}
diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
index 765c8a5e2ffb..0899f1566b51 100644
--- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
@@ -62,17 +62,11 @@ java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
SDBThreadAttach::releaseRef();
}
-jclass java_sql_DatabaseMetaData::getMyClass()
+jclass java_sql_DatabaseMetaData::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/DatabaseMetaData"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/DatabaseMetaData");
return theClass;
}
// -----------------------------------------------------------------------------
@@ -86,49 +80,41 @@ java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myO
}
// -------------------------------------------------------------------------
-void java_sql_DatabaseMetaData::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// -------------------------------------------------------------------------
Reference< XResultSet > java_sql_DatabaseMetaData::impl_getTypeInfo_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethod( "getTypeInfo", mID );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethod( "getCatalogs", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getCatalogSeparator", mID );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethod( "getSchemas", mID );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID, catalog, schema, table, &columnNamePattern );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns(
const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getColumns", mID, catalog, schemaPattern, tableNamePattern, &columnNamePattern );
}
@@ -143,109 +129,100 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ OSL_VERIFY_RES( !isExceptionOccured(t.pEnv,sal_True),"Exception occured!");
+ jvalue args[4];
+
+ args[3].l = 0;
+ sal_Int32 typeFilterCount = _types.getLength();
+ if ( typeFilterCount )
{
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );
+ jobjectArray pObjArray = static_cast< jobjectArray >( t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::getMyClass(), 0 ) );
OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
- }
- OSL_ENSURE( mID, "Unknown method id!" );
- if( mID )
- {
- jvalue args[4];
-
- args[3].l = 0;
- sal_Int32 typeFilterCount = _types.getLength();
- if ( typeFilterCount )
+ const ::rtl::OUString* typeFilter = _types.getConstArray();
+ bool bIncludeAllTypes = false;
+ for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter )
{
- jobjectArray pObjArray = static_cast< jobjectArray >( t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::getMyClass(), 0 ) );
- OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
-
- const ::rtl::OUString* typeFilter = _types.getConstArray();
- bool bIncludeAllTypes = false;
- for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter )
- {
- if ( typeFilter->equalsAsciiL( "%", 1 ) )
- {
- bIncludeAllTypes = true;
- break;
- }
- jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter );
- t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT );
- OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
- }
-
- if ( bIncludeAllTypes )
- {
- // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types"
- // is represented by the table type being <null/>
- t.pEnv->DeleteLocalRef( pObjArray );
- OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
- }
- else
+ if ( typeFilter->equalsAsciiL( "%", 1 ) )
{
- args[3].l = pObjArray;
+ bIncludeAllTypes = true;
+ break;
}
- }
-
- // if we are to display "all catalogs", then respect m_aCatalogRestriction
- Any aCatalogFilter( catalog );
- if ( !aCatalogFilter.hasValue() )
- aCatalogFilter = m_pConnection->getCatalogRestriction();
- // similar for schema
- Any aSchemaFilter;
- if ( schemaPattern.equalsAsciiL( "%", 1 ) )
- aSchemaFilter = m_pConnection->getSchemaRestriction();
- else
- aSchemaFilter <<= schemaPattern;
-
- args[0].l = aCatalogFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aCatalogFilter ) ) : NULL;
- args[1].l = aSchemaFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aSchemaFilter ) ) : NULL;
- args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern);
- out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
- jthrowable jThrow = t.pEnv->ExceptionOccurred();
- if ( jThrow )
- t.pEnv->ExceptionClear();// we have to clear the exception here because we want to handle it below
-
- if ( aCatalogFilter.hasValue() )
- {
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
- }
- if(args[1].l)
- {
- t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter );
+ t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT );
OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
}
- if(tableNamePattern.getLength())
+
+ if ( bIncludeAllTypes )
{
- t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types"
+ // is represented by the table type being <null/>
+ t.pEnv->DeleteLocalRef( pObjArray );
OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
}
- //for(INT16 i=0;i<len;i++)
- if ( args[3].l )
+ else
{
- t.pEnv->DeleteLocalRef( (jobjectArray)args[3].l );
- OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ args[3].l = pObjArray;
}
+ }
- if ( jThrow )
+ // if we are to display "all catalogs", then respect m_aCatalogRestriction
+ Any aCatalogFilter( catalog );
+ if ( !aCatalogFilter.hasValue() )
+ aCatalogFilter = m_pConnection->getCatalogRestriction();
+ // similar for schema
+ Any aSchemaFilter;
+ if ( schemaPattern.equalsAsciiL( "%", 1 ) )
+ aSchemaFilter = m_pConnection->getSchemaRestriction();
+ else
+ aSchemaFilter <<= schemaPattern;
+
+ args[0].l = aCatalogFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aCatalogFilter ) ) : NULL;
+ args[1].l = aSchemaFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aSchemaFilter ) ) : NULL;
+ args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
+ jthrowable jThrow = t.pEnv->ExceptionOccurred();
+ if ( jThrow )
+ t.pEnv->ExceptionClear();// we have to clear the exception here because we want to handle it below
+ if ( aCatalogFilter.hasValue() )
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ if(args[1].l)
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ if(tableNamePattern.getLength())
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ //for(INT16 i=0;i<len;i++)
+ if ( args[3].l )
+ {
+ t.pEnv->DeleteLocalRef( (jobjectArray)args[3].l );
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+
+ if ( jThrow )
+ {
+ if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::getMyClass() ) )
{
- if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::getMyClass() ) )
- {
- java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow );
- SQLException e( pException->getMessage(),
- *this,
- pException->getSQLState(),
- pException->getErrorCode(),
- Any()
- );
- delete pException;
- throw e;
- }
+ java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow );
+ SQLException e( pException->getMessage(),
+ *this,
+ pException->getSQLState(),
+ pException->getErrorCode(),
+ Any()
+ );
+ delete pException;
+ throw e;
}
}
}
@@ -260,114 +237,114 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedureColumns(
const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID, catalog, schemaPattern, procedureNamePattern, &columnNamePattern );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedures( const Any&
catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getProcedures", mID, catalog, schemaPattern, procedureNamePattern );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getVersionColumns", mID, catalog, schema, table );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxBinaryLiteralLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxRowSize", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxCatalogNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxCharLiteralLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnsInIndex", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxCursorNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxConnections", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnsInTable", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxStatementLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxTableNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxTablesInSelect", mID );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getExportedKeys", mID, catalog, schema, table );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getImportedKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getImportedKeys", mID, catalog, schema, table );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getPrimaryKeys(
const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID, catalog, schema, table );
}
// -------------------------------------------------------------------------
@@ -382,31 +359,28 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo(
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[5];
- // Parameter konvertieren
- args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
- args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
- args[2].l = convertwchar_tToJavaString(t.pEnv,table);
- args[3].z = unique;
- args[4].z = approximate;
- out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z );
-
- // und aufraeumen
- if(catalog.hasValue())
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- if(args[1].l)
- t.pEnv->DeleteLocalRef((jstring)args[1].l);
- if(table.getLength())
- t.pEnv->DeleteLocalRef((jstring)args[2].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[5];
+ // Parameter konvertieren
+ args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
+ args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,table);
+ args[3].z = unique;
+ args[4].z = approximate;
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z );
+
+ // und aufraeumen
+ if(catalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(table.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
if ( !out )
return NULL;
@@ -426,29 +400,26 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[3];
- // Parameter konvertieren
- args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
- args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
- args[2].l = convertwchar_tToJavaString(t.pEnv,table);
- out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable);
-
- // und aufraeumen
- if(catalog.hasValue())
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- if(args[1].l)
- t.pEnv->DeleteLocalRef((jstring)args[1].l);
- if(table.getLength())
- t.pEnv->DeleteLocalRef((jstring)args[2].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[3];
+ // Parameter konvertieren
+ args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
+ args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,table);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable);
+
+ // und aufraeumen
+ if(catalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(table.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
if ( !out )
@@ -464,7 +435,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges(
if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
Reference< XResultSet > xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID, catalog, schemaPattern, tableNamePattern ) );
if ( xReturn.is() )
@@ -546,38 +517,35 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference(
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[6];
- // Parameter konvertieren
- args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(primaryCatalog)) : 0;
- args[1].l = primarySchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,primarySchema);
- args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable);
- args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(foreignCatalog)) : 0;
- args[4].l = foreignSchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,foreignSchema);
- args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable);
- out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l );
-
- // und aufraeumen
- if(primaryCatalog.hasValue())
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- if(args[1].l)
- t.pEnv->DeleteLocalRef((jstring)args[1].l);
- if(primaryTable.getLength())
- t.pEnv->DeleteLocalRef((jstring)args[2].l);
- if(foreignCatalog.hasValue())
- t.pEnv->DeleteLocalRef((jstring)args[3].l);
- if(args[4].l)
- t.pEnv->DeleteLocalRef((jstring)args[4].l);
- if(foreignTable.getLength())
- t.pEnv->DeleteLocalRef((jstring)args[5].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[6];
+ // Parameter konvertieren
+ args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(primaryCatalog)) : 0;
+ args[1].l = primarySchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,primarySchema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable);
+ args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(foreignCatalog)) : 0;
+ args[4].l = foreignSchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,foreignSchema);
+ args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l );
+
+ // und aufraeumen
+ if(primaryCatalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(primaryTable.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ if(foreignCatalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[3].l);
+ if(args[4].l)
+ t.pEnv->DeleteLocalRef((jstring)args[4].l);
+ if(foreignTable.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[5].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
if ( !out )
@@ -591,26 +559,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference(
sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
{
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
-
- jboolean out( sal_False );
-
- SDBThreadAttach t;
- OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callBooleanMethod: no Java enviroment anymore!" );
- if ( t.pEnv )
- {
- // obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, "()Z" );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callBooleanMethod:: unknown method id!" );
-
- // call method
- if ( _inout_MethodID )
- {
- out = t.pEnv->CallBooleanMethod( object, _inout_MethodID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
-
+ jboolean out( java_lang_Object::callBooleanMethod(_pMethodName,_inout_MethodID) );
m_aLogger.log< const sal_Char*, sal_Int16>( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
return out;
}
@@ -620,26 +569,7 @@ sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethod
{
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
- ::rtl::OUString sReturn;
-
- SDBThreadAttach t;
- OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callStringMethod: no Java enviroment anymore!" );
- if( t.pEnv )
- {
- // obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, "()Ljava/lang/String;" );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callStringMethod: unknown method id!" );
-
- // call method
- if ( _inout_MethodID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, _inout_MethodID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- sReturn = JavaString2String( t.pEnv, out );
- }
- }
-
+ const ::rtl::OUString sReturn( callStringMethod(_pMethodName,_inout_MethodID) );
if ( m_aLogger.isLoggable( LogLevel::FINEST ) )
{
::rtl::OUString sLoggedResult( sReturn );
@@ -655,28 +585,9 @@ sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethod
sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
{
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
-
- jint out( 0 );
-
- SDBThreadAttach t;
- OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callIntMethod: no Java enviroment anymore!" );
- if( t.pEnv )
- {
- // obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, "()I" );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callIntMethod: unknown method id!" );
-
- // call method
- if ( _inout_MethodID )
- {
- out = t.pEnv->CallIntMethod( object, _inout_MethodID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
-
+ sal_Int32 out( (sal_Int32)callIntMethod(_pMethodName,_inout_MethodID) );
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, (sal_Int32)out );
- return (sal_Int32)out;
+ return out;
}
// -------------------------------------------------------------------------
@@ -684,23 +595,7 @@ sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char
{
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG1, _pMethodName, _nArgument );
- jboolean out( sal_False );
- SDBThreadAttach t;
- OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg: no Java enviroment anymore!" );
- if ( t.pEnv )
- {
- // obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, "(I)Z" );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg: unknown method id!" );
-
- // call method
- if ( _inout_MethodID )
- {
- out = t.pEnv->CallBooleanMethod( object, _inout_MethodID, _nArgument );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ jboolean out( callBooleanMethodWithIntArg(_pMethodName,_inout_MethodID,_nArgument) );
m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
return out;
@@ -709,30 +604,9 @@ sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char
// -------------------------------------------------------------------------
Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
{
- m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
-
- jobject out(0);
-
SDBThreadAttach t;
- OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callResultSetMethod: no Java enviroment anymore!" );
- if ( t.pEnv )
- {
- // obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, "()Ljava/sql/ResultSet;" );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callResultSetMethod: unknown method id!" );
-
- // call method
- if ( _inout_MethodID )
- {
- out = t.pEnv->CallObjectMethod( object, _inout_MethodID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
-
- if ( !out )
- return NULL;
-
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
+ jobject out(callResultSetMethod(t.env(),_pMethodName,_inout_MethodID));
m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName );
return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
}
@@ -762,18 +636,16 @@ Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethodWithS
SDBThreadAttach t;
OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java enviroment anymore!" );
- if ( t.pEnv )
+
{
const char* pSignature = _pOptionalAdditionalString
? "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"
: "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
// obtain method ID
- if ( !_inout_MethodID )
- _inout_MethodID = t.pEnv->GetMethodID( getMyClass(), _pMethodName, pSignature );
- OSL_ENSURE( _inout_MethodID, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: unknown method id!" );
+ obtainMethodId(t.pEnv, _pMethodName,pSignature, _inout_MethodID);
// call method
- if ( _inout_MethodID )
+
{
jvalue args[4];
// convert parameters
@@ -812,320 +684,320 @@ Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethodWithS
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxIndexLength", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsNonNullableColumns", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getCatalogTerm", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getIdentifierQuoteString", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getExtraNameCharacters", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "isCatalogAtStart", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsPositionedDelete", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsPositionedUpdate", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID, level );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsANSI92FullSQL", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOuterJoins", mID );
}
// -------------------------------------------------------------------------
Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callResultSetMethod( "getTableTypes", mID );
}
// -------------------------------------------------------------------------
sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxStatements", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxProcedureNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxSchemaNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsTransactions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "allProceduresAreCallable", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsStoredProcedures", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSelectForUpdate", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "allTablesAreSelectable", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "isReadOnly", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "usesLocalFiles", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "usesLocalFilePerTable", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsTypeConversion", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsColumnAliasing", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsTableCorrelationNames", mID );
}
// -------------------------------------------------------------------------
@@ -1136,18 +1008,12 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType
jboolean out( sal_False );
SDBThreadAttach t;
- if ( t.pEnv )
- {
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), pMethodName, "(II)Z" );
- OSL_ENSURE( mID, "java_sql_DatabaseMetaData::supportsConvert: unknown method id!" );
- if ( mID )
- {
- out = t.pEnv->CallBooleanMethod( object, mID, fromType, toType );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ {
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID);
+ out = t.pEnv->CallBooleanMethod( object, mID, fromType, toType );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
@@ -1156,157 +1022,157 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsGroupBy", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsGroupByUnrelated", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsMultipleTransactions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsMultipleResultSets", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsLikeEscapeClause", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsOrderByUnrelated", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsUnion", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsUnionAll", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "nullsAreSortedAtStart", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "nullsAreSortedHigh", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "nullsAreSortedLow", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSubqueriesInExists", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSubqueriesInIns", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID );
}
// -------------------------------------------------------------------------
@@ -1315,7 +1181,7 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) t
::rtl::OUString sURL = m_pConnection->getURL();
if ( !sURL.getLength() )
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
sURL = impl_callStringMethod( "getURL", mID );
}
return sURL;
@@ -1323,157 +1189,157 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) t
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getUserName", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getDriverName", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getDriverVersion", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getDatabaseProductVersion", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getDatabaseProductName", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getProcedureTerm", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getSchemaTerm", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getDriverMajorVersion", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getDefaultTransactionIsolation", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getDriverMinorVersion", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getSQLKeywords", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getSearchStringEscape", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getStringFunctions", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getTimeDateFunctions", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getSystemFunctions", mID );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callStringMethod( "getNumericFunctions", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsFullOuterJoins", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnsInGroupBy", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnsInOrderBy", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxColumnsInSelect", mID );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callIntMethod( "getMaxUserNameLength", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID, setType );
}
// -------------------------------------------------------------------------
@@ -1484,18 +1350,12 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_I
jboolean out( sal_False );
SDBThreadAttach t;
- if ( t.pEnv )
- {
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), pMethodName, "(II)Z" );
- OSL_ENSURE( mID, "java_sql_DatabaseMetaData::supportsResultSetConcurrency: unknown method id!" );
- if ( mID )
- {
- out = t.pEnv->CallBooleanMethod( object, mID, setType, concurrency);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ {
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID);
+ out = t.pEnv->CallBooleanMethod( object, mID, setType, concurrency);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
}
m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
@@ -1504,61 +1364,61 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_I
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID, setType );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
{
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
return impl_callBooleanMethod( "supportsBatchUpdates", mID );
}
// -------------------------------------------------------------------------
@@ -1568,16 +1428,14 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getUDTs(
{
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/sql/ResultSet;";
static const char * cMethodName = "getUDTs";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
{
jvalue args[4];
// temporaere Variable initialisieren
diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx
index 7962066f093c..06044ea984c1 100644
--- a/connectivity/source/drivers/jdbc/Date.cxx
+++ b/connectivity/source/drivers/jdbc/Date.cxx
@@ -43,27 +43,14 @@ jclass java_util_Date::theClass = 0;
java_util_Date::~java_util_Date()
{}
-jclass java_util_Date::getMyClass()
+jclass java_util_Date::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/util/Date" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/util/Date");
return theClass;
}
-void java_util_Date::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/DriverManager.cxx b/connectivity/source/drivers/jdbc/DriverManager.cxx
deleted file mode 100644
index fc7fbe9b5dd4..000000000000
--- a/connectivity/source/drivers/jdbc/DriverManager.cxx
+++ /dev/null
@@ -1,113 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: DriverManager.cxx,v $
- * $Revision: 1.12 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_connectivity.hxx"
-#include "java/sql/DriverManager.hxx"
-#include "java/tools.hxx"
-
-using namespace connectivity;
-//**************************************************************
-//************ Class: java.sql.DriverManager
-//**************************************************************
-
-jclass java_sql_DriverManager::theClass = 0;
-
-java_sql_DriverManager::~java_sql_DriverManager()
-{}
-
-jclass java_sql_DriverManager::getMyClass()
-{
- // die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/DriverManager"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
- return theClass;
-}
-
-void java_sql_DriverManager::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
-jobject java_sql_DriverManager::getDriver(const ::rtl::OUString &url)
-{
- jobject out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- jvalue args[1];
- // Parameter konvertieren
- args[0].l = convertwchar_tToJavaString(t.pEnv,url);
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Driver;";
- static const char * cMethodName = "getDriver";
- // Java-Call absetzen
- static jmethodID mID = t.pEnv->GetStaticMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
- // und aufraeumen
-
- } //mID
- t.pEnv->DeleteLocalRef((jstring)args[0].l);
- return t.pEnv->NewGlobalRef( out );
- } //t.pEnv
-
- return out;
-}
-
-
-void java_sql_DriverManager::setLoginTimeout(sal_Int32 _par0)
-{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setLoginTimeout";
- // Java-Call absetzen
- static jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- t.pEnv->CallStaticVoidMethod(getMyClass(), mID, _par0);
- ThrowSQLException(t.pEnv,0);
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
-}
-
-
diff --git a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx
index e95c07659f38..795067b37e99 100644
--- a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx
+++ b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx
@@ -52,31 +52,15 @@ jclass java_sql_DriverPropertyInfo::theClass = 0;
java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
{}
// --------------------------------------------------------------------------------
-jclass java_sql_DriverPropertyInfo::getMyClass()
+jclass java_sql_DriverPropertyInfo::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
- {
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/DriverPropertyInfo");
- OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ theClass = findMyClass("java/sql/DriverPropertyInfo");
return theClass;
}
// --------------------------------------------------------------------------------
-void java_sql_DriverPropertyInfo::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// --------------------------------------------------------------------------------
java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
{
starsdbc::DriverPropertyInfo aInfo;
@@ -89,64 +73,64 @@ java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
return aInfo;
}
// --------------------------------------------------------------------------------
-::rtl::OUString java_sql_DriverPropertyInfo::name() const
+::rtl::OUString java_sql_DriverPropertyInfo::name()
{
::rtl::OUString aStr;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
- jfieldID id = t.pEnv->GetFieldID(java_sql_DriverPropertyInfo::getMyClass(),"name","Ljava/lang/String;");
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
if(id)
aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
} //t.pEnv
return aStr;
}
// --------------------------------------------------------------------------------
-::rtl::OUString java_sql_DriverPropertyInfo::description() const
+::rtl::OUString java_sql_DriverPropertyInfo::description()
{
::rtl::OUString aStr;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
- jfieldID id = t.pEnv->GetFieldID(java_sql_DriverPropertyInfo::getMyClass(),"description","Ljava/lang/String;");
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
if(id)
aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
} //t.pEnv
return aStr;
}
// --------------------------------------------------------------------------------
-::rtl::OUString java_sql_DriverPropertyInfo::value() const
+::rtl::OUString java_sql_DriverPropertyInfo::value()
{
::rtl::OUString aStr;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
- jfieldID id = t.pEnv->GetFieldID(java_sql_DriverPropertyInfo::getMyClass(),"value","Ljava/lang/String;");
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
if(id)
aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
} //t.pEnv
return aStr;
}
// --------------------------------------------------------------------------------
-sal_Bool java_sql_DriverPropertyInfo::required() const
+sal_Bool java_sql_DriverPropertyInfo::required()
{
jboolean out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
- jfieldID id = t.pEnv->GetFieldID(java_sql_DriverPropertyInfo::getMyClass(),"required","Z");
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
if(id)
out = t.pEnv->GetBooleanField( object, id);
} //t.pEnv
return out;
}
// --------------------------------------------------------------------------------
-Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices() const
+Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
- jfieldID id = t.pEnv->GetFieldID(java_sql_DriverPropertyInfo::getMyClass(),"choices","[Ljava/lang/String;");
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
if(id)
{
const java_lang_String * pEmpty = NULL;
diff --git a/connectivity/source/drivers/jdbc/Exception.cxx b/connectivity/source/drivers/jdbc/Exception.cxx
index 61246d7f5857..a2290c5c1dba 100644
--- a/connectivity/source/drivers/jdbc/Exception.cxx
+++ b/connectivity/source/drivers/jdbc/Exception.cxx
@@ -41,25 +41,11 @@ jclass java_lang_Exception::theClass = 0;
java_lang_Exception::~java_lang_Exception()
{}
-jclass java_lang_Exception::getMyClass()
+jclass java_lang_Exception::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/lang/Exception"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/lang/Exception");
return theClass;
}
-void java_lang_Exception::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx
index 32e893f5c665..522c1f67973e 100644
--- a/connectivity/source/drivers/jdbc/InputStream.cxx
+++ b/connectivity/source/drivers/jdbc/InputStream.cxx
@@ -51,27 +51,14 @@ java_io_InputStream::~java_io_InputStream()
SDBThreadAttach::releaseRef();
}
-jclass java_io_InputStream::getMyClass()
+jclass java_io_InputStream::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/io/InputStream" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/io/InputStream");
return theClass;
}
-void java_io_InputStream::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
@@ -80,61 +67,19 @@ sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Se
void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "skip";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallIntMethod( object, mID,nBytesToSkip);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callIntMethodWithIntArg("skip",mID,nBytesToSkip);
}
sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "()Z";
- static const char * cMethodName = "available";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callIntMethod("available",mID);
}
void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
}
// -----------------------------------------------------
sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
@@ -143,25 +88,21 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen
throw ::com::sun::star::io::BufferSizeExceededException();
jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead);
static const char * cSignature = "([BII)I";
static const char * cMethodName = "read";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
+ if ( !out )
+ ThrowSQLException(t.pEnv,*this);
+ if(out > 0)
{
- out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
- if ( !out )
- ThrowSQLException(t.pEnv,*this);
- if(out > 0)
- {
- jboolean p = sal_False;
- memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
- }
+ jboolean p = sal_False;
+ memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
}
t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
} //t.pEnv
diff --git a/connectivity/source/drivers/jdbc/JBigDecimal.cxx b/connectivity/source/drivers/jdbc/JBigDecimal.cxx
index a3a3c185c96a..e7f3f2bb00cb 100644
--- a/connectivity/source/drivers/jdbc/JBigDecimal.cxx
+++ b/connectivity/source/drivers/jdbc/JBigDecimal.cxx
@@ -43,29 +43,16 @@ jclass java_math_BigDecimal::theClass = 0;
java_math_BigDecimal::~java_math_BigDecimal()
{}
-jclass java_math_BigDecimal::getMyClass()
+jclass java_math_BigDecimal::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/math/BigDecimal"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/math/BigDecimal");
return theClass;
}
-void java_math_BigDecimal::saveClassRef( jclass pClass )
+java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL )
{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
-java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL ){
SDBThreadAttach t;
if( !t.pEnv )
return;
@@ -73,9 +60,8 @@ java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)V";
jobject tempObj;
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
jstring str = convertwchar_tToJavaString(t.pEnv,_par0.replace(',','.'));
tempObj = t.pEnv->NewObject( getMyClass(), mID, str );
@@ -86,7 +72,8 @@ java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java
// und aufraeumen
}
-java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Object( NULL, (jobject)NULL ){
+java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Object( NULL, (jobject)NULL )
+{
SDBThreadAttach t;
if( !t.pEnv )
return;
@@ -94,9 +81,8 @@ java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Obj
// temporaere Variable initialisieren
static const char * cSignature = "(D)V";
jobject tempObj;
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 );
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index 0730d6e9964d..96325511807f 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -289,11 +289,9 @@ java_sql_Connection::~java_sql_Connection()
if ( xTest.is() )
{
SDBThreadAttach t;
- if( t.pEnv )
+ clearObject(*t.pEnv);
+
{
- if( object )
- t.pEnv->DeleteGlobalRef( object );
- object = NULL;
if ( m_pDriverobject )
t.pEnv->DeleteGlobalRef( m_pDriverobject );
m_pDriverobject = NULL;
@@ -321,69 +319,27 @@ void java_sql_Connection::disposing()
if ( object )
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
}
}
// -------------------------------------------------------------------------
-jclass java_sql_Connection::getMyClass()
+jclass java_sql_Connection::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Connection"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Connection");
return theClass;
}
// -------------------------------------------------------------------------
-void java_sql_Connection::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_Connection::getCatalog( ) throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getCatalog";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getCatalog",mID);
}
// -------------------------------------------------------------------------
Reference< XDatabaseMetaData > SAL_CALL java_sql_Connection::getMetaData( ) throw(SQLException, RuntimeException)
@@ -395,24 +351,11 @@ Reference< XDatabaseMetaData > SAL_CALL java_sql_Connection::getMetaData( ) thr
Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
if(!xMetaData.is())
{
- jobject out(0);//(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/DatabaseMetaData;";
- static const char * cMethodName = "getMetaData";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/DatabaseMetaData;", mID);
if(out)
{
-
xMetaData = new java_sql_DatabaseMetaData( t.pEnv, out, *this );
m_xMetaData = xMetaData;
}
@@ -428,193 +371,54 @@ void SAL_CALL java_sql_Connection::close( ) throw(SQLException, RuntimeExceptio
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::commit( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "commit";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("commit",mID);
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_Connection::isClosed( ) throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
- jboolean out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isClosed";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out && java_sql_Connection_BASE::rBHelper.bDisposed;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isClosed", mID ) && java_sql_Connection_BASE::rBHelper.bDisposed;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_Connection::isReadOnly( ) throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isReadOnly";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isReadOnly", mID );
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)V";
- static const char * cMethodName = "setCatalog";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,catalog);
- t.pEnv->CallVoidMethod( object, mID, str );
-
- t.pEnv->DeleteLocalRef(str);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("setCatalog",mID,catalog);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::rollback( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "rollback";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("rollback",mID);
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_Connection::getAutoCommit( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- jboolean out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "getAutoCommit";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallBooleanMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "getAutoCommit", mID );
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(Z)V";
- static const char * cMethodName = "setReadOnly";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, (jboolean)readOnly );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setReadOnly",mID,readOnly);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(Z)V";
- static const char * cMethodName = "setAutoCommit";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, (jboolean)autoCommit );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setAutoCommit",mID,autoCommit);
}
// -------------------------------------------------------------------------
Reference< ::com::sun::star::container::XNameAccess > SAL_CALL java_sql_Connection::getTypeMap( ) throw(SQLException, RuntimeException)
@@ -622,23 +426,9 @@ Reference< ::com::sun::star::container::XNameAccess > SAL_CALL java_sql_Connecti
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/util/Map;";
- static const char * cMethodName = "getTypeMap";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ /*jobject out = */callObjectMethod(t.pEnv,"getTypeMap","()Ljava/util/Map;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return 0;// ? 0 : Map2XNameAccess( t.pEnv, out );
}
@@ -657,23 +447,8 @@ sal_Int32 SAL_CALL java_sql_Connection::getTransactionIsolation( ) throw(SQLExc
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getTransactionIsolation";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallIntMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getTransactionIsolation",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
@@ -681,22 +456,8 @@ void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) th
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setTransactionIsolation";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, level );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setTransactionIsolation",mID,level);
}
// -------------------------------------------------------------------------
Reference< XStatement > SAL_CALL java_sql_Connection::createStatement( ) throw(SQLException, RuntimeException)
@@ -783,26 +544,21 @@ Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const
::rtl::OUString aStr;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)Ljava/lang/String;";
static const char * cMethodName = "nativeSQL";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,sql);
-
- jobject out = t.pEnv->CallObjectMethod( object, mID, str );
- t.pEnv->DeleteLocalRef(str);
- aStr = JavaString2String(t.pEnv, (jstring)out );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
-
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jstring str = convertwchar_tToJavaString(t.pEnv,sql);
+
+ jobject out = t.pEnv->CallObjectMethod( object, mID, str );
+ t.pEnv->DeleteLocalRef(str);
+ aStr = JavaString2String(t.pEnv, (jstring)out );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
m_aLogger.log( LogLevel::FINER, STR_LOG_NATIVE_SQL, sql, aStr );
@@ -812,24 +568,8 @@ Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const
// -------------------------------------------------------------------------
void SAL_CALL java_sql_Connection::clearWarnings( ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
-
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
}
// -------------------------------------------------------------------------
Any SAL_CALL java_sql_Connection::getWarnings( ) throw(SQLException, RuntimeException)
@@ -837,22 +577,9 @@ Any SAL_CALL java_sql_Connection::getWarnings( ) throw(SQLException, RuntimeExc
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
- jobject out(NULL);
SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/SQLWarning;";
- static const char * cMethodName = "getWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
if( out )
{
@@ -961,8 +688,8 @@ void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDri
m_pDriverClassLoader.reset();
// here I try to find the class for jdbc driver
- java_sql_SQLException_BASE::getMyClass();
- java_lang_Throwable::getMyClass();
+ java_sql_SQLException_BASE::st_getMyClass();
+ java_lang_Throwable::st_getMyClass();
if ( !_sDriverClass.getLength() )
{
@@ -1005,7 +732,7 @@ void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDri
if( t.pEnv && m_pDriverobject )
m_pDriverobject = t.pEnv->NewGlobalRef( m_pDriverobject );
- if( t.pEnv )
+
{
jclass tempClass = t.pEnv->GetObjectClass(m_pDriverobject);
if ( m_pDriverobject )
@@ -1084,10 +811,9 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url,
static const char * cMethodName = "connect";
// Java-Call absetzen
jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- if( mID )
+ if ( !mID )
+ mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature );
+ if ( mID )
{
jvalue args[2];
// Parameter konvertieren
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
index b392a4b61a79..7d2bafa0d29c 100644
--- a/connectivity/source/drivers/jdbc/JDriver.cxx
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -33,7 +33,6 @@
#include "java/sql/Driver.hxx"
#include "java/lang/Object.hxx"
#include "java/lang/Class.hxx"
-#include "java/sql/DriverManager.hxx"
#include "java/sql/DriverPropertyInfo.hxx"
#include "java/sql/Connection.hxx"
#include "java/util/Property.hxx"
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
index 5ff18bb2c130..f4d798973611 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -96,20 +96,8 @@ void SAL_CALL OStatement_BASE2::disposing()
if ( object )
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
}
::comphelper::disposeComponent(m_xGeneratedStatement);
@@ -121,17 +109,11 @@ void SAL_CALL OStatement_BASE2::disposing()
java_sql_Statement_Base::disposing();
}
// -------------------------------------------------------------------------
-jclass java_sql_Statement_Base::getMyClass()
+jclass java_sql_Statement_Base::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Statement"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Statement");
return theClass;
}
// -----------------------------------------------------------------------------
@@ -143,14 +125,6 @@ void SAL_CALL java_sql_Statement_Base::disposing(void)
}
// -------------------------------------------------------------------------
-void java_sql_Statement_Base::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-//-----------------------------------------------------------------------------
void SAL_CALL OStatement_BASE2::release() throw()
{
relase_ChildImpl();
@@ -190,23 +164,17 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( )
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+ createStatement(t.pEnv);
+ // temporaere Variable initialisieren
+ try
{
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/ResultSet;";
- static const char * cMethodName = "getGeneratedKeys";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- // und aufraeumen
- // ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- connectivity::isExceptionOccured(t.pEnv,sal_True);
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ out = callResultSetMethod(t.env(),"getGeneratedKeys",mID);
+ }
+ catch(const SQLException&)
+ {
+ // ignore
+ }
Reference< XResultSet > xRes;
if ( !out )
@@ -234,23 +202,9 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( )
void SAL_CALL java_sql_Statement_Base::cancel( ) throw(RuntimeException)
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- if( t.pEnv ){
-
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "cancel";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("cancel",mID);
}
// -------------------------------------------------------------------------
@@ -268,20 +222,11 @@ void SAL_CALL java_sql_Statement_Base::close( ) throw(::com::sun::star::sdbc::S
void SAL_CALL java_sql_Statement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethod("clearBatch",mID);
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -294,8 +239,6 @@ sal_Bool SAL_CALL java_sql_Statement_Base::execute( const ::rtl::OUString& sql )
jboolean out(sal_False);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
-
- if( t.pEnv )
{
createStatement(t.pEnv);
m_sSqlStatement = sql;
@@ -303,23 +246,20 @@ sal_Bool SAL_CALL java_sql_Statement_Base::execute( const ::rtl::OUString& sql )
static const char * cSignature = "(Ljava/lang/String;)Z";
static const char * cMethodName = "execute";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
- {
- jdbc::ContextClassLoaderScope ccl( t.env(),
- m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
- m_aLogger,
- *this
- );
-
- out = t.pEnv->CallBooleanMethod( object, mID, str.get() );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ {
+ jdbc::ContextClassLoaderScope ccl( t.env(),
+ m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_aLogger,
+ *this
+ );
+
+ out = t.pEnv->CallBooleanMethod( object, mID, str.get() );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
} //t.pEnv
return out;
}
@@ -333,7 +273,7 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const ::
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
createStatement(t.pEnv);
m_sSqlStatement = sql;
@@ -341,23 +281,20 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const ::
static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/ResultSet;";
static const char * cMethodName = "executeQuery";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
- {
- jdbc::ContextClassLoaderScope ccl( t.env(),
- m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
- m_aLogger,
- *this
- );
-
- out = t.pEnv->CallObjectMethod( object, mID, str.get() );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ {
+ jdbc::ContextClassLoaderScope ccl( t.env(),
+ m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_aLogger,
+ *this
+ );
+
+ out = t.pEnv->CallObjectMethod( object, mID, str.get() );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
@@ -383,24 +320,10 @@ void SAL_CALL java_sql_Statement::addBatch( const ::rtl::OUString& sql ) throw(:
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
+ {
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)V";
- static const char * cMethodName = "addBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,sql);
- t.pEnv->CallVoidMethod( object, mID, str );
- // und aufraeumen
- t.pEnv->DeleteLocalRef(str);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("addBatch",mID,sql);
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -411,27 +334,16 @@ Sequence< sal_Int32 > SAL_CALL java_sql_Statement::executeBatch( ) throw(::com:
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
Sequence< sal_Int32 > aSeq;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()[I";
- static const char * cMethodName = "executeBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jintArray out = (jintArray)t.pEnv->CallObjectMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- if (out)
- {
- jboolean p = sal_False;
- aSeq.realloc(t.pEnv->GetArrayLength(out));
- memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
- t.pEnv->DeleteLocalRef(out);
- }
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID);
+ if (out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
return aSeq;
}
// -------------------------------------------------------------------------
@@ -443,58 +355,21 @@ sal_Int32 SAL_CALL java_sql_Statement_Base::executeUpdate( const ::rtl::OUString
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_UPDATE, sql );
- jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- m_sSqlStatement = sql;
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)I";
- static const char * cMethodName = "executeUpdate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
- {
- jdbc::ContextClassLoaderScope ccl( t.env(),
- m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
- m_aLogger,
- *this
- );
-
- out = t.pEnv->CallIntMethod( object, mID, str.get() );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ createStatement(t.pEnv);
+ m_sSqlStatement = sql;
+ static jmethodID mID(NULL);
+ return callIntMethodWithStringArg("executeUpdate",mID,sql);
}
// -------------------------------------------------------------------------
Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callResultSetMethod(t.env(),"getResultSet",mID);
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/ResultSet;";
- static const char * cMethodName = "getResultSet";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
}
@@ -502,78 +377,29 @@ Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base
sal_Int32 SAL_CALL java_sql_Statement_Base::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getUpdateCount";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
-
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ sal_Int32 out = callIntMethod("getUpdateCount",mID);
m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, (sal_Int32)out );
- return (sal_Int32)out;
+ return out;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_Statement_Base::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "getMoreResults";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "getMoreResults", mID );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
Any SAL_CALL java_sql_Statement_Base::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(NULL);
SDBThreadAttach t;
- if( t.pEnv )
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/SQLWarning;";
- static const char * cMethodName = "getWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
if( out )
{
@@ -591,192 +417,72 @@ void SAL_CALL java_sql_Statement_Base::clearWarnings( ) throw(::com::sun::star:
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t;
- if( t.pEnv )
+
{
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
}
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getQueryTimeOut() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getQueryTimeOut";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("getQueryTimeOut",mID);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getMaxRows() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getMaxRows";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("getMaxRows",mID);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getResultSetConcurrency() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv && object ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getResultSetConcurrency";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- else
- out = m_nResultSetConcurrency;
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("getResultSetConcurrency",mID,m_nResultSetConcurrency);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getResultSetType() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv && object ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getResultSetType";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
+ static jmethodID mID(NULL);
+ return impl_getProperty("getResultSetType",mID,m_nResultSetType);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault)
+{
+ sal_Int32 out = _nDefault;
+ if ( object )
+ out = callIntMethod(_pMethodName,_inout_MethodID,true);
- } //mID
- } //t.pEnv
- else
- out = m_nResultSetType;
- return (sal_Int32)out;
+ return out;
}
//------------------------------------------------------------------------------
-sal_Int32 java_sql_Statement_Base::getFetchDirection() throw(SQLException, RuntimeException)
+sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getFetchDirection";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
+ createStatement(t.pEnv);
+ return callIntMethod(_pMethodName,_inout_MethodID,true);
+}
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getFetchDirection() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getFetchDirection",mID);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getFetchSize() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getFetchSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("getFetchSize",mID);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_Statement_Base::getMaxFieldSize() throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getMaxFieldSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("getMaxFieldSize",mID);
}
//------------------------------------------------------------------------------
::rtl::OUString java_sql_Statement_Base::getCursorName() throw(SQLException, RuntimeException)
@@ -784,26 +490,16 @@ sal_Int32 java_sql_Statement_Base::getMaxFieldSize() throw(SQLException, Runtime
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv )
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ try
{
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getCursorName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- isExceptionOccured(t.pEnv,sal_True);
-
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ return callStringMethod("getCursorName",mID);
+ }
+ catch(const SQLException&)
+ {
+ }
+ return ::rtl::OUString();
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -811,22 +507,9 @@ void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLExceptio
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setQueryTimeOut";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setQueryTimeOut",mID,_par0,true);
}
//------------------------------------------------------------------------------
@@ -838,20 +521,9 @@ void java_sql_Statement_Base::setEscapeProcessing(sal_Bool _par0) throw(SQLExcep
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
m_bEscapeProcessing = _par0;
- if( t.pEnv )
- {
- createStatement( t.pEnv );
- static const char * cSignature = "(Z)V";
- static const char * cMethodName = "setEscapeProcessing";
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
- }
- }
+ createStatement( t.pEnv );
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setEscapeProcessing",mID,_par0,true);
}
//------------------------------------------------------------------------------
@@ -860,21 +532,9 @@ void java_sql_Statement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, Ru
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setMaxRows";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setMaxRows",mID,_par0,true);
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -884,15 +544,7 @@ void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQL
m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_CONCURRENCY, (sal_Int32)_par0 );
m_nResultSetConcurrency = _par0;
- if( object )
- {
- SDBThreadAttach t;
- if( t.pEnv )
- {
- t.pEnv->DeleteGlobalRef( object );
- object = NULL;
- }
- }
+ clearObject();
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -902,15 +554,7 @@ void java_sql_Statement_Base::setResultSetType(sal_Int32 _par0) throw(SQLExcepti
m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_TYPE, (sal_Int32)_par0 );
m_nResultSetType = _par0;
- if( object )
- {
- SDBThreadAttach t;
- if( t.pEnv )
- {
- t.pEnv->DeleteGlobalRef( object );
- object = NULL;
- }
- }
+ clearObject();
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -919,22 +563,9 @@ void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLExcept
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_DIRECTION, (sal_Int32)_par0 );
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setFetchDirection";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
-
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true);
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -944,22 +575,9 @@ void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException,
m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_SIZE, (sal_Int32)_par0 );
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setFetchSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
-
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchSize",mID,_par0,true);
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
@@ -967,22 +585,9 @@ void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLExceptio
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setMaxFieldSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
-
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setMaxFieldSize",mID,_par0,true);
}
//------------------------------------------------------------------------------
void java_sql_Statement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
@@ -990,24 +595,10 @@ void java_sql_Statement_Base::setCursorName(const ::rtl::OUString &_par0) throw(
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)V";
- static const char * cMethodName = "setCursorName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,_par0);
- t.pEnv->CallVoidMethod( object, mID,str);
- isExceptionOccured(t.pEnv,sal_True);
-
- t.pEnv->DeleteLocalRef(str);
- isExceptionOccured(t.pEnv,sal_True);
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("setCursorName",mID,_par0);
} //t.pEnv
}
@@ -1161,27 +752,14 @@ jclass java_sql_Statement::theClass = 0;
java_sql_Statement::~java_sql_Statement()
{}
-jclass java_sql_Statement::getMyClass()
+jclass java_sql_Statement::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Statement"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Statement");
return theClass;
}
-void java_sql_Statement::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
// -----------------------------------------------------------------------------
void java_sql_Statement::createStatement(JNIEnv* _pEnv)
{
@@ -1194,7 +772,7 @@ void java_sql_Statement::createStatement(JNIEnv* _pEnv)
static const char * cMethodName = "createStatement";
// Java-Call absetzen
jobject out = NULL;
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
if( mID ){
diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx
index 6e550134a90c..6f4e78550dc0 100644
--- a/connectivity/source/drivers/jdbc/Object.cxx
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -45,7 +45,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include "resource/jdbc_log.hrc"
-
+#include <rtl/logfile.hxx>
#include <comphelper/logging.hxx>
#include <memory>
@@ -112,17 +112,10 @@ void SDBThreadAttach::releaseRef()
// statische Variablen der Klasse:
jclass java_lang_Object::theClass = 0;
-jclass java_lang_Object::getMyClass()
+jclass java_lang_Object::getMyClass() const
{
if( !theClass )
- {
- SDBThreadAttach t;
-
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/lang/Object" );
- theClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- }
+ theClass = findMyClass("java/lang/Object");
return theClass;
}
// der eigentliche Konstruktor
@@ -146,9 +139,7 @@ java_lang_Object::~java_lang_Object()
if( object )
{
SDBThreadAttach t;
- if( t.pEnv )
- t.pEnv->DeleteGlobalRef( object );
- object = NULL;
+ clearObject(*t.pEnv);
}
SDBThreadAttach::releaseRef();
}
@@ -166,65 +157,30 @@ void java_lang_Object::clearObject()
if( object )
{
SDBThreadAttach t;
- if( t.pEnv )
- t.pEnv->DeleteGlobalRef( object );
- object = NULL;
+ clearObject(*t.pEnv);
}
}
// der protected-Konstruktor fuer abgeleitete Klassen
void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj )
{
OSL_ENSURE( myObj, "object in c++ -> Java Wrapper" );
- if( pXEnv && myObj )
+ if( myObj )
object = pXEnv->NewGlobalRef( myObj );
}
java_lang_Class * java_lang_Object::getClass()
{
- jobject out;
SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/Class;";
- static const char * cMethodName = "getClass";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallObjectMethodA( object, mID, NULL );
- ThrowSQLException(t.pEnv,NULL);
- return new java_lang_Class( t.pEnv, out );
- } //mID
- } //pEnv
- return NULL;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getClass","()Ljava/lang/Class;", mID);
+ return out ? new java_lang_Class( t.pEnv, out ) : NULL;
}
::rtl::OUString java_lang_Object::toString() const
{
-
- SDBThreadAttach t;
- ::rtl::OUString aStr;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "toString";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,NULL);
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //pEnv
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("toString",mID);
}
// --------------------------------------------------------------------------------
@@ -240,14 +196,14 @@ namespace
_pEnvironment->ExceptionClear();
// we have to clear the exception here because we want to handle it itself
- if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::getMyClass() ) )
+ if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::st_getMyClass() ) )
{
::std::auto_ptr< java_sql_SQLException_BASE > pException( new java_sql_SQLException_BASE( _pEnvironment, jThrow ) );
_out_rException = SQLException( pException->getMessage(), _rxContext,
pException->getSQLState(), pException->getErrorCode(), Any() );
return true;
}
- else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::getMyClass() ) )
+ else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::st_getMyClass() ) )
{
::std::auto_ptr< java_lang_Throwable > pThrow( new java_lang_Throwable( _pEnvironment, jThrow ) );
::rtl::OUString sMessage = pThrow->getMessage();
@@ -283,5 +239,204 @@ void java_lang_Object::ThrowSQLException( JNIEnv* _pEnvironment, const Reference
if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) )
throw aException;
}
+// -----------------------------------------------------------------------------
+void java_lang_Object::obtainMethodId(JNIEnv* _pEnv,const char* _pMethodName, const char* _pSignature,jmethodID& _inout_MethodID) const
+{
+ if ( !_inout_MethodID )
+ {
+ _inout_MethodID = _pEnv->GetMethodID( getMyClass(), _pMethodName, _pSignature );
+ OSL_ENSURE( _inout_MethodID, _pSignature );
+ if ( !_inout_MethodID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+}
+// -----------------------------------------------------------------------------
+sal_Bool java_lang_Object::callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ jboolean out( sal_False );
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()Z", _inout_MethodID);
+ // call method
+ out = t.pEnv->CallBooleanMethod( object, _inout_MethodID );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return out;
+}
+// -----------------------------------------------------------------------------
+sal_Bool java_lang_Object::callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const
+{
+ jboolean out( sal_False );
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethodWithIntArg: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)Z", _inout_MethodID);
+ // call method
+ out = t.pEnv->CallBooleanMethod( object, _inout_MethodID, _nArgument );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return out;
+}
+// -------------------------------------------------------------------------
+jobject java_lang_Object::callResultSetMethod( JNIEnv& _rEnv,const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ // call method
+ jobject out = callObjectMethod(&_rEnv,_pMethodName,"()Ljava/sql/ResultSet;", _inout_MethodID);
+ return out;
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()I", _inout_MethodID);
+
+ // call method
+ jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+
+ return (sal_Int32)out;
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)I", _inout_MethodID);
+ // call method
+ jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return (sal_Int32)out;
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()V", _inout_MethodID);
+
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID );
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)V", _inout_MethodID);
+
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID);
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_lang_Object::callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" );
+
+ // call method
+ jstring out = (jstring)callObjectMethod(t.pEnv,_pMethodName,"()Ljava/lang/String;", _inout_MethodID);
+ return JavaString2String( t.pEnv, out );
+}
+// -----------------------------------------------------------------------------
+jobject java_lang_Object::callObjectMethod( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID ) const
+{
+ // obtain method ID
+ obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ // call method
+ jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID);
+ ThrowSQLException( _pEnv, NULL );
+ return out;
+}
+
+// -----------------------------------------------------------------------------
+jobject java_lang_Object::callObjectMethodWithIntArg( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
+{
+ obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ // call method
+ jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID,_nArgument );
+ ThrowSQLException( _pEnv, NULL );
+ return out;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_lang_Object::callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" );
+ jstring out = (jstring)callObjectMethodWithIntArg(t.pEnv,_pMethodName,"(I)Ljava/lang/String;",_inout_MethodID,_nArgument);
+ return JavaString2String( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID);
+
+ jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument);
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID , str);
+ t.pEnv->DeleteLocalRef(str);
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethodWithStringArg: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)I", _inout_MethodID);
+
+ //TODO: Check if the code below is needed
+ //jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ //{
+ // jdbc::ContextClassLoaderScope ccl( t.env(),
+ // m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ // m_aLogger,
+ // *this
+ // );
+
+ jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument);
+ // call method
+ jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str);
+ t.pEnv->DeleteLocalRef(str);
+ ThrowSQLException( t.pEnv, NULL );
+ return (sal_Int32)out;
+}
+// -----------------------------------------------------------------------------
+jclass java_lang_Object::findMyClass(const char* _pClassName)
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ SDBThreadAttach t;
+ jclass tempClass = t.pEnv->FindClass(_pClassName); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
+ if(!tempClass)
+ {
+ t.pEnv->ExceptionDescribe();
+ t.pEnv->ExceptionClear();
+ }
+ jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
+ t.pEnv->DeleteLocalRef( tempClass );
+ return globClass;
+}
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 281e29fd5919..beef4792ba1e 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -73,33 +73,15 @@ java_sql_PreparedStatement::~java_sql_PreparedStatement()
}
// -----------------------------------------------------------------------------
-jclass java_sql_PreparedStatement::getMyClass()
+jclass java_sql_PreparedStatement::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
if( !theClass )
- {
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- jclass tempClass = t.pEnv->FindClass("java/sql/PreparedStatement"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
- }
+ theClass = findMyClass("java/sql/PreparedStatement");
return theClass;
}
// -------------------------------------------------------------------------
-void java_sql_PreparedStatement::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// -------------------------------------------------------------------------
-
::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
{
::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType);
@@ -127,24 +109,8 @@ sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "execute";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "execute", mID );
}
// -------------------------------------------------------------------------
@@ -153,25 +119,8 @@ sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::su
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE );
-
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "executeUpdate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return impl_getProperty("executeUpdate",mID);
}
// -------------------------------------------------------------------------
@@ -182,21 +131,18 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
m_aLogger.log( LogLevel::FINER, STR_LOG_STRING_PARAMETER, parameterIndex, x );
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){ // temporaere Variable initialisieren
+ { // temporaere Variable initialisieren
createStatement(t.pEnv);
static const char * cSignature = "(ILjava/lang/String;)V";
static const char * cMethodName = "setString";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring str = convertwchar_tToJavaString(t.pEnv,x);
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,str);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(str);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jstring str = convertwchar_tToJavaString(t.pEnv,x);
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,str);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(str);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -213,23 +159,10 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/ResultSet;";
- static const char * cMethodName = "executeQuery";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callResultSetMethod(t.env(),"executeQuery",mID);
return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this);
}
@@ -242,21 +175,9 @@ void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex,
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(IZ)V";
- static const char * cMethodName = "setBoolean";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setBoolean", "(IZ)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -267,21 +188,9 @@ void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(IB)V";
- static const char * cMethodName = "setByte";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setByte", "(IB)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -292,26 +201,10 @@ void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, con
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/sql/Date;)V";
- static const char * cMethodName = "setDate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[1];
- // Parameter konvertieren
- java_sql_Date aT(x);
- args[0].l = aT.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[0].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ java_sql_Date aT(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("setDate", "(ILjava/sql/Date;)V", mID, parameterIndex, aT.getJavaObject());
}
// -------------------------------------------------------------------------
@@ -323,27 +216,10 @@ void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, con
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/sql/Time;)V";
- static const char * cMethodName = "setTime";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[2];
- // Parameter konvertieren
- args[0].i = (sal_Int32)parameterIndex;
- java_sql_Time aT(x);
- args[1].l = aT.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[1].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ java_sql_Time aT(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("setTime", "(ILjava/sql/Time;)V", mID, parameterIndex, aT.getJavaObject());
}
// -------------------------------------------------------------------------
@@ -354,26 +230,10 @@ void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/sql/Timestamp;)V";
- static const char * cMethodName = "setTimestamp";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jvalue args[1];
- // Parameter konvertieren
- java_sql_Timestamp aT(x);
- args[0].l = aT.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[0].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ java_sql_Timestamp aD(x);
+ callVoidMethod("setTimestamp", "(ILjava/sql/Timestamp;)V", mID, parameterIndex, aD.getJavaObject());
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
@@ -383,21 +243,9 @@ void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, d
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(ID)V";
- static const char * cMethodName = "setDouble";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setDouble", "(ID)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -408,21 +256,9 @@ void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, fl
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(IF)V";
- static const char * cMethodName = "setFloat";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setFloat", "(IF)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -433,21 +269,9 @@ void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(II)V";
- static const char * cMethodName = "setInt";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setInt", "(II)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -458,21 +282,9 @@ void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(IJ)V";
- static const char * cMethodName = "setLong";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setLong", "(IJ)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -483,21 +295,9 @@ void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(II)V";
- static const char * cMethodName = "setNull";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setNull", "(II)V", mID, parameterIndex, sqlType);
}
// -------------------------------------------------------------------------
@@ -532,17 +332,16 @@ void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameter
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
// temporaere Variable initialisieren
static const char * cSignature = "(ILjava/lang/Object;II)V";
static const char * cMethodName = "setObject";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ {
jobject obj = NULL;
double nTemp = 0.0;
switch(targetSqlType)
@@ -592,22 +391,9 @@ void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterInde
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/lang/Object;)V";
- static const char * cMethodName = "setObject";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,0);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod<jobject>("setObject", "(ILjava/lang/Object;)V", mID, parameterIndex, NULL);
}
// -------------------------------------------------------------------------
@@ -631,21 +417,9 @@ void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sa
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "(IS)V";
- static const char * cMethodName = "setShort";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setShort", "(IS)V", mID, parameterIndex, x);
}
// -------------------------------------------------------------------------
@@ -656,24 +430,20 @@ void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, co
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
// temporaere Variable initialisieren
static const char * cSignature = "(I[B)V";
static const char * cMethodName = "setBytes";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength());
- t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray());
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray);
- t.pEnv->DeleteLocalRef(pByteArray);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength());
+ t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray());
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray);
+ t.pEnv->DeleteLocalRef(pByteArray);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -685,48 +455,43 @@ void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 paramete
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
// temporaere Variable initialisieren
static const char * cSignature = "(ILjava/io/InputStream;I)V";
static const char * cMethodName = "setCharacterStream";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- Sequence< sal_Int8 > aSeq;
- if ( x.is() )
- x->readBytes( aSeq, length );
- sal_Int32 actualLength = aSeq.getLength();
-
- jvalue args2[3];
- jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength );
- t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
- args2[0].l = pByteArray;
- args2[1].i = 0;
- args2[2].i = actualLength;
- // temporaere Variable initialisieren
- const char * cSignatureStream = "([BII)V";
- // Java-Call absetzen
- jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream");
- static jmethodID mID2 = NULL;
- if ( !mID2 )
- mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
- jobject tempObj = NULL;
- if(mID2)
- tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
-
- t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength);
- // und aufraeumen
- t.pEnv->DeleteLocalRef(pByteArray);
- t.pEnv->DeleteLocalRef(tempObj);
- t.pEnv->DeleteLocalRef(aClass);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
-
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ Sequence< sal_Int8 > aSeq;
+ if ( x.is() )
+ x->readBytes( aSeq, length );
+ sal_Int32 actualLength = aSeq.getLength();
+
+ jvalue args2[3];
+ jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength );
+ t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
+ args2[0].l = pByteArray;
+ args2[1].i = 0;
+ args2[2].i = actualLength;
+ // temporaere Variable initialisieren
+ const char * cSignatureStream = "([BII)V";
+ // Java-Call absetzen
+ jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream");
+ static jmethodID mID2 = NULL;
+ if ( !mID2 )
+ mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
+ jobject tempObj = NULL;
+ if(mID2)
+ tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
+
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(pByteArray);
+ t.pEnv->DeleteLocalRef(tempObj);
+ t.pEnv->DeleteLocalRef(aClass);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -738,16 +503,14 @@ void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIn
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
// temporaere Variable initialisieren
static const char * cSignature = "(ILjava/io/InputStream;I)V";
static const char * cMethodName = "setBinaryStream";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
{
Sequence< sal_Int8 > aSeq;
if ( x.is() )
@@ -789,20 +552,11 @@ void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t;
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearParameters";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethod("clearParameters",mID);
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -811,20 +565,10 @@ void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star:
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethod("clearBatch",mID);
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -834,19 +578,10 @@ void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sd
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "addBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
+ static jmethodID mID(NULL);
+ callVoidMethod("addBatch",mID);
} //t.pEnv
}
// -------------------------------------------------------------------------
@@ -857,27 +592,16 @@ void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sd
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
::com::sun::star::uno::Sequence< sal_Int32 > aSeq;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()[I";
- static const char * cMethodName = "executeBatch";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jintArray out = (jintArray)t.pEnv->CallObjectMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- if(out)
- {
- jboolean p = sal_False;
- aSeq.realloc(t.pEnv->GetArrayLength(out));
- memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
- t.pEnv->DeleteLocalRef(out);
- }
- } //mID
- } //t.pEnv
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID);
+ if(out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
return aSeq;
}
// -------------------------------------------------------------------------
@@ -885,28 +609,14 @@ void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sd
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- createStatement(t.pEnv);
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/ResultSetMetaData;";
- static const char * cMethodName = "getMetaData";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID);
return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection );
}
// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
void SAL_CALL java_sql_PreparedStatement::acquire() throw()
{
OStatement_BASE2::acquire();
@@ -932,7 +642,7 @@ void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv)
args[0].l = convertwchar_tToJavaString(_pEnv,m_sSqlStatement);
// Java-Call absetzen
jobject out = NULL;
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
if( mID )
diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx
index cf3f6c386bbb..7460e519f8ca 100644
--- a/connectivity/source/drivers/jdbc/Reader.cxx
+++ b/connectivity/source/drivers/jdbc/Reader.cxx
@@ -51,28 +51,14 @@ java_io_Reader::~java_io_Reader()
SDBThreadAttach::releaseRef();
}
-jclass java_io_Reader::getMyClass()
+jclass java_io_Reader::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/io/Reader" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/io/Reader");
return theClass;
}
-void java_io_Reader::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
return readBytes(aData,nMaxBytesToRead);
@@ -80,62 +66,31 @@ sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequenc
void SAL_CALL java_io_Reader::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "skip";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallIntMethod( object, mID,nBytesToSkip);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callIntMethodWithIntArg("skip",mID,nBytesToSkip);
}
sal_Int32 SAL_CALL java_io_Reader::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
jboolean out(sal_False);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
static const char * cSignature = "()Z";
static const char * cMethodName = "available";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallBooleanMethod( object, mID);
+ ThrowSQLException(t.pEnv,*this);
} //t.pEnv
return out;
}
void SAL_CALL java_io_Reader::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- t.pEnv->CallVoidMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
}
// -----------------------------------------------------
sal_Int32 SAL_CALL java_io_Reader::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
@@ -143,28 +98,24 @@ sal_Int32 SAL_CALL java_io_Reader::readBytes( ::com::sun::star::uno::Sequence< s
OSL_ENSURE(aData.getLength() < nBytesToRead," Sequence is smaller than BytesToRead");
jint out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+
{
jcharArray pCharArray = t.pEnv->NewCharArray(nBytesToRead);
static const char * cSignature = "([CII)I";
static const char * cMethodName = "read";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nBytesToRead );
+ if ( !out )
+ ThrowSQLException(t.pEnv,*this);
+ if(out > 0)
{
- out = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nBytesToRead );
- if ( !out )
- ThrowSQLException(t.pEnv,*this);
- if(out > 0)
- {
- jboolean p = sal_False;
- if(aData.getLength() < out)
- aData.realloc(out-aData.getLength());
+ jboolean p = sal_False;
+ if(aData.getLength() < out)
+ aData.realloc(out-aData.getLength());
- memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out);
- }
+ memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out);
}
t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
} //t.pEnv
diff --git a/connectivity/source/drivers/jdbc/Ref.cxx b/connectivity/source/drivers/jdbc/Ref.cxx
index d522ff4e22ba..dd91d1bd4aec 100644
--- a/connectivity/source/drivers/jdbc/Ref.cxx
+++ b/connectivity/source/drivers/jdbc/Ref.cxx
@@ -48,48 +48,17 @@ java_sql_Ref::~java_sql_Ref()
SDBThreadAttach::releaseRef();
}
-jclass java_sql_Ref::getMyClass()
+jclass java_sql_Ref::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/sql/Ref" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Ref");
return theClass;
}
-void java_sql_Ref::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
::rtl::OUString SAL_CALL java_sql_Ref::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getBaseTypeName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,*this);
- aStr = JavaString2String(t.pEnv,out);
- // und aufraeumen
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getBaseTypeName",mID);
}
diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx
index 23270f3ea3ac..9b8de989bb51 100644
--- a/connectivity/source/drivers/jdbc/ResultSet.cxx
+++ b/connectivity/source/drivers/jdbc/ResultSet.cxx
@@ -86,10 +86,10 @@ java_sql_ResultSet::java_sql_ResultSet( JNIEnv * pEnv, jobject myObj, const java
osl_incrementInterlockedCount(&m_refCount);
if ( pStmt )
m_xStatement = *pStmt;
+
osl_decrementInterlockedCount(&m_refCount);
}
// -----------------------------------------------------------------------------
-
java_sql_ResultSet::~java_sql_ResultSet()
{
if ( !java_sql_ResultSet_BASE::rBHelper.bDisposed && !java_sql_ResultSet_BASE::rBHelper.bInDispose )
@@ -100,29 +100,15 @@ java_sql_ResultSet::~java_sql_ResultSet()
}
}
-jclass java_sql_ResultSet::getMyClass()
+jclass java_sql_ResultSet::getMyClass() const
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMyClass" );
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/ResultSet"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/ResultSet");
return theClass;
}
-void java_sql_ResultSet::saveClassRef( jclass pClass )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::saveClassRef" );
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
// -------------------------------------------------------------------------
void java_sql_ResultSet::disposing(void)
{
@@ -134,22 +120,10 @@ void java_sql_ResultSet::disposing(void)
if( object )
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "close";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- clearObject(*t.pEnv);
- }
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+ clearObject(*t.pEnv);
+ }
SDBThreadAttach::releaseRef();
}
@@ -175,52 +149,17 @@ void java_sql_ResultSet::disposing(void)
sal_Int32 SAL_CALL java_sql_ResultSet::findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::findColumn" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(Ljava/lang/String;)I";
- static const char * cMethodName = "findColumn";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- // Parameter konvertieren
- jstring str = convertwchar_tToJavaString(t.pEnv,columnName);
- out = t.pEnv->CallIntMethod( object, mID, str );
- // und aufraeumen
- t.pEnv->DeleteLocalRef(str);
-
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethodWithStringArg("findColumn",mID,columnName);
}
// -------------------------------------------------------------------------
-
-
Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBinaryStream" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/io/InputStream;";
- static const char * cMethodName = "getBinaryStream";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBinaryStream","(I)Ljava/io/InputStream;", mID, columnIndex);
+
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_io_InputStream( t.pEnv, out );
}
@@ -228,23 +167,10 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::get
Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCharacterStream" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/io/Reader;";
- static const char * cMethodName = "getCharacterStream";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getCharacterStream","(I)Ljava/io/Reader;", mID, columnIndex);
+
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_io_Reader( t.pEnv, out );
}
@@ -253,77 +179,34 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::get
sal_Bool SAL_CALL java_sql_ResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBoolean" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "getBoolean";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex );
}
// -------------------------------------------------------------------------
sal_Int8 SAL_CALL java_sql_ResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getByte" );
- jbyte out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)B";
- static const char * cMethodName = "getByte";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallByteMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod;
+ return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex);
}
// -------------------------------------------------------------------------
Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBytes" );
- Sequence< sal_Int8 > aSeq;
+ Sequence< sal_Int8 > aSeq;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
+ static jmethodID mID(NULL);
+ jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex);
+ if (out)
{
- static const char * cSignature = "(I)[B";
- static const char * cMethodName = "getBytes";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- if (out)
- {
- jboolean p = sal_False;
- aSeq.realloc(t.pEnv->GetArrayLength(out));
- memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
- t.pEnv->DeleteLocalRef(out);
- }
- // und aufraeumen
- } //mID
- } //t.pEnv
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
return aSeq;
}
// -------------------------------------------------------------------------
@@ -331,23 +214,9 @@ Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnInde
::com::sun::star::util::Date SAL_CALL java_sql_ResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDate" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Date;";
- static const char * cMethodName = "getDate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out ? static_cast <com::sun::star::util::Date> (java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date();
}
@@ -356,141 +225,52 @@ Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnInde
double SAL_CALL java_sql_ResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDouble" );
- jdouble out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)D";
- static const char * cMethodName = "getDouble";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallDoubleMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ jdouble (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod;
+ return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex);
}
// -------------------------------------------------------------------------
float SAL_CALL java_sql_ResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFloat" );
- jfloat out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)F";
- static const char * cMethodName = "getFloat";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallFloatMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod;
+ return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInt" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getInt";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getInt",mID,columnIndex);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSet::getRow( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRow" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getRow",mID);
}
// -------------------------------------------------------------------------
sal_Int64 SAL_CALL java_sql_ResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getLong" );
- jlong out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)J";
- static const char * cMethodName = "getLong";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallLongMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod;
+ return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)L",mID,columnIndex);
}
// -------------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_ResultSet::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMetaData" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/ResultSetMetaData;";
- static const char * cMethodName = "getMetaData";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID);
return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection );
}
@@ -498,22 +278,10 @@ sal_Int64 SAL_CALL java_sql_ResultSet::getLong( sal_Int32 columnIndex ) throw(SQ
Reference< XArray > SAL_CALL java_sql_ResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getArray" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Array;";
- static const char * cMethodName = "getArray";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex);
+
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Array( t.pEnv, out );
}
@@ -522,22 +290,9 @@ Reference< XArray > SAL_CALL java_sql_ResultSet::getArray( sal_Int32 columnIndex
Reference< XClob > SAL_CALL java_sql_ResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getClob" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Clob;";
- static const char * cMethodName = "getClob";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Clob( t.pEnv, out );
}
@@ -545,22 +300,9 @@ Reference< XClob > SAL_CALL java_sql_ResultSet::getClob( sal_Int32 columnIndex )
Reference< XBlob > SAL_CALL java_sql_ResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBlob" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Blob;";
- static const char * cMethodName = "getBlob";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Blob( t.pEnv, out );
}
@@ -569,22 +311,10 @@ Reference< XBlob > SAL_CALL java_sql_ResultSet::getBlob( sal_Int32 columnIndex )
Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRef" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Ref;";
- static const char * cMethodName = "getRef";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex);
+
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? 0 : new java_sql_Ref( t.pEnv, out );
}
@@ -595,24 +325,27 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" );
jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ {
jvalue args[2];
// Parameter konvertieren
args[0].i = (sal_Int32)columnIndex;
args[1].l = convertTypeMapToJavaMap(t.pEnv,typeMap);
// temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/Object;";
- static const char * cMethodName = "getObject";
// Java-Call absetzen
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
+ {
+ static const char * cSignature = "(I)Ljava/lang/Object;";
+ static const char * cMethodName = "getObject";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
out = t.pEnv->CallObjectMethodA( object, mID, args);
t.pEnv->DeleteLocalRef((jstring)args[1].l);
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
// und aufraeumen
- } //mID
+
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out );
@@ -622,23 +355,9 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen
sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getShort" );
- jshort out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)S";
- static const char * cMethodName = "getShort";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallShortMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int16)out;
+ static jmethodID mID(NULL);
+ jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod;
+ return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex);
}
// -------------------------------------------------------------------------
@@ -646,25 +365,8 @@ sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(S
::rtl::OUString SAL_CALL java_sql_ResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getString" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getString";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, columnIndex );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- // und aufraeumen
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getString",mID,columnIndex);
}
// -------------------------------------------------------------------------
@@ -672,23 +374,9 @@ sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(S
::com::sun::star::util::Time SAL_CALL java_sql_ResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTime" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Time;";
- static const char * cMethodName = "getTime";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time();
}
@@ -698,22 +386,9 @@ sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(S
::com::sun::star::util::DateTime SAL_CALL java_sql_ResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTimestamp" );
- jobject out(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/sql/Timestamp;";
- static const char * cMethodName = "getTimestamp";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID, columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime();
}
@@ -722,112 +397,36 @@ sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(S
sal_Bool SAL_CALL java_sql_ResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isAfterLast" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isAfterLast";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isAfterLast", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::isFirst( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isFirst" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isFirst";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isFirst", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::isLast( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isLast" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isLast";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isLast", mID );
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::beforeFirst" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "isBeforeFirst";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("beforeFirst",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::afterLast( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::afterLast" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "afterLast";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("afterLast",mID);
}
// -------------------------------------------------------------------------
@@ -841,113 +440,37 @@ void SAL_CALL java_sql_ResultSet::close( ) throw(::com::sun::star::sdbc::SQLExc
sal_Bool SAL_CALL java_sql_ResultSet::first( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::first" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "first";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "first", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::last( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::last" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "last";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "last", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::absolute" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "absolute";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID,row);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "absolute", mID,row );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::relative" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "relative";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID,row);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "relative", mID,row );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::previous( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::previous" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "previous";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "previous", mID );
}
// -------------------------------------------------------------------------
Reference< XInterface > SAL_CALL java_sql_ResultSet::getStatement( ) throw(SQLException, RuntimeException)
@@ -960,200 +483,70 @@ Reference< XInterface > SAL_CALL java_sql_ResultSet::getStatement( ) throw(SQLE
sal_Bool SAL_CALL java_sql_ResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowDeleted" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "rowDeleted";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowDeleted", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::rowInserted( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowInserted" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "rowInserted";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowInserted", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowUpdated" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "rowUpdated";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowUpdated", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isBeforeFirst" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "isBeforeFirst";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isBeforeFirst", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::next( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::next" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
-
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "next";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "next", mID );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSet::wasNull( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::wasNull" );
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Z";
- static const char * cMethodName = "wasNull";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "wasNull", mID );
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::cancel( ) throw(::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancel" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "cancel";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("cancel",mID);
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::clearWarnings" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "clearWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
}
// -------------------------------------------------------------------------
::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getWarnings" );
- jobject out(NULL);
SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/SQLWarning;";
- static const char * cMethodName = "getWarnings";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
if( out )
{
@@ -1170,247 +563,91 @@ void SAL_CALL java_sql_ResultSet::clearWarnings( ) throw(::com::sun::star::sdbc
void SAL_CALL java_sql_ResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::insertRow" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "insertRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("insertRow",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateRow" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "updateRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateRow",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::deleteRow" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "deleteRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("deleteRow",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancelRowUpdates" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "cancelRowUpdates";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("cancelRowUpdates",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToInsertRow" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "moveToInsertRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("moveToInsertRow",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToCurrentRow" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "moveToCurrentRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("moveToCurrentRow",mID);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateNull" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "updateNull";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("updateNull",mID,columnIndex);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBoolean" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(IZ)V";
- static const char * cMethodName = "updateBoolean";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateBoolean", "(IZ)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateByte" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(IB)V";
- static const char * cMethodName = "updateByte";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateByte", "(IB)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateShort" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(IS)V";
- static const char * cMethodName = "updateShort";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateShort", "(IS)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateInt" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(II)V";
- static const char * cMethodName = "updateInt";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateInt", "(II)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateLong" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(IJ)V";
- static const char * cMethodName = "updateLong";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateLong", "(IJ)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
@@ -1418,42 +655,16 @@ void SAL_CALL java_sql_ResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x
void SAL_CALL java_sql_ResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateFloat" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(IF)V";
- static const char * cMethodName = "updateFloat";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateFloat", "(IF)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDouble" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(ID)V";
- static const char * cMethodName = "updateDouble";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,columnIndex,x);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ static jmethodID mID(NULL);
+ callVoidMethod("updateDouble", "(ID)V", mID, columnIndex, x);
}
// -------------------------------------------------------------------------
@@ -1461,17 +672,20 @@ void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::r
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateString" );
SDBThreadAttach t;
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/lang/String;)V";
- static const char * cMethodName = "updateString";
// Java-Call absetzen
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ {
+ static const char * cSignature = "(ILjava/lang/String;)V";
+ static const char * cMethodName = "updateString";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
{
// Parameter konvertieren
jstring str = convertwchar_tToJavaString(t.pEnv,x);
@@ -1487,16 +701,19 @@ void SAL_CALL java_sql_ResultSet::updateBytes( sal_Int32 columnIndex, const ::co
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBytes" );
SDBThreadAttach t;
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
- static const char * cSignature = "(I[B)V";
- static const char * cMethodName = "updateBytes";
// Java-Call absetzen
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ {
+ static const char * cSignature = "(I[B)V";
+ static const char * cMethodName = "updateBytes";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
{
jbyteArray aArray = t.pEnv->NewByteArray(x.getLength());
t.pEnv->SetByteArrayRegion(aArray,0,x.getLength(),(jbyte*)x.getConstArray());
@@ -1512,79 +729,27 @@ void SAL_CALL java_sql_ResultSet::updateBytes( sal_Int32 columnIndex, const ::co
void SAL_CALL java_sql_ResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDate" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/sql/Date;)V";
- static const char * cMethodName = "updateDate";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jvalue args[1];
- // Parameter konvertieren
- java_sql_Date aD(x);
- args[0].l = aD.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ java_sql_Date aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateDate", "(ILjava/sql/Date;)V", mID, columnIndex, aD.getJavaObject());
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTime" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/sql/Time;)V";
- static const char * cMethodName = "updateTime";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jvalue args[1];
- // Parameter konvertieren
- java_sql_Time aD(x);
- args[0].l = aD.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ java_sql_Time aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateTime", "(ILjava/sql/Time;)V", mID, columnIndex, aD.getJavaObject());
}
// -------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTimestamp" );
- SDBThreadAttach t;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "(I;Ljava/sql/Timestamp;)V";
- static const char * cMethodName = "updateTimestamp";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jvalue args[1];
- java_sql_Timestamp aD(x);
- // Parameter konvertieren
- args[0].l = aD.getJavaObject();
- t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- }
- }
+ java_sql_Timestamp aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateTimestamp", "(ILjava/sql/Timestamp;)V", mID, columnIndex, aD.getJavaObject());
}
// -------------------------------------------------------------------------
@@ -1622,17 +787,20 @@ void SAL_CALL java_sql_ResultSet::updateNumericObject( sal_Int32 columnIndex, co
try
{
SDBThreadAttach t;
- if( t.pEnv )
+
{
// temporaere Variable initialisieren
- static const char * cSignature = "(ILjava/lang/Object;I)V";
- static const char * cMethodName = "updateObject";
// Java-Call absetzen
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
+ {
+ static const char * cSignature = "(ILjava/lang/Object;I)V";
+ static const char * cMethodName = "updateObject";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
{
// Parameter konvertieren
double nTemp = 0.0;
@@ -1658,182 +826,58 @@ void SAL_CALL java_sql_ResultSet::updateNumericObject( sal_Int32 columnIndex, co
sal_Int32 java_sql_ResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetConcurrency" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getConcurrency";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getConcurrency",mID,true);
}
-// -------------------------------------------------------------------------
//------------------------------------------------------------------------------
sal_Int32 java_sql_ResultSet::getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetType" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getType";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getType",mID,true);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_ResultSet::getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchDirection" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getFetchDirection";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getFetchDirection",mID,true);
}
//------------------------------------------------------------------------------
sal_Int32 java_sql_ResultSet::getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchSize" );
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getFetchSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getFetchSize",mID,true);
}
//------------------------------------------------------------------------------
::rtl::OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCursorName" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getCursorName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *const_cast< java_sql_ResultSet* >( this ) );
- aStr = JavaString2String(t.pEnv,out);
- }
- }
-
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getCursorName",mID);
}
//------------------------------------------------------------------------------
void java_sql_ResultSet::setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchDirection" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setFetchDirection";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
-
- } //mID
- } //t.pEnv
-
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true);
}
//------------------------------------------------------------------------------
void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::refreshRow" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv )
- {
- // temporaere Variable initialisieren
- static const char * cSignature = "()V";
- static const char * cMethodName = "refreshRow";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethod("refreshRow",mID);
}
//------------------------------------------------------------------------------
void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchSize" );
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setFetchSize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID,_par0);
- // special case here most JDBC 1.x doesn't support this feature so we just clear the exception when they occured
- isExceptionOccured(t.pEnv,sal_True);
- } //mID
- } //t.pEnv
-
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchSize",mID,_par0,true);
}
// -------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* java_sql_ResultSet::createArrayHelper( ) const
@@ -1853,7 +897,7 @@ void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::s
// -------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & java_sql_ResultSet::getInfoHelper()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInfoHelper" );
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInfoHelper" );
return *const_cast<java_sql_ResultSet*>(this)->getArrayHelper();
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx
index 12bc7a3b1c3b..3b61f31826c2 100644
--- a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx
+++ b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx
@@ -33,6 +33,8 @@
#include "java/sql/ResultSetMetaData.hxx"
#include "java/sql/Connection.hxx"
#include "java/tools.hxx"
+#include <rtl/logfile.hxx>
+
using namespace connectivity;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
@@ -40,6 +42,8 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
+
+#define NULLABLE_UNDEFINED 99
//**************************************************************
//************ Class: java.sql.ResultSetMetaData
//**************************************************************
@@ -49,7 +53,9 @@ java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject m
:java_lang_Object( pEnv, myObj )
,m_aLogger( _rResultSetLogger )
,m_pConnection( &_rCon )
+ ,m_nColumnCount(-1)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::java_sql_ResultSetMetaData" );
SDBThreadAttach::addRef();
}
java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData()
@@ -57,499 +63,179 @@ java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData()
SDBThreadAttach::releaseRef();
}
-jclass java_sql_ResultSetMetaData::getMyClass()
+jclass java_sql_ResultSetMetaData::getMyClass() const
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getMyClass" );
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/ResultSetMetaData"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/ResultSetMetaData");
return theClass;
}
// -------------------------------------------------------------------------
-void java_sql_ResultSetMetaData::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// -------------------------------------------------------------------------
-
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getColumnDisplaySize";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID,column);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnDisplaySize" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getColumnDisplaySize",mID,column);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getColumnType";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID,column);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnType" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getColumnType",mID,column);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnCount" );
+ if ( m_nColumnCount == -1 )
+ {
+ static jmethodID mID(NULL);
+ m_nColumnCount = callIntMethod("getColumnCount",mID);
+ } // if ( m_nColumnCount == -1 )
+ return m_nColumnCount;
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getColumnCount";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isCaseSensitive";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCaseSensitive" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column );
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getSchemaName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getSchemaName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getSchemaName",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getColumnName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnName",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getTableName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getTableName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getTableName",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getCatalogName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getCatalogName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getCatalogName",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getColumnTypeName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnTypeName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnTypeName",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getColumnLabel";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnLabel" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnLabel",mID,column);
}
// -------------------------------------------------------------------------
::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- ::rtl::OUString aStr;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Ljava/lang/String;";
- static const char * cMethodName = "getColumnClassName";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- aStr = JavaString2String(t.pEnv,out);
- }
-
- // und aufraeumen
- } //t.pEnv
- return aStr;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnServiceName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnClassName",mID,column);
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCurrency" );
if ( m_pConnection->isIgnoreCurrencyEnabled() )
return sal_False;
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isCurrency";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //t.pEnv
- return out;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isCurrency", mID,column );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isAutoIncrement";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallBooleanMethod( object, mID, column);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isAutoIncrement" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isSigned";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- out = t.pEnv->CallBooleanMethod( object, mID, column);
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSigned" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isSigned", mID,column );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getPrecision";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getPrecision" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getPrecision",mID,column);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "getScale";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getScale" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getScale",mID,column);
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)I";
- static const char * cMethodName = "isNullable";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isNullable" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("isNullable",mID,column);
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isSearchable";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSearchable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isSearchable", mID,column );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isReadOnly";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isReadOnly" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isReadOnly", mID,column );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isDefinitelyWritable";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isDefinitelyWritable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
- jboolean out(sal_False);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)Z";
- static const char * cMethodName = "isWritable";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallBooleanMethod( object, mID, column );
- ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
- // und aufraeumen
- } //mID
- } //t.pEnv
- return out;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isWritable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isWritable", mID,column );
}
// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/SQLException.cxx b/connectivity/source/drivers/jdbc/SQLException.cxx
index 21b8f19dad2a..cdc195643cba 100644
--- a/connectivity/source/drivers/jdbc/SQLException.cxx
+++ b/connectivity/source/drivers/jdbc/SQLException.cxx
@@ -63,52 +63,23 @@ java_sql_SQLException_BASE::~java_sql_SQLException_BASE()
{}
-jclass java_sql_SQLException_BASE::getMyClass()
+jclass java_sql_SQLException_BASE::getMyClass() const
{
- // die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/sql/SQLException");
- OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- if(!tempClass)
- {
- t.pEnv->ExceptionDescribe();
- t.pEnv->ExceptionClear();
- }
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
- return theClass;
+ return st_getMyClass();
}
-
-void java_sql_SQLException_BASE::saveClassRef( jclass pClass )
+jclass java_sql_SQLException_BASE::st_getMyClass()
{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/SQLException");
+ return theClass;
}
starsdbc::SQLException java_sql_SQLException_BASE::getNextException() const
{
- jobject out = NULL;
SDBThreadAttach t;
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/sql/SQLException;";
- static const char * cMethodName = "getNextException";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getNextException","()Ljava/sql/SQLException;", mID);
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
if( out )
{
@@ -121,44 +92,12 @@ starsdbc::SQLException java_sql_SQLException_BASE::getNextException() const
::rtl::OUString java_sql_SQLException_BASE::getSQLState() const
{
- SDBThreadAttach t;
- ::rtl::OUString aStr;
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getSQLState";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring) t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getSQLState",mID);
}
sal_Int32 java_sql_SQLException_BASE::getErrorCode() const
{
- jint out(0);
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getErrorCode";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- ThrowSQLException(t.pEnv,0);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getErrorCode",mID);
}
diff --git a/connectivity/source/drivers/jdbc/SQLWarning.cxx b/connectivity/source/drivers/jdbc/SQLWarning.cxx
index 55a96396b6dc..95ad8c4ca62b 100644
--- a/connectivity/source/drivers/jdbc/SQLWarning.cxx
+++ b/connectivity/source/drivers/jdbc/SQLWarning.cxx
@@ -41,25 +41,11 @@ jclass java_sql_SQLWarning_BASE::theClass = 0;
java_sql_SQLWarning_BASE::~java_sql_SQLWarning_BASE()
{}
-jclass java_sql_SQLWarning_BASE::getMyClass()
+jclass java_sql_SQLWarning_BASE::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/sql/SQLWarning" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/SQLWarning");
return theClass;
}
-void java_sql_SQLWarning_BASE::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx
index 02a2d7f25106..2f436f264464 100644
--- a/connectivity/source/drivers/jdbc/String.cxx
+++ b/connectivity/source/drivers/jdbc/String.cxx
@@ -42,30 +42,19 @@ jclass java_lang_String::theClass = 0;
java_lang_String::~java_lang_String()
{}
-jclass java_lang_String::getMyClass()
+jclass java_lang_String::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_lang_String::st_getMyClass()
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/lang/String");
- OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/lang/String");
return theClass;
}
//--------------------------------------------------------------------------
-void java_lang_String::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-//--------------------------------------------------------------------------
java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL )
{
SDBThreadAttach t;
@@ -78,9 +67,8 @@ java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Ob
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)V";
jobject tempObj;
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
diff --git a/connectivity/source/drivers/jdbc/Throwable.cxx b/connectivity/source/drivers/jdbc/Throwable.cxx
index c97cbd5018c5..bdf6743157b0 100644
--- a/connectivity/source/drivers/jdbc/Throwable.cxx
+++ b/connectivity/source/drivers/jdbc/Throwable.cxx
@@ -42,98 +42,30 @@ jclass java_lang_Throwable::theClass = 0;
java_lang_Throwable::~java_lang_Throwable()
{}
-jclass java_lang_Throwable::getMyClass()
+jclass java_lang_Throwable::getMyClass() const
{
- // die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass("java/lang/Throwable"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
- return theClass;
+ return st_getMyClass();
}
-// -----------------------------------------------------------------------------
-
-void java_lang_Throwable::saveClassRef( jclass pClass )
+jclass java_lang_Throwable::st_getMyClass()
{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/Throwable");
+ return theClass;
}
// -----------------------------------------------------------------------------
::rtl::OUString java_lang_Throwable::getMessage() const
{
- ::rtl::OUString aStr;
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getMessage";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,NULL);
-
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getMessage",mID);
}
// -----------------------------------------------------------------------------
::rtl::OUString java_lang_Throwable::getLocalizedMessage() const
{
- ::rtl::OUString aStr;
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "getLocalizedMessage";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,NULL);
-
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
-}
-// -----------------------------------------------------------------------------
-::rtl::OUString java_lang_Throwable::toString() const
-{
- ::rtl::OUString aStr;
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "()Ljava/lang/String;";
- static const char * cMethodName = "toString";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID);
- ThrowSQLException(t.pEnv,NULL);
-
- aStr = JavaString2String(t.pEnv,out);
- } //mID
- } //t.pEnv
- // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
- return aStr;
+ static jmethodID mID(NULL);
+ return callStringMethod("getLocalizedMessage",mID);
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index 75f589c2a861..8c30f7a14efc 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -57,7 +57,7 @@ java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;";
jobject tempObj;
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
@@ -69,29 +69,15 @@ java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java
java_sql_Date::~java_sql_Date()
{}
-jclass java_sql_Date::getMyClass()
+jclass java_sql_Date::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Date"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Date");
return theClass;
}
// -----------------------------------------------------------------------------
-void java_sql_Date::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-// -----------------------------------------------------------------------------
java_sql_Date::operator ::com::sun::star::util::Date()
{
return ::dbtools::DBTypeConversion::toDate(toString());
@@ -106,28 +92,14 @@ jclass java_sql_Time::theClass = 0;
java_sql_Time::~java_sql_Time()
{}
-jclass java_sql_Time::getMyClass()
+jclass java_sql_Time::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Time"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Time");
return theClass;
}
-void java_sql_Time::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL )
{
SDBThreadAttach t;
@@ -143,7 +115,7 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;";
jobject tempObj;
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
@@ -166,28 +138,14 @@ jclass java_sql_Timestamp::theClass = 0;
java_sql_Timestamp::~java_sql_Timestamp()
{}
-jclass java_sql_Timestamp::getMyClass()
+jclass java_sql_Timestamp::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
- if( !t.pEnv ) return (jclass)0;
- jclass tempClass = t.pEnv->FindClass("java/sql/Timestamp"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/sql/Timestamp");
return theClass;
}
-void java_sql_Timestamp::saveClassRef( jclass pClass )
-{
- if( pClass==0 )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
-
java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut)
:java_util_Date( NULL, (jobject)NULL )
{
@@ -205,7 +163,7 @@ java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _
// temporaere Variable initialisieren
static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;";
jobject tempObj;
- static jmethodID mID = NULL;
+ static jmethodID mID(NULL);
if ( !mID )
mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
@@ -217,40 +175,14 @@ java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _
sal_Int32 java_sql_Timestamp::getNanos()
{
- jint out(0);
- SDBThreadAttach t;
- if( t.pEnv ){
-
- // temporaere Variable initialisieren
- static const char * cSignature = "()I";
- static const char * cMethodName = "getNanos";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- out = t.pEnv->CallIntMethod( object, mID);
- } //mID
- } //t.pEnv
- return (sal_Int32)out;
+ static jmethodID mID(NULL);
+ return callIntMethod("getNanos",mID);
}
void java_sql_Timestamp::setNanos( sal_Int32 _par0 )
{
- SDBThreadAttach t;
- if( t.pEnv ){
- // temporaere Variable initialisieren
- static const char * cSignature = "(I)V";
- static const char * cMethodName = "setNanos";
- // Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID ){
- t.pEnv->CallVoidMethod( object, mID, _par0 );
- // und aufraeumen
- } //mID
- } //t.pEnv
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setNanos",mID,_par0);
}
// -----------------------------------------------------------------------------
java_sql_Timestamp::operator ::com::sun::star::util::DateTime()
diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk
index 58287b0bf86a..b8d6a54dd065 100644
--- a/connectivity/source/drivers/jdbc/makefile.mk
+++ b/connectivity/source/drivers/jdbc/makefile.mk
@@ -60,7 +60,6 @@ SLOFILES=\
$(SLO)$/ConnectionLog.obj \
$(SLO)$/DatabaseMetaData.obj \
$(SLO)$/Date.obj \
- $(SLO)$/DriverManager.obj \
$(SLO)$/DriverPropertyInfo.obj \
$(SLO)$/Exception.obj \
$(SLO)$/InputStream.obj \
diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx
index 9888bb6f683d..6f50a6b1affd 100644
--- a/connectivity/source/drivers/jdbc/tools.cxx
+++ b/connectivity/source/drivers/jdbc/tools.cxx
@@ -52,7 +52,7 @@ void java_util_Properties::setProperty(const ::rtl::OUString key, const ::rtl::O
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
jobject out(0);
- if( t.pEnv )
+
{
jvalue args[2];
// Parameter konvertieren
@@ -62,14 +62,10 @@ void java_util_Properties::setProperty(const ::rtl::OUString key, const ::rtl::O
static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;";
static const char * cMethodName = "setProperty";
// Java-Call absetzen
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
- if( mID )
- {
- out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l);
- ThrowSQLException(t.pEnv,NULL);
- }
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l);
+ ThrowSQLException(t.pEnv,NULL);
t.pEnv->DeleteLocalRef((jstring)args[1].l);
t.pEnv->DeleteLocalRef((jstring)args[0].l);
ThrowSQLException(t.pEnv,0);
@@ -83,27 +79,14 @@ jclass java_util_Properties::theClass = 0;
java_util_Properties::~java_util_Properties()
{}
-jclass java_util_Properties::getMyClass()
+jclass java_util_Properties::getMyClass() const
{
// die Klasse muss nur einmal geholt werden, daher statisch
- if( !theClass ){
- SDBThreadAttach t;
- if( !t.pEnv ) return (jclass)NULL;
- jclass tempClass = t.pEnv->FindClass( "java/util/Properties" );
- jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
- t.pEnv->DeleteLocalRef( tempClass );
- saveClassRef( globClass );
- }
+ if( !theClass )
+ theClass = findMyClass("java/util/Properties");
return theClass;
}
-void java_util_Properties::saveClassRef( jclass pClass )
-{
- if( pClass==NULL )
- return;
- // der uebergebe Klassen-Handle ist schon global, daher einfach speichern
- theClass = pClass;
-}
//--------------------------------------------------------------------------
java_util_Properties::java_util_Properties( ): java_lang_Object( NULL, (jobject)NULL )
{
@@ -114,9 +97,8 @@ java_util_Properties::java_util_Properties( ): java_lang_Object( NULL, (jobject)
// temporaere Variable initialisieren
static const char * cSignature = "()V";
jobject tempObj;
- static jmethodID mID = NULL;
- if ( !mID )
- mID = t.pEnv->GetMethodID( getMyClass(), "<init>", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
tempObj = t.pEnv->NewObject( getMyClass(), mID);
saveRef( t.pEnv, tempObj );
t.pEnv->DeleteLocalRef( tempObj );
@@ -218,7 +200,7 @@ sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear)
if ( _bClear )
pEnv->ExceptionClear();
#if OSL_DEBUG_LEVEL > 1
- if(pEnv->IsInstanceOf(pThrowable,java_sql_SQLException_BASE::getMyClass()))
+ if(pEnv->IsInstanceOf(pThrowable,java_sql_SQLException_BASE::st_getMyClass()))
{
java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE(pEnv,pThrowable);