1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <connectivity/sqlparse.hxx>
21 #include <connectivity/sqliterator.hxx>
22 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
23 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
24 #include <com/sun/star/sdbc/XResultSet.hpp>
25 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
26 #include <com/sun/star/sdbc/XRow.hpp>
27 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/beans/PropertyState.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <cppuhelper/servicefactory.hxx>
32 #include <com/sun/star/sdbc/XConnection.hpp>
33 #include <com/sun/star/sdbc/XDriver.hpp>
34 #include <connectivity/sqlnode.hxx>
36 using namespace connectivity
;
37 using namespace com::sun::star::sdbc
;
38 using namespace com::sun::star
;
39 using namespace com::sun::star::uno
;
40 using namespace com::sun::star::beans
;
45 void main( int argc
, char * argv
[] )
47 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> m_xConnection
;
48 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> m_xDriver
;
51 Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xFac
=
52 createRegistryServiceFactory(OUString("g:\\office50\\program\\applicat.rdb"),OUString());
56 m_xDriver
= Reference
<XDriver
>(xFac
->createInstance("com.sun.star.sdbc.driver.dbase.Driver"),UNO_QUERY
);
60 Sequence
<PropertyValue
> aValue
;
61 // aValue.getArray()[0] = PropertyValue( OUString("user"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE);
62 // aValue.getArray()[1] = PropertyValue( OUString("password"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE);
64 m_xConnection
= m_xDriver
->connect(OUString("sdbc:dbase:g:\\"),aValue
);
65 if(m_xConnection
.is())
67 Reference
<XStatement
> xStmt
= m_xConnection
->createStatement();
70 Reference
<XResultSet
> xRes
= xStmt
->executeQuery(OUString("SELECT * FROM Tele"));
73 OUString
aPat( "%s\t" );
74 Reference
<XRow
> xRow(xRes
,UNO_QUERY
);
75 Reference
<XResultSetMetaData
> xMeta
= Reference
<XResultSetMetaDataSupplier
>(xRes
,UNO_QUERY
)->getMetaData();
76 for(sal_Int32 i
=1;i
<xMeta
->getColumnCount();++i
)
78 wprintf(aPat
.getStr(), xMeta
->getColumnName(i
).getStr());
80 printf("----------------------------------------------------------------------\n");
83 for(sal_Int32 j
=1;j
<xMeta
->getColumnCount();++j
)
84 wprintf(aPat
.getStr(), xRow
->getString(j
).getStr());
95 printf("Exception thrown!\n");
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */