LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/jdbc - JDriver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-12-27 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "java/sql/Driver.hxx"
      21             : #include "java/lang/Object.hxx"
      22             : #include "java/lang/Class.hxx"
      23             : #include "java/sql/DriverPropertyInfo.hxx"
      24             : #include "java/sql/Connection.hxx"
      25             : #include "java/util/Property.hxx"
      26             : #include "java/tools.hxx"
      27             : #include "connectivity/dbexception.hxx"
      28             : #include <jvmfwk/framework.h>
      29             : #include "diagnose_ex.h"
      30             : #include "resource/jdbc_log.hrc"
      31             : #include "resource/common_res.hrc"
      32             : #include "resource/sharedresources.hxx"
      33             : #include <comphelper/componentcontext.hxx>
      34             : 
      35             : using namespace connectivity;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::beans;
      38             : using namespace ::com::sun::star::sdbc;
      39             : using namespace ::com::sun::star::container;
      40             : using namespace ::com::sun::star::lang;
      41             : 
      42             : // -------------------------------------------------------------------------
      43           0 : java_sql_Driver::java_sql_Driver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
      44             :     :m_aContext( _rxFactory )
      45           0 :     ,m_aLogger( m_aContext.getUNOContext(), "sdbcl", "org.openoffice.sdbc.jdbcBridge" )
      46             : {
      47           0 : }
      48             : // --------------------------------------------------------------------------------
      49           0 : java_sql_Driver::~java_sql_Driver()
      50             : {
      51           0 : }
      52             : 
      53             : // static ServiceInfo
      54             : //------------------------------------------------------------------------------
      55           0 : rtl::OUString java_sql_Driver::getImplementationName_Static(  ) throw(RuntimeException)
      56             : {
      57           0 :     return ::rtl::OUString("com.sun.star.comp.sdbc.JDBCDriver");
      58             :         // this name is referenced in the configuration and in the jdbc.xml
      59             :         // Please take care when changing it.
      60             : }
      61             : //------------------------------------------------------------------------------
      62           0 : Sequence< ::rtl::OUString > java_sql_Driver::getSupportedServiceNames_Static(  ) throw (RuntimeException)
      63             : {
      64           0 :     Sequence< ::rtl::OUString > aSNS( 1 );
      65           0 :     aSNS[0] = ::rtl::OUString("com.sun.star.sdbc.Driver");
      66           0 :     return aSNS;
      67             : }
      68             : //------------------------------------------------------------------
      69           0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
      70             : {
      71           0 :     return *(new java_sql_Driver(_rxFactory));
      72             : }
      73             : // --------------------------------------------------------------------------------
      74           0 : ::rtl::OUString SAL_CALL java_sql_Driver::getImplementationName(  ) throw(RuntimeException)
      75             : {
      76           0 :     return getImplementationName_Static();
      77             : }
      78             : 
      79             : // --------------------------------------------------------------------------------
      80           0 : sal_Bool SAL_CALL java_sql_Driver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
      81             : {
      82           0 :     Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
      83           0 :     const ::rtl::OUString* pSupported = aSupported.getConstArray();
      84           0 :     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
      85           0 :     for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
      86             :         ;
      87             : 
      88           0 :     return pSupported != pEnd;
      89             : }
      90             : 
      91             : // --------------------------------------------------------------------------------
      92           0 : Sequence< ::rtl::OUString > SAL_CALL java_sql_Driver::getSupportedServiceNames(  ) throw(RuntimeException)
      93             : {
      94           0 :     return getSupportedServiceNames_Static();
      95             : }
      96             : // -------------------------------------------------------------------------
      97           0 : Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUString& url, const
      98             :                                                          Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
      99             : {
     100           0 :     m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_CONNECTING_URL, url );
     101             : 
     102           0 :     Reference< XConnection > xOut;
     103           0 :     if ( acceptsURL(url ) )
     104             :     {
     105           0 :         java_sql_Connection* pConnection = new java_sql_Connection( *this );
     106           0 :         xOut = pConnection;
     107           0 :         if ( !pConnection->construct(url,info) )
     108           0 :             xOut.clear(); // an error occurred and the java driver didn't throw an exception
     109             :         else
     110           0 :             m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS );
     111             :     }
     112           0 :     return xOut;
     113             : }
     114             : // -------------------------------------------------------------------------
     115           0 : sal_Bool SAL_CALL java_sql_Driver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
     116             : {
     117             :     // don't ask the real driver for the url
     118             :     // I feel responsible for all jdbc url's
     119           0 :     sal_Bool bEnabled = sal_False;
     120           0 :     OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
     121           0 :     static const ::rtl::OUString s_sJdbcPrefix(  "jdbc:" );
     122           0 :     return bEnabled && 0 == url.compareTo(s_sJdbcPrefix, 5);
     123             : }
     124             : // -------------------------------------------------------------------------
     125           0 : Sequence< DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const ::rtl::OUString& url,
     126             :                                                                          const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
     127             : {
     128           0 :     if ( acceptsURL(url) )
     129             :     {
     130           0 :         ::std::vector< DriverPropertyInfo > aDriverInfo;
     131             : 
     132           0 :         Sequence< ::rtl::OUString > aBooleanValues(2);
     133           0 :         aBooleanValues[0] = ::rtl::OUString(  "false"  );
     134           0 :         aBooleanValues[1] = ::rtl::OUString(  "true"  );
     135             : 
     136             :         aDriverInfo.push_back(DriverPropertyInfo(
     137             :                 ::rtl::OUString("JavaDriverClass")
     138             :                 ,::rtl::OUString("The JDBC driver class name.")
     139             :                 ,sal_True
     140             :                 ,::rtl::OUString()
     141             :                 ,Sequence< ::rtl::OUString >())
     142           0 :         );
     143             :         aDriverInfo.push_back(DriverPropertyInfo(
     144             :                 ::rtl::OUString("JavaDriverClassPath")
     145             :                 ,::rtl::OUString("The class path where to look for the JDBC driver.")
     146             :                 ,sal_True
     147             :                 ,::rtl::OUString(  ""  )
     148             :                 ,Sequence< ::rtl::OUString >())
     149           0 :         );
     150             :         aDriverInfo.push_back(DriverPropertyInfo(
     151             :                 ::rtl::OUString("SystemProperties")
     152             :                 ,::rtl::OUString("Additional properties to set at java.lang.System before loading the driver.")
     153             :                 ,sal_True
     154             :                 ,::rtl::OUString(  ""  )
     155             :                 ,Sequence< ::rtl::OUString >())
     156           0 :         );
     157             :         aDriverInfo.push_back(DriverPropertyInfo(
     158             :                 ::rtl::OUString("ParameterNameSubstitution")
     159             :                 ,::rtl::OUString("Change named parameters with '?'.")
     160             :                 ,sal_False
     161             :                 ,::rtl::OUString(  "false"  )
     162             :                 ,aBooleanValues)
     163           0 :         );
     164             :         aDriverInfo.push_back(DriverPropertyInfo(
     165             :                 ::rtl::OUString("IgnoreDriverPrivileges")
     166             :                 ,::rtl::OUString("Ignore the privileges from the database driver.")
     167             :                 ,sal_False
     168             :                 ,::rtl::OUString(  "false"  )
     169             :                 ,aBooleanValues)
     170           0 :         );
     171             :         aDriverInfo.push_back(DriverPropertyInfo(
     172             :                 ::rtl::OUString("IsAutoRetrievingEnabled")
     173             :                 ,::rtl::OUString("Retrieve generated values.")
     174             :                 ,sal_False
     175             :                 ,::rtl::OUString(  "false"  )
     176             :                 ,aBooleanValues)
     177           0 :         );
     178             :         aDriverInfo.push_back(DriverPropertyInfo(
     179             :                 ::rtl::OUString("AutoRetrievingStatement")
     180             :                 ,::rtl::OUString("Auto-increment statement.")
     181             :                 ,sal_False
     182             :                 ,::rtl::OUString()
     183             :                 ,Sequence< ::rtl::OUString >())
     184           0 :         );
     185             :         aDriverInfo.push_back(DriverPropertyInfo(
     186             :                 ::rtl::OUString("GenerateASBeforeCorrelationName")
     187             :                 ,::rtl::OUString("Generate AS before table correlation names.")
     188             :                 ,sal_False
     189             :                 ,::rtl::OUString(  "true"  )
     190             :                 ,aBooleanValues)
     191           0 :         );
     192             :         aDriverInfo.push_back(DriverPropertyInfo(
     193             :                 ::rtl::OUString("IgnoreCurrency")
     194             :                 ,::rtl::OUString("Ignore the currency field from the ResultsetMetaData.")
     195             :                 ,sal_False
     196             :                 ,::rtl::OUString(  "false"  )
     197             :                 ,aBooleanValues)
     198           0 :         );
     199             :         aDriverInfo.push_back(DriverPropertyInfo(
     200             :                 ::rtl::OUString("EscapeDateTime")
     201             :                 ,::rtl::OUString("Escape date time format.")
     202             :                 ,sal_False
     203             :                 ,::rtl::OUString(  "true"  )
     204             :                 ,aBooleanValues)
     205           0 :         );
     206             :         aDriverInfo.push_back(DriverPropertyInfo(
     207             :                 ::rtl::OUString("TypeInfoSettings")
     208             :                 ,::rtl::OUString("Defines how the type info of the database metadata should be manipulated.")
     209             :                 ,sal_False
     210             :                 ,::rtl::OUString( )
     211             :                 ,Sequence< ::rtl::OUString > ())
     212           0 :         );
     213             :         aDriverInfo.push_back(DriverPropertyInfo(
     214             :                 ::rtl::OUString("ImplicitCatalogRestriction")
     215             :                 ,::rtl::OUString("The catalog which should be used in getTables calls, when the caller passed NULL.")
     216             :                 ,sal_False
     217             :                 ,::rtl::OUString( )
     218             :                 ,Sequence< ::rtl::OUString > ())
     219           0 :         );
     220             :         aDriverInfo.push_back(DriverPropertyInfo(
     221             :                 ::rtl::OUString("ImplicitSchemaRestriction")
     222             :                 ,::rtl::OUString("The schema which should be used in getTables calls, when the caller passed NULL.")
     223             :                 ,sal_False
     224             :                 ,::rtl::OUString( )
     225             :                 ,Sequence< ::rtl::OUString > ())
     226           0 :         );
     227           0 :         return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
     228             :     }
     229           0 :     ::connectivity::SharedResources aResources;
     230           0 :     const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
     231           0 :     ::dbtools::throwGenericSQLException(sMessage ,*this);
     232           0 :     return Sequence< DriverPropertyInfo >();
     233             : }
     234             : // -------------------------------------------------------------------------
     235           0 : sal_Int32 SAL_CALL java_sql_Driver::getMajorVersion(  ) throw(RuntimeException)
     236             : {
     237           0 :     return 1;
     238             : }
     239             : // -------------------------------------------------------------------------
     240           0 : sal_Int32 SAL_CALL java_sql_Driver::getMinorVersion(  ) throw(RuntimeException)
     241             : {
     242           0 :     return 0;
     243             : }
     244             : // -------------------------------------------------------------------------
     245             : 
     246             : 
     247             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10