Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / dbase / DConnection.cxx
blob49bb15fe5ed9548526ed9e5ad48f91e32561f0c7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DConnection.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
34 #ifndef _CONNECTIVITY_DBASE_OCONNECTION_HXX_
35 #include "dbase/DConnection.hxx"
36 #endif
37 #include "dbase/DDatabaseMetaData.hxx"
38 #include "dbase/DCatalog.hxx"
39 #ifndef _CONNECTIVITY_DBASE_ODRIVER_HXX_
40 #include "dbase/DDriver.hxx"
41 #endif
42 #include <com/sun/star/lang/DisposedException.hpp>
43 #include <tools/urlobj.hxx>
44 #include "dbase/DPreparedStatement.hxx"
45 #include "dbase/DStatement.hxx"
46 #include <tools/debug.hxx>
47 #include <connectivity/dbexception.hxx>
49 using namespace connectivity::dbase;
50 using namespace connectivity::file;
52 typedef connectivity::file::OConnection OConnection_BASE;
54 //------------------------------------------------------------------------------
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::beans;
57 using namespace ::com::sun::star::sdbcx;
58 using namespace ::com::sun::star::sdbc;
59 using namespace ::com::sun::star::lang;
61 DBG_NAME(ODbaseConnection)
62 // --------------------------------------------------------------------------------
63 ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver)
65 DBG_CTOR(ODbaseConnection,NULL);
66 m_aFilenameExtension = String::CreateFromAscii("dbf");
68 //-----------------------------------------------------------------------------
69 ODbaseConnection::~ODbaseConnection()
71 DBG_DTOR(ODbaseConnection,NULL);
74 // XServiceInfo
75 // --------------------------------------------------------------------------------
76 IMPLEMENT_SERVICE_INFO(ODbaseConnection, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection")
78 // --------------------------------------------------------------------------------
79 Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException)
81 ::osl::MutexGuard aGuard( m_aMutex );
82 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
85 Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
86 if(!xMetaData.is())
88 xMetaData = new ODbaseDatabaseMetaData(this);
89 m_xMetaData = xMetaData;
92 return xMetaData;
94 //------------------------------------------------------------------------------
95 ::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog()
97 ::osl::MutexGuard aGuard( m_aMutex );
98 Reference< XTablesSupplier > xTab = m_xCatalog;
99 if(!xTab.is())
101 ODbaseCatalog *pCat = new ODbaseCatalog(this);
102 xTab = pCat;
103 m_xCatalog = xTab;
105 return xTab;
107 // --------------------------------------------------------------------------------
108 Reference< XStatement > SAL_CALL ODbaseConnection::createStatement( ) throw(SQLException, RuntimeException)
110 ::osl::MutexGuard aGuard( m_aMutex );
111 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
114 Reference< XStatement > xReturn = new ODbaseStatement(this);
115 m_aStatements.push_back(WeakReferenceHelper(xReturn));
116 return xReturn;
118 // --------------------------------------------------------------------------------
119 Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
121 ::osl::MutexGuard aGuard( m_aMutex );
122 checkDisposed(OConnection_BASE::rBHelper.bDisposed);
125 ODbasePreparedStatement* pStmt = new ODbasePreparedStatement(this);
126 Reference< XPreparedStatement > xHoldAlive = pStmt;
127 pStmt->construct(sql);
128 m_aStatements.push_back(WeakReferenceHelper(*pStmt));
129 return pStmt;
131 // --------------------------------------------------------------------------------
132 Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
134 ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
135 return NULL;
137 // -----------------------------------------------------------------------------