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