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 :
21 : #include "dbase/DConnection.hxx"
22 : #include "dbase/DDatabaseMetaData.hxx"
23 : #include "dbase/DCatalog.hxx"
24 : #include "dbase/DDriver.hxx"
25 : #include <com/sun/star/lang/DisposedException.hpp>
26 : #include "dbase/DPreparedStatement.hxx"
27 : #include "dbase/DStatement.hxx"
28 : #include <tools/debug.hxx>
29 : #include <connectivity/dbexception.hxx>
30 :
31 : using namespace connectivity::dbase;
32 : using namespace connectivity::file;
33 :
34 : typedef connectivity::file::OConnection OConnection_BASE;
35 :
36 : //------------------------------------------------------------------------------
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::beans;
39 : using namespace ::com::sun::star::sdbcx;
40 : using namespace ::com::sun::star::sdbc;
41 : using namespace ::com::sun::star::lang;
42 :
43 : DBG_NAME(ODbaseConnection)
44 : // --------------------------------------------------------------------------------
45 0 : ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver)
46 : {
47 : DBG_CTOR(ODbaseConnection,NULL);
48 0 : m_aFilenameExtension = rtl::OUString("dbf");
49 0 : }
50 : //-----------------------------------------------------------------------------
51 0 : ODbaseConnection::~ODbaseConnection()
52 : {
53 : DBG_DTOR(ODbaseConnection,NULL);
54 0 : }
55 :
56 : // XServiceInfo
57 : // --------------------------------------------------------------------------------
58 0 : IMPLEMENT_SERVICE_INFO(ODbaseConnection, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection")
59 :
60 : // --------------------------------------------------------------------------------
61 0 : Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException)
62 : {
63 0 : ::osl::MutexGuard aGuard( m_aMutex );
64 0 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
65 :
66 :
67 0 : Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
68 0 : if(!xMetaData.is())
69 : {
70 0 : xMetaData = new ODbaseDatabaseMetaData(this);
71 0 : m_xMetaData = xMetaData;
72 : }
73 :
74 0 : return xMetaData;
75 : }
76 : //------------------------------------------------------------------------------
77 0 : ::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog()
78 : {
79 0 : ::osl::MutexGuard aGuard( m_aMutex );
80 0 : Reference< XTablesSupplier > xTab = m_xCatalog;
81 0 : if(!xTab.is())
82 : {
83 0 : ODbaseCatalog *pCat = new ODbaseCatalog(this);
84 0 : xTab = pCat;
85 0 : m_xCatalog = xTab;
86 : }
87 0 : return xTab;
88 : }
89 : // --------------------------------------------------------------------------------
90 0 : Reference< XStatement > SAL_CALL ODbaseConnection::createStatement( ) throw(SQLException, RuntimeException)
91 : {
92 0 : ::osl::MutexGuard aGuard( m_aMutex );
93 0 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
94 :
95 :
96 0 : Reference< XStatement > xReturn = new ODbaseStatement(this);
97 0 : m_aStatements.push_back(WeakReferenceHelper(xReturn));
98 0 : return xReturn;
99 : }
100 : // --------------------------------------------------------------------------------
101 0 : Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
102 : {
103 0 : ::osl::MutexGuard aGuard( m_aMutex );
104 0 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
105 :
106 :
107 0 : ODbasePreparedStatement* pStmt = new ODbasePreparedStatement(this);
108 0 : Reference< XPreparedStatement > xHoldAlive = pStmt;
109 0 : pStmt->construct(sql);
110 0 : m_aStatements.push_back(WeakReferenceHelper(*pStmt));
111 0 : return pStmt;
112 : }
113 : // --------------------------------------------------------------------------------
114 0 : Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
115 : {
116 0 : ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
117 0 : return NULL;
118 : }
119 : // -----------------------------------------------------------------------------
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|