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