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 29 : ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver)
43 : {
44 29 : m_aFilenameExtension = "dbf";
45 29 : }
46 :
47 58 : ODbaseConnection::~ODbaseConnection()
48 : {
49 58 : }
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 2721 : Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException, std::exception)
57 : {
58 2721 : ::osl::MutexGuard aGuard( m_aMutex );
59 2721 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
60 :
61 :
62 2721 : Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
63 2721 : if(!xMetaData.is())
64 : {
65 29 : xMetaData = new ODbaseDatabaseMetaData(this);
66 29 : m_xMetaData = xMetaData;
67 : }
68 :
69 2721 : return xMetaData;
70 : }
71 :
72 93 : ::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog()
73 : {
74 93 : ::osl::MutexGuard aGuard( m_aMutex );
75 93 : Reference< XTablesSupplier > xTab = m_xCatalog;
76 93 : if(!xTab.is())
77 : {
78 29 : ODbaseCatalog *pCat = new ODbaseCatalog(this);
79 29 : xTab = pCat;
80 29 : m_xCatalog = xTab;
81 : }
82 93 : return xTab;
83 : }
84 :
85 11 : Reference< XStatement > SAL_CALL ODbaseConnection::createStatement( ) throw(SQLException, RuntimeException, std::exception)
86 : {
87 11 : ::osl::MutexGuard aGuard( m_aMutex );
88 11 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
89 :
90 :
91 11 : Reference< XStatement > xReturn = new ODbaseStatement(this);
92 11 : m_aStatements.push_back(WeakReferenceHelper(xReturn));
93 11 : return xReturn;
94 : }
95 :
96 53 : Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareStatement( const OUString& sql ) throw(SQLException, RuntimeException, std::exception)
97 : {
98 53 : ::osl::MutexGuard aGuard( m_aMutex );
99 53 : checkDisposed(OConnection_BASE::rBHelper.bDisposed);
100 :
101 :
102 53 : ODbasePreparedStatement* pStmt = new ODbasePreparedStatement(this);
103 106 : Reference< XPreparedStatement > xHoldAlive = pStmt;
104 53 : pStmt->construct(sql);
105 42 : m_aStatements.push_back(WeakReferenceHelper(*pStmt));
106 95 : 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: */
|