diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-08-14 06:21:03 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-08-14 06:21:03 +0000 |
commit | f9f3513d1476fbe3433fc1a8c093b0a53dc4c36c (patch) | |
tree | b5786c55dd150ec18ead4a87b0f5af6e8a65c5f8 /connectivity/source | |
parent | ef5ff4dda65354b289e052428e41b3bcfdf9535f (diff) |
#90553# convert classname in jni conform way
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/jdbc/Class.cxx | 42 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/DatabaseMetaData.cxx | 21 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/JDriver.cxx | 13 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/Object.cxx | 14 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/ResultSet.cxx | 27 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/tools.cxx | 12 |
6 files changed, 78 insertions, 51 deletions
diff --git a/connectivity/source/drivers/jdbc/Class.cxx b/connectivity/source/drivers/jdbc/Class.cxx index c01824d64c9b..c75777e8538c 100644 --- a/connectivity/source/drivers/jdbc/Class.cxx +++ b/connectivity/source/drivers/jdbc/Class.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Class.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: kr $ $Date: 2001-08-06 13:28:47 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,28 +104,12 @@ java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 ) { jobject out(NULL); SDBThreadAttach t; - if( t.pEnv ){ - jvalue args[1]; - // Parameter konvertieren - args[0].l = convertwchar_tToJavaString(t.pEnv,_par0); - // temporaere Variable initialisieren - char * cSignature = "(Ljava/lang/String;)Ljava/lang/Class;"; - char * cMethodName = "forName"; - // Java-Call absetzen - 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 ); - - if(!out) - { - t.pEnv->ExceptionClear(); - out = t.pEnv->FindClass(::rtl::OUStringToOString(_par0, RTL_TEXTENCODING_ASCII_US)); - } - - ThrowSQLException(t.pEnv,0); - // und aufraeumen - } //mID - t.pEnv->DeleteLocalRef((jstring)args[0].l); + if( t.pEnv ) + { + ::rtl::OString sClassName = ::rtl::OUStringToOString(_par0, RTL_TEXTENCODING_ASCII_US); + sClassName = sClassName.replace('.','/'); + out = t.pEnv->FindClass(sClassName); + ThrowSQLException(t.pEnv,0); } //t.pEnv // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! return out==0 ? NULL : new java_lang_Class( t.pEnv, out ); @@ -136,15 +120,16 @@ sal_Bool java_lang_Class::isAssignableFrom( java_lang_Class * _par0 ) jboolean out; SDBThreadAttach t; if( t.pEnv ){ - jvalue args[1]; - // Parameter konvertieren - args[0].l = _par0 != NULL ? ((java_lang_Object *)_par0)->getJavaObject() : NULL; + // temporaere Variable initialisieren char * cSignature = "(Ljava/lang/Class;)Z"; char * cMethodName = "isAssignableFrom"; // Java-Call absetzen jmethodID 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 @@ -206,7 +191,8 @@ jobject java_lang_Class::newInstanceObject() if( mID ){ out = (jstring)t.pEnv->CallObjectMethod( object, mID); ThrowSQLException(t.pEnv,0); - aStr = JavaString2String(t.pEnv, (jstring)out ); + if(out) + aStr = JavaString2String(t.pEnv, (jstring)out ); } //mID } //t.pEnv // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index 56da0cf259be..7c07ab1e8871 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DatabaseMetaData.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-07-04 10:54:30 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -236,7 +236,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges( args[3].l = convertwchar_tToJavaString(t.pEnv,columnNamePattern); out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); - ThrowSQLException(t.pEnv,*this); + if(catalog.hasValue()) t.pEnv->DeleteLocalRef((jstring)args[0].l); if(args[1].l) @@ -245,6 +245,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges( t.pEnv->DeleteLocalRef((jstring)args[2].l); if(columnNamePattern.getLength()) t.pEnv->DeleteLocalRef((jstring)args[3].l); + ThrowSQLException(t.pEnv,*this); } //mID } //t.pEnv // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! @@ -300,6 +301,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( char * cMethodName = "getTables"; // Java-Call absetzen jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!"); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); if( mID ) { jvalue args[4]; @@ -307,12 +309,14 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( if(len) { jobjectArray pObjArray = t.pEnv->NewObjectArray((jsize) len, java_lang_String::getMyClass(), 0); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); const ::rtl::OUString* pBegin = types.getConstArray(); for(sal_Int32 i=0;i<len;i++,++pBegin) { jstring aT = convertwchar_tToJavaString(t.pEnv,*pBegin); //jstring aT = t.pEnv->NewStringUTF(_par3.GetToken(i)); t.pEnv->SetObjectArrayElement(pObjArray,(jsize)i,aT); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); } args[3].l = pObjArray; }else @@ -322,14 +326,25 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); 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); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); if(catalog.hasValue()) + { t.pEnv->DeleteLocalRef((jstring)args[0].l); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); + } if(args[1].l) + { t.pEnv->DeleteLocalRef((jstring)args[1].l); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); + } if(tableNamePattern.getLength()) + { t.pEnv->DeleteLocalRef((jstring)args[2].l); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); + } //for(INT16 i=0;i<len;i++) t.pEnv->DeleteLocalRef((jobjectArray)args[3].l); + OSL_ENSURE(!t.pEnv->ExceptionOccurred(),"Exception occured!"); ThrowSQLException(t.pEnv,*this); } //mID diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx index 008623e52065..6f161c29c63c 100644 --- a/connectivity/source/drivers/jdbc/JDriver.cxx +++ b/connectivity/source/drivers/jdbc/JDriver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: JDriver.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-08-03 14:19:08 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -206,6 +206,15 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUStrin } } } + catch(SQLException& e) + { + if( object ) + { + t.pEnv->DeleteGlobalRef( object ); + object = NULL; + } + throw SQLException(::rtl::OUString::createFromAscii("The specified driver could not be loaded!"),*this,::rtl::OUString(),1000,makeAny(e)); + } catch(Exception&) { if( object ) diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index e737f7ca93ba..67ad2771dbc3 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Object.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-07-06 08:37:18 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -194,15 +194,25 @@ int SDB_JRE_InitJava(const Reference<XMultiServiceFactory >& _rxFactory) SDBThreadAttach::SDBThreadAttach() : bDetach(sal_False), pEnv(NULL) { attachThread(pEnv); + if(pEnv && pEnv->ExceptionOccurred()) + pEnv->ExceptionClear(); } SDBThreadAttach::SDBThreadAttach(const Reference<XMultiServiceFactory >& _rxFactory) : bDetach(sal_False), pEnv(NULL) { attachThread(pEnv,_rxFactory); + if(pEnv && pEnv->ExceptionOccurred()) + pEnv->ExceptionClear(); } SDBThreadAttach::~SDBThreadAttach() { + if(pEnv && pEnv->ExceptionOccurred()) + { + OSL_ENSURE(0,"Exception occured in JNI!"); + pEnv->ExceptionClear(); + } + detachThread(); } diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 1b1ef1a63d5b..3f27294537a3 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ResultSet.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-07-04 10:54:30 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -583,8 +583,8 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!"); if( mID ){ out = t.pEnv->CallObjectMethodA( object, mID, args); - ThrowSQLException(t.pEnv,*this); t.pEnv->DeleteLocalRef((jstring)args[1].l); + ThrowSQLException(t.pEnv,*this); // und aufraeumen } //mID } //t.pEnv @@ -1448,19 +1448,21 @@ void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, con SDBThreadAttach t; if( t.pEnv ) { - // TODO - jvalue args[1]; - // Parameter konvertieren - args[0].l = 0; // temporaere Variable initialisieren char * cSignature = "(ILjava/io/InputStream;I)V"; char * cMethodName = "updateBinaryStream"; // Java-Call absetzen jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!"); if( mID ){ + // TODO + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; + t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,length); - ThrowSQLException(t.pEnv,*this); + t.pEnv->DeleteLocalRef((jobject)args[0].l); + ThrowSQLException(t.pEnv,*this); } } } @@ -1470,18 +1472,19 @@ void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, SDBThreadAttach t; if( t.pEnv ) { - jvalue args[1]; - // Parameter konvertieren - args[0].l = 0; + // temporaere Variable initialisieren char * cSignature = "(ILjava/io/InputStream;I)V"; char * cMethodName = "updateCharacterStream"; // Java-Call absetzen jmethodID mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!"); if( mID ){ + jvalue args[1]; + // Parameter konvertieren + args[0].l = 0; t.pEnv->CallVoidMethod( object, mID,columnIndex,args[0].l,length); - ThrowSQLException(t.pEnv,*this); t.pEnv->DeleteLocalRef((jobject)args[0].l); + ThrowSQLException(t.pEnv,*this); } } } diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index 57bf3eeacc66..22b6963e3141 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tools.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-31 08:29:15 $ + * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,9 +161,13 @@ java_util_Properties::java_util_Properties( ): java_lang_Object( NULL, (jobject) // -------------------------------------------------------------------------------- jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _rTemp) { + jstring pStr = NULL; if (pEnv) - return pEnv->NewString(_rTemp.getStr(), _rTemp.getLength()); - return NULL; + { + pStr = pEnv->NewString(_rTemp.getStr(), _rTemp.getLength()); + OSL_ENSURE(pStr,"Could not create a jsstring object!"); + } + return pStr; } // -------------------------------------------------------------------------------- |