diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-11 20:55:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-12 16:39:55 +0100 |
commit | 32db3f5dc4fccecc8c66b1cb4f4444f2e517e648 (patch) | |
tree | 9848d00e7095514ca0f470f62258dd79b0b8fab7 /connectivity/source | |
parent | aeac20e7bd2a2fe9b1c2ea3930e5aa3acffc3a74 (diff) |
coverity#706331 Uncaught exception
Change-Id: I48e11a07924418721d45fcac55bd5aeb68f115a3
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/jdbc/Array.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/DatabaseMetaData.cxx | 48 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/InputStream.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/JConnection.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/JStatement.cxx | 19 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/Object.cxx | 53 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/PreparedStatement.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/ResultSet.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/ResultSetMetaData.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/SQLException.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/inc/java/lang/Object.hxx | 9 |
11 files changed, 93 insertions, 70 deletions
diff --git a/connectivity/source/drivers/jdbc/Array.cxx b/connectivity/source/drivers/jdbc/Array.cxx index 8fccdef8d4f9..d3ff1baa6455 100644 --- a/connectivity/source/drivers/jdbc/Array.cxx +++ b/connectivity/source/drivers/jdbc/Array.cxx @@ -49,7 +49,7 @@ OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sd sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethod("getBaseType",mID); + return callIntMethod_Throw("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, std::exception) diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index d256c7be5c96..63b73cd0d8eb 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -241,73 +241,73 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns( sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxBinaryLiteralLength", mID ); + return impl_callIntMethod("getMaxBinaryLiteralLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxRowSize", mID ); + return impl_callIntMethod("getMaxRowSize", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCatalogNameLength", mID ); + return impl_callIntMethod("getMaxCatalogNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCharLiteralLength", mID ); + return impl_callIntMethod("getMaxCharLiteralLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnNameLength", mID ); + return impl_callIntMethod("getMaxColumnNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInIndex", mID ); + return impl_callIntMethod("getMaxColumnsInIndex", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCursorNameLength", mID ); + return impl_callIntMethod("getMaxCursorNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxConnections", mID ); + return impl_callIntMethod("getMaxConnections", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInTable", mID ); + return impl_callIntMethod("getMaxColumnsInTable", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxStatementLength", mID ); + return impl_callIntMethod("getMaxStatementLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxTableNameLength", mID ); + return impl_callIntMethod("getMaxTableNameLength", mID); } sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( ) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxTablesInSelect", mID ); + return impl_callIntMethod("getMaxTablesInSelect", mID); } Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys( @@ -567,7 +567,7 @@ OUString java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodN sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) { m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); - sal_Int32 out( (sal_Int32)callIntMethod(_pMethodName,_inout_MethodID) ); + sal_Int32 out( (sal_Int32)callIntMethod_Throw(_pMethodName,_inout_MethodID) ); m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, (sal_Int32)out ); return out; } @@ -722,7 +722,7 @@ bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxIndexLength", mID ); + return impl_callIntMethod("getMaxIndexLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException, std::exception) @@ -896,19 +896,19 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) th sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( ) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxStatements", mID ); + return impl_callIntMethod("getMaxStatements", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxProcedureNameLength", mID ); + return impl_callIntMethod("getMaxProcedureNameLength", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxSchemaNameLength", mID ); + return impl_callIntMethod("getMaxSchemaNameLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException, std::exception) @@ -1215,19 +1215,19 @@ OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLExceptio sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getDriverMajorVersion", mID ); + return impl_callIntMethod("getDriverMajorVersion", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getDefaultTransactionIsolation", mID ); + return impl_callIntMethod("getDefaultTransactionIsolation", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getDriverMinorVersion", mID ); + return impl_callIntMethod("getDriverMinorVersion", mID); } OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException, std::exception) @@ -1299,25 +1299,25 @@ sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInGroupBy", mID ); + return impl_callIntMethod("getMaxColumnsInGroupBy", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInOrderBy", mID ); + return impl_callIntMethod("getMaxColumnsInOrderBy", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInSelect", mID ); + return impl_callIntMethod("getMaxColumnsInSelect", mID); } sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxUserNameLength", mID ); + return impl_callIntMethod("getMaxUserNameLength", mID); } sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException, std::exception) diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx index 26d8a156ff27..16341a180c28 100644 --- a/connectivity/source/drivers/jdbc/InputStream.cxx +++ b/connectivity/source/drivers/jdbc/InputStream.cxx @@ -68,7 +68,7 @@ void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::c sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethod("available",mID); + return callIntMethod_Throw("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, std::exception) { diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index a9b8ef9c6c03..d9a388190525 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -401,13 +401,13 @@ sal_Bool SAL_CALL java_sql_Connection::getAutoCommit( ) throw(SQLException, Run void SAL_CALL java_sql_Connection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setReadOnly",mID,readOnly); + callVoidMethodWithBoolArg_Throw("setReadOnly", mID, readOnly); } void SAL_CALL java_sql_Connection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setAutoCommit",mID,autoCommit); + callVoidMethodWithBoolArg_Throw("setAutoCommit", mID, autoCommit); } Reference< ::com::sun::star::container::XNameAccess > SAL_CALL java_sql_Connection::getTypeMap( ) throw(SQLException, RuntimeException, std::exception) @@ -437,7 +437,7 @@ sal_Int32 SAL_CALL java_sql_Connection::getTransactionIsolation( ) throw(SQLExc checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); static jmethodID mID(NULL); - return callIntMethod("getTransactionIsolation",mID); + return callIntMethod_Throw("getTransactionIsolation", mID); } void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException, std::exception) @@ -446,7 +446,7 @@ void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) th checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setTransactionIsolation",mID,level); + callVoidMethodWithIntArg_Throw("setTransactionIsolation", mID, level); } Reference< XStatement > SAL_CALL java_sql_Connection::createStatement( ) throw(SQLException, RuntimeException, std::exception) diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx index 3f5958e6032c..16d6631d6d2b 100644 --- a/connectivity/source/drivers/jdbc/JStatement.cxx +++ b/connectivity/source/drivers/jdbc/JStatement.cxx @@ -368,7 +368,7 @@ sal_Int32 SAL_CALL java_sql_Statement_Base::getUpdateCount( ) throw(::com::sun: SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - sal_Int32 out = callIntMethod("getUpdateCount",mID); + sal_Int32 out = callIntMethod_Throw("getUpdateCount", mID); m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, (sal_Int32)out ); return out; } @@ -442,8 +442,7 @@ sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jm { sal_Int32 out = _nDefault; if ( object ) - out = callIntMethod(_pMethodName,_inout_MethodID,true); - + out = callIntMethod_Nothrow(_pMethodName, _inout_MethodID); return out; } @@ -451,7 +450,7 @@ sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jm { SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); - return callIntMethod(_pMethodName,_inout_MethodID,true); + return callIntMethod_Nothrow(_pMethodName, _inout_MethodID); } @@ -497,7 +496,7 @@ void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLExceptio SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setQueryTimeOut",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setQueryTimeOut", mID, _par0); } @@ -511,7 +510,7 @@ void java_sql_Statement_Base::setEscapeProcessing(bool _par0) throw(SQLException m_bEscapeProcessing = _par0; createStatement( t.pEnv ); static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setEscapeProcessing",mID,_par0,true); + callVoidMethodWithBoolArg_Nothrow("setEscapeProcessing", mID, _par0); } @@ -522,7 +521,7 @@ void java_sql_Statement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, Ru SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setMaxRows",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setMaxRows", mID, _par0); } void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException) @@ -553,7 +552,7 @@ void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLExcept SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setFetchDirection", mID, _par0); } void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException) @@ -565,7 +564,7 @@ void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchSize",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setFetchSize", mID, _par0); } void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException) @@ -575,7 +574,7 @@ void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLExceptio SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - callVoidMethodWithIntArg("setMaxFieldSize",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setMaxFieldSize", mID, _par0); } void java_sql_Statement_Base::setCursorName(const OUString &_par0) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 67529483b29d..37538fa77d87 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -262,19 +262,25 @@ jobject java_lang_Object::callResultSetMethod( JNIEnv& _rEnv,const char* _pMetho return out; } -sal_Int32 java_lang_Object::callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException ) const +sal_Int32 java_lang_Object::callIntMethod_Throw(const char* _pMethodName, jmethodID& _inout_MethodID) const { SDBThreadAttach t; OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); obtainMethodId(t.pEnv, _pMethodName,"()I", _inout_MethodID); - // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,true); - else - ThrowSQLException( t.pEnv, NULL ); + ThrowSQLException( t.pEnv, NULL ); + return (sal_Int32)out; +} +sal_Int32 java_lang_Object::callIntMethod_Nothrow(const char* _pMethodName, jmethodID& _inout_MethodID) const +{ + SDBThreadAttach t; + OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); + obtainMethodId(t.pEnv, _pMethodName,"()I", _inout_MethodID); + // call method + jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) ); + isExceptionOccurred(t.pEnv,true); return (sal_Int32)out; } @@ -301,7 +307,7 @@ void java_lang_Object::callVoidMethod( const char* _pMethodName, jmethodID& _ino ThrowSQLException( t.pEnv, NULL ); } -void java_lang_Object::callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const +void java_lang_Object::callVoidMethodWithIntArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const { SDBThreadAttach t; OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); @@ -309,23 +315,38 @@ void java_lang_Object::callVoidMethodWithIntArg( const char* _pMethodName, jmeth // call method t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,true); - else - ThrowSQLException( t.pEnv, NULL ); + ThrowSQLException( t.pEnv, NULL ); +} + +void java_lang_Object::callVoidMethodWithIntArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const +{ + SDBThreadAttach t; + OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); + obtainMethodId(t.pEnv, _pMethodName,"(I)V", _inout_MethodID); + + // call method + t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument ); + isExceptionOccurred(t.pEnv,true); +} + +void java_lang_Object::callVoidMethodWithBoolArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const +{ + SDBThreadAttach t; + OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); + obtainMethodId(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID); + // call method + t.pEnv->CallVoidMethod( object, _inout_MethodID,int(_nArgument) ); + ThrowSQLException( t.pEnv, NULL ); } -void java_lang_Object::callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument,bool _bIgnoreException ) const +void java_lang_Object::callVoidMethodWithBoolArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const { SDBThreadAttach t; OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" ); obtainMethodId(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID); // call method t.pEnv->CallVoidMethod( object, _inout_MethodID,int(_nArgument) ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,true); - else - ThrowSQLException( t.pEnv, NULL ); + isExceptionOccurred(t.pEnv,true); } OUString java_lang_Object::callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index ecd7d01818cb..7309a20872ac 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -113,7 +113,7 @@ sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::su SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); createStatement(t.pEnv); static jmethodID mID(NULL); - return callIntMethod("executeUpdate",mID); + return callIntMethod_Throw("executeUpdate", mID); } diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index d6553a8d2749..881fc463d3e0 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -225,7 +225,7 @@ sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQL sal_Int32 SAL_CALL java_sql_ResultSet::getRow( ) throw(SQLException, RuntimeException, std::exception) { static jmethodID mID(NULL); - return callIntMethod("getRow",mID); + return callIntMethod_Throw("getRow", mID); } @@ -574,7 +574,7 @@ void SAL_CALL java_sql_ResultSet::moveToCurrentRow( ) throw(::com::sun::star::s void SAL_CALL java_sql_ResultSet::updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { static jmethodID mID(NULL); - callVoidMethodWithIntArg("updateNull",mID,columnIndex); + callVoidMethodWithIntArg_Throw("updateNull", mID, columnIndex); } @@ -824,25 +824,25 @@ 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) { static jmethodID mID(NULL); - return callIntMethod("getConcurrency",mID,true); + return callIntMethod_Nothrow("getConcurrency", mID); } sal_Int32 java_sql_ResultSet::getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { static jmethodID mID(NULL); - return callIntMethod("getType",mID,true); + return callIntMethod_Nothrow("getType",mID); } sal_Int32 java_sql_ResultSet::getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { static jmethodID mID(NULL); - return callIntMethod("getFetchDirection",mID,true); + return callIntMethod_Nothrow("getFetchDirection", mID); } sal_Int32 java_sql_ResultSet::getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { static jmethodID mID(NULL); - return callIntMethod("getFetchSize",mID,true); + return callIntMethod_Nothrow("getFetchSize", mID); } OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) @@ -855,7 +855,7 @@ OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc: void java_sql_ResultSet::setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setFetchDirection", mID, _par0); } void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeException, std::exception) @@ -867,7 +867,7 @@ void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeExce void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchSize",mID,_par0,true); + callVoidMethodWithIntArg_Nothrow("setFetchSize", mID, _par0); } ::cppu::IPropertyArrayHelper* java_sql_ResultSet::createArrayHelper( ) const diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx index 74dc2f8dbcb6..91c548a3c7dd 100644 --- a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx +++ b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx @@ -74,7 +74,7 @@ sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLExcep if ( m_nColumnCount == -1 ) { static jmethodID mID(NULL); - m_nColumnCount = callIntMethod("getColumnCount",mID); + m_nColumnCount = callIntMethod_Throw("getColumnCount", mID); } // if ( m_nColumnCount == -1 ) return m_nColumnCount; diff --git a/connectivity/source/drivers/jdbc/SQLException.cxx b/connectivity/source/drivers/jdbc/SQLException.cxx index be3d244884e3..1b2cc88551fa 100644 --- a/connectivity/source/drivers/jdbc/SQLException.cxx +++ b/connectivity/source/drivers/jdbc/SQLException.cxx @@ -84,7 +84,7 @@ OUString java_sql_SQLException_BASE::getSQLState() const sal_Int32 java_sql_SQLException_BASE::getErrorCode() const { static jmethodID mID(NULL); - return callIntMethod("getErrorCode",mID); + return callIntMethod_Throw("getErrorCode", mID); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx index 6fa0d3db7995..ed839c78fcf3 100644 --- a/connectivity/source/inc/java/lang/Object.hxx +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -114,14 +114,17 @@ namespace connectivity bool callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const; bool callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; jobject callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const; - sal_Int32 callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException = false ) const; + sal_Int32 callIntMethod_Throw(const char* _pMethodName, jmethodID& _inout_MethodID) const; + sal_Int32 callIntMethod_Nothrow(const char* _pMethodName, jmethodID& _inout_MethodID) const; sal_Int32 callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; sal_Int32 callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const; OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const; OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const; void callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const; - void callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const; - void callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument,bool _bIgnoreException = false ) const; + void callVoidMethodWithIntArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + void callVoidMethodWithIntArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + void callVoidMethodWithBoolArg_Throw( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const; + void callVoidMethodWithBoolArg_Nothrow( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const; void callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID, const OUString& _nArgument ) const; jobject callObjectMethod( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID ) const; jobject callObjectMethodWithIntArg( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const; |