Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 68893 invoked from network); 25 Jun 2007 02:13:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Jun 2007 02:13:20 -0000 Received: (qmail 9382 invoked by uid 500); 25 Jun 2007 02:13:24 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 9356 invoked by uid 500); 25 Jun 2007 02:13:23 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 9341 invoked by uid 99); 25 Jun 2007 02:13:23 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jun 2007 19:13:23 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jun 2007 19:13:18 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 1B2601A981A; Sun, 24 Jun 2007 19:12:58 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r550317 - in /incubator/tuscany/cpp/das: ./ VSExpress/tuscany_das/ runtime/core/include/apache/das/rdb/ runtime/core/src/apache/das/ runtime/core/src/apache/das/rdb/ samples/ samples/SimpleRead/ samples/SimpleRead/VSExpress/ samples/SimpleR... Date: Mon, 25 Jun 2007 02:12:57 -0000 To: tuscany-commits@ws.apache.org From: adrianocrestani@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070625021258.1B2601A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: adrianocrestani Date: Sun Jun 24 19:12:55 2007 New Revision: 550317 URL: http://svn.apache.org/viewvc?view=rev&rev=550317 Log: - Added constructor on Connection class that accepts a connection string - Added SimpleRead samples - Added Getting Started documentation Added: incubator/tuscany/cpp/das/GettingStarted.html incubator/tuscany/cpp/das/samples/ incubator/tuscany/cpp/das/samples/SimpleRead/ incubator/tuscany/cpp/das/samples/SimpleRead/Readme.html incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/ incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/ incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.sln incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.suo (with props) incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/SimpleRead.vcproj incubator/tuscany/cpp/das/samples/SimpleRead/rsc/ incubator/tuscany/cpp/das/samples/SimpleRead/rsc/SimpleRead.fdb (with props) incubator/tuscany/cpp/das/samples/SimpleRead/src/ incubator/tuscany/cpp/das/samples/SimpleRead/src/main.cpp Modified: incubator/tuscany/cpp/das/VSExpress/tuscany_das/tuscany_das.suo incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h incubator/tuscany/cpp/das/runtime/core/src/apache/das/DataGraphPrinter.cpp incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Connection.cpp Added: incubator/tuscany/cpp/das/GettingStarted.html URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/GettingStarted.html?view=auto&rev=550317 ============================================================================== --- incubator/tuscany/cpp/das/GettingStarted.html (added) +++ incubator/tuscany/cpp/das/GettingStarted.html Sun Jun 24 19:12:55 2007 @@ -0,0 +1,157 @@ + + + + + Tuscany - Getting Started + + + + + + + + + +
+



+

+
+

Tuscany - + Getting Started - DAS C++

+

This document describes what is needed to install + Tuscany DAS for C++. If you haven't already done so, the first step + is to download the DAS C++ from its repository: + https://svn.apache.org/repos/asf/incubator/tuscany/cpp/das/. +

+

Contents

+
    +
  1. System + Requirements +

    +
  2. Installing + Tuscany DAS C++ on Windows.

    +
  3. Samples +

    +
  4. Getting Help +

    +
+

System Requirements

+

In order to use Tuscany DAS there are some minimum + requirements:

+ + + + + + + + + + + + + + + +
+

Software

+
+

Download Link

+
+

Operating systems: +

+
    +
  • Windows XP SP2 +

    +
+
+

Tuscany SDO C++ (from the trunk)

+
+

To compile and install Tuscany SDO C++ follow + the instructions on + https://svn.apache.org/repos/asf/incubator/tuscany/cpp/sdo/GettingStarted.html + page. But instead of download the source from Tuscany downloads page, download the SDO C++ source from the trunk: https://svn.apache.org/repos/asf/incubator/tuscany/cpp/sdo/

+
+

Installing Tuscany DAS + C++ on Windows

+
    +
  1. Download the + contents under + https://svn.apache.org/repos/asf/incubator/tuscany/cpp/das/ + into folder <tuscany_das_cpp>.

    +
  2. The following + environment variables are required: +

    +
      +
    • TUSCANY_SDOCPP=<path + to tuscany sdo for c++ folder> +

      +
    +
  3. Build the source + using Visual Studio Express solution under folder + <tuscany_das_cpp>/VSExpress/das_runtime/.

    +
  4. Run the testcases: +

    +
      +
    • <tuscany_das_cpp>/VSExpress/das_runtime/das_test/Debug/das_test.exe +

      +
    +

    The output of all tests must show “OK”.

    +
+

Samples

+ + + + + +
+

SimpleRead

+
+

This sample shows how to load data from a RDB + source, using RDB DAS, into a SDO graph and then retrieve data from + it. +

+
+

Getting Help

+

Any problem with this release can be reported to + the Tuscany mailing + lists or create a JIRA issue + at http://issues.apache.org/jira/browse/Tuscany.

+

 

+ + + + +
+

Thank you for your interest in Tuscany.

+

-The Tuscany Development Team +

+
+
+
+ + \ No newline at end of file Modified: incubator/tuscany/cpp/das/VSExpress/tuscany_das/tuscany_das.suo URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/VSExpress/tuscany_das/tuscany_das.suo?view=diff&rev=550317&r1=550316&r2=550317 ============================================================================== Binary files - no diff available. Modified: incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h?view=diff&rev=550317&r1=550316&r2=550317 ============================================================================== --- incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h (original) +++ incubator/tuscany/cpp/das/runtime/core/include/apache/das/rdb/Connection.h Sun Jun 24 19:12:55 2007 @@ -47,7 +47,8 @@ std::list statements; public: - Connection(string dns, string user, string password) throw (SqlException); + Connection(string dsn, string user, string password) throw (SqlException); + Connection(string connectString) throw (SqlException); virtual ~Connection(void); SQLHDBC getODBCConnection(void) const; void commit(void); Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/DataGraphPrinter.cpp URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/DataGraphPrinter.cpp?view=diff&rev=550317&r1=550316&r2=550317 ============================================================================== --- incubator/tuscany/cpp/das/runtime/core/src/apache/das/DataGraphPrinter.cpp (original) +++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/DataGraphPrinter.cpp Sun Jun 24 19:12:55 2007 @@ -36,7 +36,7 @@ out << std::endl << "[" << typeList[i].getName(); const commonj::sdo::Type* base = typeList[i].getBaseType(); - out << "{"; + /*out << "{"; out << " baseType = " << ((base == 0) ? "NULL" : base->getName()); out << " uri = " << typeList[i].getURI(); out << " abstractType = " << typeList[i].isAbstractType(); @@ -44,15 +44,15 @@ out << " dataObjectType = " << typeList[i].isDataObjectType(); out << " dataType = " << typeList[i].isDataType(); out << " openType = " << typeList[i].isOpenType(); - out << " sequencedType = " << typeList[i].isSequencedType(); - out << "} ]" << std::endl; + out << " sequencedType = " << typeList[i].isSequencedType() << " } ";*/ + out << "]" << std::endl; commonj::sdo::PropertyList propertyList = typeList[i].getProperties(); for (unsigned int j = 0 ; j < propertyList.size() ; j++) { - out << propertyList[j].getName(); - out << "{"; + out << propertyList[j].getName() << std::endl; + /*out << "{"; out << " type = " << propertyList[j].getType().getName(); out << " alias = " << propertyList[j].getAlias(); out << " aliasCount = " << propertyList[j].getAliasCount(); @@ -61,7 +61,7 @@ out << " many = " << propertyList[j].isMany(); out << " readOnly = " << propertyList[j].isReadOnly(); out << " reference = " << propertyList[j].isReference(); - out << "}" << std::endl; + out << "}" << std::endl;*/ } @@ -74,7 +74,7 @@ void DataGraphPrinter::printDataGraph(commonj::sdo::DataObjectPtr dataObject, bool ref) { std::ostream& out = *this->out; commonj::sdo::PropertyList& propertyList = dataObject->getType().getProperties(); - out << getTab(tabCount) << "[" << dataObject->getType().getName() << "]"; + out << getTab(tabCount) << "[" << dataObject->getType().getURI() << "." << dataObject->getType().getName() << "]"; tabCount++; for (unsigned int i = 0 ; i < propertyList.size() ; i++) { Modified: incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Connection.cpp URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Connection.cpp?view=diff&rev=550317&r1=550316&r2=550317 ============================================================================== --- incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Connection.cpp (original) +++ incubator/tuscany/cpp/das/runtime/core/src/apache/das/rdb/Connection.cpp Sun Jun 24 19:12:55 2007 @@ -22,7 +22,7 @@ namespace das { namespace rdb { -Connection::Connection(string dns, string user, string password) throw (SqlException){ +Connection::Connection(string dsn, string user, string password) throw (SqlException){ SQLRETURN result; SQLINTEGER error; @@ -55,7 +55,7 @@ setAutoCommit(false); //Connect to the datasource - result = SQLConnect(connection, reinterpret_cast(const_cast (dns.c_str())), SQL_NTS, + result = SQLConnect(connection, reinterpret_cast(const_cast (dsn.c_str())), SQL_NTS, reinterpret_cast(const_cast (user.c_str())), SQL_NTS, reinterpret_cast(const_cast (password.c_str())), SQL_NTS); @@ -66,6 +66,61 @@ SQLFreeHandle(SQL_HANDLE_DBC, connection); SQLFreeHandle(SQL_HANDLE_ENV, environment); + + string error("Error to establish the connection.\nSQLSTATE: "); + error += reinterpret_cast(&sqlStat); + throw SqlException(error.c_str()); + } + +} + +Connection::Connection(string connectString) throw (SqlException) { + SQLRETURN result; + + SQLINTEGER error; + SQLCHAR sqlStat; + SQLCHAR * message = 0; + SQLSMALLINT messageLength; + SQLCHAR outConnectString[1024]; + + //Alloc environment handle + result = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&environment); + + if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) + throw SqlException("Error to alloc the environment handle - SQLHENV"); + + //Set the environment + result = SQLSetEnvAttr(environment, SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3, 0); + + if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){ + SQLFreeHandle(SQL_HANDLE_ENV, environment); + throw SqlException("Error to set the environment handle - SQLHENV"); + } + + //Allocate connection handle + result = SQLAllocHandle(SQL_HANDLE_DBC, environment, &connection); + + if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){ + SQLFreeHandle(SQL_HANDLE_ENV, environment); + throw SqlException("Error to alloc the connection handle - SQLHDBC"); + } + + setAutoCommit(false); + + //Connect to the datasource + result = SQLDriverConnect( connection, 0, (SQLCHAR*) (char*) connectString.c_str(), SQL_NTS, + (SQLCHAR*)outConnectString, sizeof(outConnectString), + &messageLength, SQL_DRIVER_COMPLETE ); + + if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)){ + + SQLGetDiagRec(SQL_HANDLE_DBC, connection,1, + &sqlStat, &error,message,100,&messageLength); + + SQLFreeHandle(SQL_HANDLE_DBC, connection); + SQLFreeHandle(SQL_HANDLE_ENV, environment); + + string outC = (char*) outConnectString; string error("Error to establish the connection.\nSQLSTATE: "); error += reinterpret_cast(&sqlStat); Added: incubator/tuscany/cpp/das/samples/SimpleRead/Readme.html URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/Readme.html?view=auto&rev=550317 ============================================================================== --- incubator/tuscany/cpp/das/samples/SimpleRead/Readme.html (added) +++ incubator/tuscany/cpp/das/samples/SimpleRead/Readme.html Sun Jun 24 19:12:55 2007 @@ -0,0 +1,195 @@ + + + + + + + + Tuscany RDB DAS Sample + + + + + + + + + + + + + + + + + +

Tuscany RDB DAS Sample (SimpleRead) 

+

This sample shows how to load data from a RDB source, +using RDB DAS, into a SDO graph and then retrieve data from it.

+

Setup

+ +

Compiling the Sample

+

Compile the sample source using Visual Studio Express +solution under <tuscany_das_cpp>/samples/SimpleRead/VSExpress/.

+

Running the Sample

+

To run the +sample execute the file +<tuscany_das_cpp>/samples/SimpleRead/VSExpress/debug/SimpleRead.exe

+

Requirements:

+
    +
  • Firebird must be running as Superserver and + accepting connection from localhost.

    +
  • The sample tries to access the data source using + user “SYSDA” and password “masterkey”. You + can modify it to meet your firebird user and password access on + sample main function:

    +
+

...

+

string +user = "SYSDBA";

+

string +password = "masterkey";

+

...

+ +

Sample Architecture

+

The sample files are located under +<tuscany_das_cpp>/samples/SimpleRead/.

+

Contents:

+
    +
  • /src/main.cpp: This file contains the sample + code that prints the animals table's data that is stored on + /rsc/SimpleRead.fdb data source.

    +
+
    +
  • /rsc/SimpleRead.fdb: This is a Firebird data + source file that contains a table called “animals” + created with the following sql:

    +
+

CREATE +TABLE animals ( +

+

id +INT NOT NULL, +

+

name +VARCHAR(20), +

+

PRIMARY +KEY (id) +

+

); + +

+ + \ No newline at end of file Added: incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.sln URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.sln?view=auto&rev=550317 ============================================================================== --- incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.sln (added) +++ incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.sln Sun Jun 24 19:12:55 2007 @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleRead", "SimpleRead\SimpleRead.vcproj", "{AAA4B06B-A3FA-485D-A450-4965B6EF2F58}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Debug|Win32.ActiveCfg = Debug|Win32 + {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Debug|Win32.Build.0 = Debug|Win32 + {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Release|Win32.ActiveCfg = Release|Win32 + {AAA4B06B-A3FA-485D-A450-4965B6EF2F58}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.suo URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.suo?view=auto&rev=550317 ============================================================================== Binary file - no diff available. Propchange: incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead.suo ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/SimpleRead.vcproj URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/SimpleRead.vcproj?view=auto&rev=550317 ============================================================================== --- incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/SimpleRead.vcproj (added) +++ incubator/tuscany/cpp/das/samples/SimpleRead/VSExpress/SimpleRead/SimpleRead.vcproj Sun Jun 24 19:12:55 2007 @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: incubator/tuscany/cpp/das/samples/SimpleRead/rsc/SimpleRead.fdb URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/rsc/SimpleRead.fdb?view=auto&rev=550317 ============================================================================== Binary file - no diff available. Propchange: incubator/tuscany/cpp/das/samples/SimpleRead/rsc/SimpleRead.fdb ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/tuscany/cpp/das/samples/SimpleRead/src/main.cpp URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/das/samples/SimpleRead/src/main.cpp?view=auto&rev=550317 ============================================================================== --- incubator/tuscany/cpp/das/samples/SimpleRead/src/main.cpp (added) +++ incubator/tuscany/cpp/das/samples/SimpleRead/src/main.cpp Sun Jun 24 19:12:55 2007 @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +// including DAS headers +#include +#include +#include +#include + +// including SDO header +#include + +using namespace apache::das::rdb; +using namespace apache::das; +using namespace commonj::sdo; +using namespace std; + +void main() { + char* tuscanyDASCPPPath = getenv("TUSCANY_DASCPP"); + + if (tuscanyDASCPPPath == 0) { + cout << "environment variable TUSCANY_DASCPP not set!" << endl; + system("PAUSE"); + return; + + } + + try { + // Connect to a database using a connect string + string user = "SYSDBA"; + string password = "masterkey"; + string dataSourcePath = (string) tuscanyDASCPPPath + "/../samples/SimpleRead/rsc/SimpleRead.fdb"; + + Connection connection( + "DRIVER=Firebird/InterBase(r) driver; " + + "UID=" + user + + "; PWD=" + masterkey + + ";DBNAME=localhost:" + dataSourcePath + ";" + ); + + // Create a DAS instance providing a connection using a factory + DASImpl* das = (DASImpl*) DASImpl::getFACTORY()->createDAS(connection); + + // Create a DAS command from a sql string + CommandPtr command = das->createCommand("SELECT * FROM animals;"); + + // Execute the command that returns the graph root data object + DataObjectPtr root = command->executeQuery(); + + // Gets the cart list + DataObjectList& cartList = root->getList("ANIMALS"); + + // for each cart on the list is printed the its id and name + for (int i = 0 ; i < cartList.size() ; i++) { + // Gets the cart id + long id = cartList[i]->getInteger("ID"); + + // Gets the the name string length and allocate enough space for it + unsigned int stringLength = cartList[i]->getLength("NAME"); + wchar_t* buffer = new wchar_t[stringLength]; + + // Gets the cart name + cartList[i]->getString("NAME", buffer, stringLength); + wstring name = wstring(buffer, stringLength); + + // Print the cart data + wcout << "[Animal: " << i << "]" << endl; + wcout << "\tid = " << id << endl; + wcout << "\tname = " << name << endl << endl; + + } + + system("PAUSE"); + + } catch (SqlException& ex) { + cout << "couldn't connect to the data source!" << endl; + system("PAUSE"); + return; + + } + + + +} --------------------------------------------------------------------- To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org For additional commands, e-mail: tuscany-commits-help@ws.apache.org