Tag: cws_src680_qiq User: fs Date: 06/05/15 07:21:49 Modified: /dba/dbaccess/source/ui/misc/ datasourceconnector.cxx
Log: #i51143# display warnings which were encountered during connecting to the database File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: datasourceconnector.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/datasourceconnector.cxx?r1=1.7&r2=1.7.124.1 Delta lines: +52 -22 --------------------- --- datasourceconnector.cxx 8 Sep 2005 16:12:48 -0000 1.7 +++ datasourceconnector.cxx 15 May 2006 14:21:47 -0000 1.7.124.1 @@ -4,9 +4,9 @@ * * $RCSfile: datasourceconnector.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.7.124.1 $ * - * last change: $Author: rt $ $Date: 2005/09/08 16:12:48 $ + * last change: $Author: fs $ $Date: 2006/05/15 14:21:47 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,6 +42,9 @@ #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif +#ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#endif #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> #endif @@ -78,6 +81,9 @@ #ifndef SVTOOLS_FILENOTATION_HXX #include <svtools/filenotation.hxx> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif #ifndef _DBU_MISC_HRC_ #include "dbu_misc.hrc" #endif @@ -197,13 +203,9 @@ { if (bPwdRequired && !sPassword.getLength()) { // password required, but empty -> connect using an interaction handler - Reference< XCompletedConnection > xConnectionCompletion(_xDataSource, UNO_QUERY); - if (!xConnectionCompletion.is()) - { - OSL_ENSURE(sal_False, "ODatasourceConnector::connect: missing an interface ... need an error message here!"); - } - else - { // instantiate the default SDB interaction handler + Reference< XCompletedConnection > xConnectionCompletion( _xDataSource, UNO_QUERY_THROW ); + + // instantiate the default SDB interaction handler Reference< XInteractionHandler > xHandler(m_xORB->createInstance(SERVICE_SDB_INTERACTION_HANDLER), UNO_QUERY); if (!xHandler.is()) { @@ -214,7 +216,6 @@ xConnection = xConnectionCompletion->connectWithCompletion(xHandler); } } - } else { xConnection = _xDataSource->getConnection(sUser, sPassword); @@ -223,10 +224,16 @@ catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); } catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); } catch(SQLException& e) { aInfo = SQLExceptionInfo(e); } - catch(Exception&) { OSL_ENSURE(sal_False, "SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( !_bShowError ) + return xConnection; - // display the error (if any) - if ( _bShowError && aInfo.isValid() ) + // was there and error? + if ( aInfo.isValid() ) { if ( m_sContextInformation.getLength() ) { @@ -240,6 +247,29 @@ } showError(aInfo, m_pErrorMessageParent, m_xORB); + return xConnection; + } + + // was there a warning? + Reference< XWarningsSupplier > xConnectionWarnings( xConnection, UNO_QUERY ); + if ( xConnectionWarnings.is() ) + { + try + { + Any aWarnings( xConnectionWarnings->getWarnings() ); + if ( aWarnings.hasValue() ) + { + SQLContext aContext; + aContext.Message = String( ModuleRes( STR_WARNINGS_DURING_CONNECT ) ); + aContext.NextException = aWarnings; + showError( SQLExceptionInfo( aContext ), m_pErrorMessageParent, m_xORB ); + } + xConnectionWarnings->clearWarnings(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } return xConnection; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
