User: hr      
Date: 2007-06-27 14:36:02+0000
Modified:
   dba/connectivity/source/drivers/jdbc/JConnection.cxx

Log:
 INTEGRATION: CWS sdblogging (1.3.4); FILE MERGED
 2007/05/23 09:01:57 fs 1.3.4.7: WARNING -> SEVERE
 2007/05/22 19:19:29 fs 1.3.4.6: #i76119# property construct m_aLogger
 2007/04/18 06:06:39 fs 1.3.4.5: #i10000#
 2007/04/16 11:24:26 fs 1.3.4.4: RESYNC: (1.3-1.4); FILE MERGED
 2007/04/12 09:04:34 fs 1.3.4.3: #i76119# ThrowLoggedSQLException instead of 
ThrowSQLException
 2007/04/11 13:51:33 fs 1.3.4.2: #i76119# logging meta data methods
 2007/04/11 08:53:28 fs 1.3.4.1: #i76119# added logging messages

File Changes:

Directory: /dba/connectivity/source/drivers/jdbc/
=================================================

File [changed]: JConnection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/jdbc/JConnection.cxx?r1=1.4&r2=1.5
Delta lines:  +81 -59
---------------------
--- JConnection.cxx     2007-03-12 10:41:12+0000        1.4
+++ JConnection.cxx     2007-06-27 14:35:59+0000        1.5
@@ -70,6 +70,7 @@
 #include "connectivity/dbexception.hxx"
 #endif
 #include "java/util/Property.hxx"
+#include "resource/jdbc_log.hrc"
 #include "com/sun/star/uno/XComponentContext.hpp"
 #include "jvmaccess/classpath.hxx"
 
@@ -81,7 +82,6 @@
 using namespace connectivity;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
-//     using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::lang;
@@ -197,13 +197,14 @@
 //**************************************************************
 jclass java_sql_Connection::theClass = 0;
 
-java_sql_Connection::java_sql_Connection( const java_sql_Driver* _pDriver)
-    :java_lang_Object( _pDriver->getORB() )
-    ,OSubComponent<java_sql_Connection, 
java_sql_Connection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+java_sql_Connection::java_sql_Connection( const java_sql_Driver& _rDriver )
+    :java_lang_Object( _rDriver.getContext().getLegacyServiceFactory() )
+    ,OSubComponent<java_sql_Connection, 
java_sql_Connection_BASE>((::cppu::OWeakObject*)(&_rDriver), this)
     ,m_xMetaData(NULL)
-    ,m_pDriver(_pDriver)
+    ,m_pDriver( &_rDriver )
     ,m_pDriverobject(NULL)
     ,m_Driver_theClass(NULL)
+    ,m_aLogger( _rDriver.getLogger() )
     ,m_bParameterSubstitution(sal_False)
     ,m_bIgnoreDriverPrivileges(sal_True)
 {
@@ -239,6 +240,9 @@
 void java_sql_Connection::disposing()
 {
        ::osl::MutexGuard aGuard(m_aMutex);
+
+    m_aLogger.log( LogLevel::INFO, STR_LOG_SHUTDOWN_CONNECTION );
+
        dispose_ChildImpl();
        java_sql_Connection_BASE::disposing();
 
@@ -268,7 +272,7 @@
                                mID  = t.pEnv->GetMethodID( getMyClass(), 
cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
                        if( mID )
                                t.pEnv->CallVoidMethod( object, mID);
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //t.pEnv
        }
 }
@@ -314,7 +318,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                        aStr = JavaString2String(t.pEnv,out);
                } //mID
        } //t.pEnv
@@ -344,12 +348,12 @@
                                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);
+                               ThrowLoggedSQLException( m_aLogger, t.pEnv, 
*this );
                } //t.pEnv
                if(out)
                {
 
-                       xMetaData = new java_sql_DatabaseMetaData( t.pEnv, 
out,this );
+                       xMetaData = new java_sql_DatabaseMetaData( t.pEnv, out, 
*this );
                        m_xMetaData = xMetaData;
                }
        }
@@ -380,7 +384,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID );
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
 }
@@ -402,7 +406,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
        return out && java_sql_Connection_BASE::rBHelper.bDisposed;
@@ -426,7 +430,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
        return out;
@@ -454,7 +458,7 @@
                        t.pEnv->CallVoidMethod( object, mID, str );
 
                        t.pEnv->DeleteLocalRef(str);
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                }
        } //t.pEnv
 }
@@ -476,7 +480,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID);
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
 }
@@ -500,7 +504,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
        } //t.pEnv
        return out;
 }
@@ -523,7 +527,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID, (jboolean)readOnly 
);
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                        // und aufraeumen
                } //mID
        } //t.pEnv
@@ -547,7 +551,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID, 
(jboolean)autoCommit );
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                        // und aufraeumen
                } //mID
        } //t.pEnv
@@ -572,7 +576,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
        // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten 
Zeigers !!!
@@ -607,7 +611,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID )
                        out = t.pEnv->CallIntMethod( object, mID );
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
        } //t.pEnv
        return out;
 }
@@ -629,7 +633,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID, level );
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                        // und aufraeumen
                } //mID
        } //t.pEnv
@@ -639,10 +643,14 @@
 {
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+    m_aLogger.log( LogLevel::FINE, STR_LOG_CREATE_STATEMENT );
 
        SDBThreadAttach t;
-       Reference< XStatement > xStmt = new java_sql_Statement( t.pEnv,this );
-       m_aStatements.push_back(WeakReferenceHelper(xStmt));
+    java_sql_Statement* pStatement = new java_sql_Statement( t.pEnv, *this );
+       Reference< XStatement > xStmt = pStatement;
+       m_aStatements.push_back( WeakReferenceHelper( xStmt ) );
+
+    m_aLogger.log( LogLevel::FINE, STR_LOG_CREATED_STATEMENT_ID, 
pStatement->getStatementObjectID() );
        return xStmt;
 }
 // 
-----------------------------------------------------------------------------
@@ -653,7 +661,7 @@
        {
                try
                {
-                       OSQLParser aParser(m_pDriver->getORB());
+                       OSQLParser aParser( 
m_pDriver->getContext().getLegacyServiceFactory() );
                        ::rtl::OUString sErrorMessage;
                        ::rtl::OUString sNewSql;
                        OSQLParseNode* pNode = 
aParser.parseTree(sErrorMessage,_sSQL);
@@ -676,12 +684,17 @@
 {
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+    m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_STATEMENT, sql );
 
        SDBThreadAttach t;
        ::rtl::OUString sSqlStatement = sql;
-       sSqlStatement = transFormPreparedStatement(sSqlStatement);
-       Reference< XPreparedStatement > xReturn = new 
java_sql_PreparedStatement( t.pEnv, this,sSqlStatement );
+       sSqlStatement = transFormPreparedStatement( sSqlStatement );
+
+    java_sql_PreparedStatement* pStatement = new java_sql_PreparedStatement( 
t.pEnv, *this, sSqlStatement );
+       Reference< XPreparedStatement > xReturn( pStatement );
        m_aStatements.push_back(WeakReferenceHelper(xReturn));
+
+    m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_STATEMENT_ID, 
pStatement->getStatementObjectID() );
        return xReturn;
 }
 // -------------------------------------------------------------------------
@@ -689,13 +702,17 @@
 {
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+    m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_CALL, sql );
 
        SDBThreadAttach t;
        ::rtl::OUString sSqlStatement = sql;
-       sSqlStatement = transFormPreparedStatement(sSqlStatement);
-       Reference< XPreparedStatement > xStmt = new java_sql_CallableStatement( 
t.pEnv, this,sSqlStatement );
+       sSqlStatement = transFormPreparedStatement( sSqlStatement );
 
+    java_sql_CallableStatement* pStatement = new java_sql_CallableStatement( 
t.pEnv, *this, sSqlStatement );
+       Reference< XPreparedStatement > xStmt( pStatement );
        m_aStatements.push_back(WeakReferenceHelper(xStmt));
+
+    m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_CALL_ID, 
pStatement->getStatementObjectID() );
        return xStmt;
 }
 // -------------------------------------------------------------------------
@@ -704,7 +721,6 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
 
-
        ::rtl::OUString aStr;
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
        if( t.pEnv ){
@@ -724,11 +740,13 @@
                        jobject out = t.pEnv->CallObjectMethod( object, mID, 
str );
                        t.pEnv->DeleteLocalRef(str);
                        aStr = JavaString2String(t.pEnv, (jstring)out );
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
 
        } //t.pEnv
-       // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten 
Zeigers !!!
+
+    m_aLogger.log( LogLevel::FINER, STR_LOG_NATIVE_SQL, sql, aStr );
+
        return aStr;
 }
 // -------------------------------------------------------------------------
@@ -737,7 +755,6 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
 
-
        SDBThreadAttach t;
        if( t.pEnv )
        {
@@ -750,7 +767,7 @@
                        mID  = t.pEnv->GetMethodID( getMyClass(), cMethodName, 
cSignature );OSL_ENSURE(mID,"Unknown method id!");
                if( mID ){
                        t.pEnv->CallVoidMethod( object, mID);
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                }
        }
 }
@@ -760,7 +777,6 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
 
-
        jobject out(NULL);
        SDBThreadAttach t;
        if( t.pEnv )
@@ -774,7 +790,7 @@
                        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);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                } //mID
        } //t.pEnv
        // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten 
Zeigers !!!
@@ -789,11 +805,9 @@
        return Any();
 }
 // 
-----------------------------------------------------------------------------
-void java_sql_Connection::loadDriverFromProperties(const Sequence< 
PropertyValue >& info,
-                                                                               
                   ::rtl::OUString& _rsGeneratedValueStatement,
-                                                                               
                   sal_Bool& _rbAutoRetrievingEnabled,
-                                                                               
                   sal_Bool& _bParameterSubstitution,
-                       sal_Bool& _bIgnoreDriverPrivileges)
+void java_sql_Connection::loadDriverFromProperties(
+        const Sequence< PropertyValue >& info, ::rtl::OUString& 
_rsGeneratedValueStatement,
+               sal_Bool& _rbAutoRetrievingEnabled, sal_Bool& 
_bParameterSubstitution, sal_Bool& _bIgnoreDriverPrivileges )
 {
        // first try if the jdbc driver is alraedy registered at the driver 
manager
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
@@ -839,8 +853,13 @@
             ::rtl::OUString aStr;
             OSL_VERIFY( pJavaDriverClass->Value >>= aStr );
             OSL_ASSERT( aStr.getLength());
-            if ( aStr.getLength() )
+            if ( !aStr.getLength() )
+            {
+                m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_DRIVER_CLASS );
+            }
+            else
             {
+                m_aLogger.log( LogLevel::INFO, STR_LOG_LOADING_DRIVER, aStr );
                 // the driver manager holds the class of the driver for later 
use
                 ::std::auto_ptr< java_lang_Class > pDrvClass;
                 if ( pJavaDriverClassPath == 0 )
@@ -852,20 +871,17 @@
                 {
                     ::rtl::OUString classpath;
                     OSL_VERIFY( pJavaDriverClassPath->Value >>= classpath );
+                    
                     pDrvClass.reset(
                         new java_lang_Class(
                             t.pEnv,
                             loadClass(
-                                Reference< XComponentContext >(
-                                    Reference< XPropertySet >(
-                                        m_pDriver->getORB(),
-                                        UNO_QUERY_THROW)->getPropertyValue(
-                                            ::rtl::OUString(
-                                                RTL_CONSTASCII_USTRINGPARAM(
-                                                    "DefaultContext"))),
-                                    UNO_QUERY_THROW),
-                                t.pEnv, classpath, aStr)));
-                    ThrowSQLException(t.pEnv, *this);
+                                m_pDriver->getContext().getUNOContext(),
+                                t.pEnv, classpath, aStr
+                            )
+                        )
+                    );
+                    ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                 }
                 if ( pDrvClass.get() )
                 {
@@ -882,6 +898,7 @@
                         }
                     }
                 }
+                m_aLogger.log( LogLevel::INFO, STR_LOG_CONN_SUCCESS );
             }
         }
        }
@@ -915,7 +932,6 @@
        enableAutoRetrievingEnabled(bAutoRetrievingEnabled);
        setAutoRetrievingStatement(sGeneratedValueStatement);
 
-
        if ( t.pEnv && m_Driver_theClass && m_pDriverobject )
        {
                // temporaere Variable initialisieren
@@ -925,7 +941,7 @@
                jmethodID mID = NULL;
                if ( !mID  )
                        mID  = t.pEnv->GetMethodID( m_Driver_theClass, 
cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
-               ThrowSQLException(t.pEnv,*this);
+               ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
                if( mID )
                {
                        jvalue args[2];
@@ -935,9 +951,12 @@
                        args[1].l = pProps->getJavaObject();
 
                        jobject out = t.pEnv->CallObjectMethod( 
m_pDriverobject, mID, args[0].l,args[1].l );
+            if ( !out )
+                m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_SYSTEM_CONNECTION 
);
+
                        try
                        {
-                               ThrowSQLException(t.pEnv,*this);
+                               ThrowLoggedSQLException( m_aLogger, t.pEnv, 
*this );
                        }
                        catch(const SQLException& )
                        {
@@ -948,11 +967,14 @@
                        // und aufraeumen
                        t.pEnv->DeleteLocalRef((jstring)args[0].l);
                        delete pProps;
-                       ThrowSQLException(t.pEnv,*this);
+                       ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
 
                        if ( out )
                                object = t.pEnv->NewGlobalRef( out );
 
+            if ( object )
+                m_aLogger.log( LogLevel::FINE, STR_LOG_GOT_JDBC_CONNECTION, 
url );
+
             m_aConnectionInfo = info;
                } //mID
        } //t.pEnv




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to