1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_connectivity.hxx" 26 27 #ifndef _CONNECTIVITY_DBASE_OCONNECTION_HXX_ 28 #include "dbase/DConnection.hxx" 29 #endif 30 #include "dbase/DDatabaseMetaData.hxx" 31 #include "dbase/DCatalog.hxx" 32 #ifndef _CONNECTIVITY_DBASE_ODRIVER_HXX_ 33 #include "dbase/DDriver.hxx" 34 #endif 35 #include <com/sun/star/lang/DisposedException.hpp> 36 #include <tools/urlobj.hxx> 37 #include "dbase/DPreparedStatement.hxx" 38 #include "dbase/DStatement.hxx" 39 #include <tools/debug.hxx> 40 #include <connectivity/dbexception.hxx> 41 42 using namespace connectivity::dbase; 43 using namespace connectivity::file; 44 45 typedef connectivity::file::OConnection OConnection_BASE; 46 47 //------------------------------------------------------------------------------ 48 using namespace ::com::sun::star::uno; 49 using namespace ::com::sun::star::beans; 50 using namespace ::com::sun::star::sdbcx; 51 using namespace ::com::sun::star::sdbc; 52 using namespace ::com::sun::star::lang; 53 54 DBG_NAME(ODbaseConnection) 55 // -------------------------------------------------------------------------------- 56 ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver) 57 { 58 DBG_CTOR(ODbaseConnection,NULL); 59 m_aFilenameExtension = String::CreateFromAscii("dbf"); 60 } 61 //----------------------------------------------------------------------------- 62 ODbaseConnection::~ODbaseConnection() 63 { 64 DBG_DTOR(ODbaseConnection,NULL); 65 } 66 67 // XServiceInfo 68 // -------------------------------------------------------------------------------- 69 IMPLEMENT_SERVICE_INFO(ODbaseConnection, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection") 70 71 // -------------------------------------------------------------------------------- 72 Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException) 73 { 74 ::osl::MutexGuard aGuard( m_aMutex ); 75 checkDisposed(OConnection_BASE::rBHelper.bDisposed); 76 77 78 Reference< XDatabaseMetaData > xMetaData = m_xMetaData; 79 if(!xMetaData.is()) 80 { 81 xMetaData = new ODbaseDatabaseMetaData(this); 82 m_xMetaData = xMetaData; 83 } 84 85 return xMetaData; 86 } 87 //------------------------------------------------------------------------------ 88 ::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog() 89 { 90 ::osl::MutexGuard aGuard( m_aMutex ); 91 Reference< XTablesSupplier > xTab = m_xCatalog; 92 if(!xTab.is()) 93 { 94 ODbaseCatalog *pCat = new ODbaseCatalog(this); 95 xTab = pCat; 96 m_xCatalog = xTab; 97 } 98 return xTab; 99 } 100 // -------------------------------------------------------------------------------- 101 Reference< XStatement > SAL_CALL ODbaseConnection::createStatement( ) throw(SQLException, RuntimeException) 102 { 103 ::osl::MutexGuard aGuard( m_aMutex ); 104 checkDisposed(OConnection_BASE::rBHelper.bDisposed); 105 106 107 Reference< XStatement > xReturn = new ODbaseStatement(this); 108 m_aStatements.push_back(WeakReferenceHelper(xReturn)); 109 return xReturn; 110 } 111 // -------------------------------------------------------------------------------- 112 Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) 113 { 114 ::osl::MutexGuard aGuard( m_aMutex ); 115 checkDisposed(OConnection_BASE::rBHelper.bDisposed); 116 117 118 ODbasePreparedStatement* pStmt = new ODbasePreparedStatement(this); 119 Reference< XPreparedStatement > xHoldAlive = pStmt; 120 pStmt->construct(sql); 121 m_aStatements.push_back(WeakReferenceHelper(*pStmt)); 122 return pStmt; 123 } 124 // -------------------------------------------------------------------------------- 125 Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) 126 { 127 ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this ); 128 return NULL; 129 } 130 // ----------------------------------------------------------------------------- 131 132