Not logged in : Login
(Sponging disallowed)

About: Sample ODBC Applications     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : sioc:Post, within Data Space : data.openlinksw.com associated with source document(s)
QRcode icon
http://data.openlinksw.com/describe/?url=http%3A%2F%2Fdocs.openlinksw.com%2Fvirtuoso%2Fsampleodbcapps.html

AttributesValues
has container
Date Created
  • Tue, 20 Nov 2012 21:00:55 GMT
  • Fri, 18 Jan 2013 15:31:20 GMT
  • Fri, 26 Apr 2013 18:19:35 GMT
  • Thu, 11 Jul 2013 21:22:54 GMT
  • Tue, 18 Mar 2014 15:54:37 GMT
  • Thu, 05 Feb 2015 21:17:51 GMT
described by
seeAlso
content
  • Sample ODBC Applications Mac OS X ODBCTEST: This is a simple 'C' based and ODBC compliant Interactive SQL processor. Open a Terminal session, and start ODBCTEST by executing the following command: /Library/iodbc/bin/odbctest At the SQL command prompt enter "?" for a list of ODBC DSNs on your machine or enter a valid ODBC Connect String. If you have a DSN named "Marketing" you would enter: DSN=Marketing;UID=username;PWD=password Note: If there is no password, you must include a semicolon at the end: DSN=Marketing;UID=sa;PWD=; Any valid SQL or ODBC command may be executed through this interface. The following example shows a connection to Microsoft SQL Server 2000, making a simple query against the sample Northwind database: [localhost:~] openlink% /Library/iodbc/bin/odbctest iODBC Demonstration program This program shows an interactive SQL processor Enter ODBC connect string (? shows list, or DSN=...): DSN=user_tthib_sql2k SQL>select au_lname, au_fname, state from authors where au_id < '333-33-3333' au_lname |au_fname |state ----------------------------------------+--------------------+----- White |Johnson |CA Green |Marjorie |CA Carson |Cheryl |CA O'Leary |Michael |CA Straight |Dean |CA 5 row(s) fetched. SQL>quit Again (y/n) ? n Have a nice day. [localhost:~] openlink% Windows 95/98/NT/2000 C++ Demo Go to the Virtuoso "Start Menu" item, then click on the "C++ Demo 32 Bit" menu item. C++ Demo Follow the Environment->Open Connection menu path. Selecting the "Open Connection" menu item results in the ODBC Driver Manager presenting you with a list of ODBC DSNs on your machine as depicted by the screen capture below: C++ Demo Select the ODBC DSN that you want to be connecting to, in this case "Local Virtuoso Demo" has been chosen since this will connect you to a sample Virtuoso database that has been populated with data. You are then presented with a Login Dialog by the Virtuoso driver for ODBC, enter a valid user name and password (default being user: demo and password: demo) into the appropriate fields. C++ Demo At this point you will be connected to the Virtuoso demonstration database, you can now use the SQL-->Execute SQL menu path to open up the Interactive SQL input dialog. Enter a valid SQL statement (see example in screen shot) and then click on the "OK" button. C++ Demo You will be presented with the results of your query. C++ Demo You exit this demo by following the Environment-->Close Connection menu path. ODBC Bench Test 32 Go to the Virtuoso "Start Menu" item, then click on the "ODBC Bench Test 32 Bit" menu item. You will be presented with the "Bench Test" interface. ODBC Bench Follow the File-Connect menu path which initializes the ODBC Driver Manager which in turn presents you with a list of ODBC DSN's installed on your machine. Select the DSN that you want to benchmark, remember that by benchmarking a DSN you are benchmarking the ODBC Driver that serves the DSN in question and the backend database engine that serves the ODBC Driver. Choose the "Local Virtuoso Demo" DSN if you want to benchmark Virtuoso. ODBC Bench You will then be presented with a Login Dialog by the Virtuoso driver for ODBC, enter a valid user name and password (default being user: demo and password: demo for the Demo database) into the appropriate fields. ODBC Bench Now follow the Bench-->Load Tables menu path and you will be presented with a dialog that enables you to configure key elements of your benchmark. Click the "Execute" button to commence the process of setting up your database for the benchmark tests. ODBC Bench As the process of loading data occurs, all the way up to completion, the benchmark program will provide status information into the benchmark output pane as shown below: ODBC Bench Now that all the benchmark data has been loaded into your database, follow the Bench-->Run Benchmark menu path and then configure your actual benchmark session parameters: These benchmark parameters fall into 3 categories, Timing Options, SQL Options, and Execution Options. ODBC Bench Timing Options: These setting allow you to configure the duration related aspects of this benchmark program Minutes - this is the duration of each benchmark run Runs - this controls how many iterations of the benchmarks you actually run (the default is one benchmark iteration with a duration of 5 minutes) SQL Options: These setting allow you to configure how your benchmark's SQL instructions are actually handled. ExecDirect with SQL Text - this means that no form of repetitive SQL execution optimization is being applied (SQL statements are prepared and executed repetitively) Prepare/Execute Bound Params - this means that the Parameter Binding SQL execution optimization is being applied (SQL is prepared once but executed many times without the overhead of re-preparing statements prior to execution) Use Stored Procedures - this means that the Stored Procedure SQL optimization is being applied (benchmark instructions are stored within database being benchmarked) Execution Options: These setting allow you to configure the tone of your benchmark, for instance it could have Transaction scoping and a mix of record retrieval queries, or it could simply be input and update intensive with a minimal amount of record retrieval queries (the case when the 100 row query checkbox is unchecked a typical OLTP scenario) Asynchronous - execute the benchmark instructions asynchronously Use Transactions - make the benchmark use transaction control (instructions are scoped to transaction blocks) Do 100 row Query - perform a simulation of a 100 record retrieval as part of the benchmark activity. Click on the "Run All" button if you would like all the different benchmark type combinations to be performed. When benchmark run complete benchmark data is written to the benchmark program's output pane. ODBC Bench The key pieces of benchmark data that you need to look out for are: Total Transactions: total number of transactions completed during the benchmark run Transactions Per Second number of transaction completed per second for the benchmark run Information from this benchmark is automatically written to an Excel format CSV (the file odbcbnch.csv) which makes it easy for you to graph and pivot data collated from several benchmark runs. A later version of this demo will actually write the benchmark data into an ODBC DSN that you provide thereby offering even more flexibility and accessibility to benchmark data. Linux & UNIX ODBCTEST: This is a simple 'C' based and ODBC compliant Interactive SQL processor. Run the script virtuoso-enterprise.sh to set up your environment: . virtuoso-enterprise.sh Start ODBCTEST by executing the following command: odbctest At the SQL command prompt enter "?" for a list of ODBC DSNs on your machine or enter a valid ODBC Connect String. If you have a DSN named "Marketing" you would enter: DSN=Marketing;UID=username;PWD=password Note: If there is no password, you must include a semicolon at the end: DSN=Marketing;UID=sa;PWD=; Any valid SQL or ODBC command may be executed through this interface. The following example shows a connection to Microsoft SQL Server 2000, making a simple query against the sample Northwind database: [localhost:~] openlink% odbctest iODBC Demonstration program This program shows an interactive SQL processor Enter ODBC connect string (? shows list, or DSN=...): DSN=test_sql2k SQL>select au_lname, au_fname, state from authors where au_id < '333-33-3333' au_lname |au_fname |state ----------------------------------------+--------------------+----- White |Johnson |CA Green |Marjorie |CA Carson |Cheryl |CA O'Leary |Michael |CA Straight |Dean |CA 5 row(s) fetched. SQL>quit Again (y/n) ? n Have a nice day. [localhost:~] openlink% MS DTC ODBC Sample Application The MS DTC demo is located in the <VIRTUOSO_INSTALLATION_DIRECTORY>\samples\odbc\MSDTCdemo1 folder. This demo shows usage of distributed transactions driven by MS DTC through the ODBC API. Setup The sample works with two instances of Virtuoso server. The running MS DTC service is needed. The servers must be started with MS DTC support (see Virtuoso documentation). First of all, edit the virt.odbc file. By default this file contains two connection strings of local Virtuoso servers running on port 1111 and port 1112, Each line begins with connection string to appropriate Virtuoso server. Initially this file contains the following lines: 1111 dba dba 00.sql 1112 dba dba 01.sql where 1111, 1112 are ports of two Virtuoso servers. "dba dba" - user and password. Initialization Start mtstest.exe +load in the <VIRTUOSO_INSTALLATION_DIRECTORY>\samples\odbc\MSDTCdemo1 folder. This must check whether all needed servers are running, create and initialize tables, procedures, etc. Test Run the command in the demo's working directory: mtstest.exe +exec N mtstest.exe +exec 0 where N - is a number of test iterations. The second command checks logical consistency of the tables. Description The demo source is start.c file in the <VIRTUOSO_INSTALLATION_DIRECTORY>\samples\odbc\MSDTCdemo1 directory. Several highlights of the most signficant parts of code are presented below: ITransactionDispenser *disp; ITransaction *transaction; ... HRESULT hr = DtcGetTransactionManagerC (0, 0, &IID_ITransactionDispenser, 0, 0, 0, &, disp); The code above creates Dispenser object which represents the local instance of MS DTC. If MS DTC is not available DtcGetTransactionManagerC fails. The Dispenser is needed to create distributed transaction objects later. Begin new distributed transaction: disp->lpVtbl->BeginTransaction (disp, 0, ISOLATIONLEVEL_ISOLATED, 0, 0, &transaction); Enlist connection in the transaction: SQLSetConnectOption (hdbc, SQL_COPT_SS_ENLIST_IN_DTC, (DWORD) transaction); And, finally, commit the transaction: transaction->lpVtbl->Commit (tran, 0, 0, 0); MS DTC OLE DB Sample Application The MS DTC OLE DB demo is located in the <VIRTUOSO_INSTALLATION_DIRECTORY>\samples\odbc\MSDTCdemo2 folder. This demo shows usage of distributed transactions driven by MS DTC through OLE DB. Setup The sample works with two instances of Virtuoso server. Running MS DTC service is needed. The servers must be started with MS DTC support (see Virtuoso documentation). The test needs two Virtuoso server instances running on ports 1111 and 1112 Run Run the command in the demo's working directory: voledbtest.exe Description The demo source is voledbtest.cs file in the <VIRTUOSO_INSTALLATION_DIRECTORY>\samples\odbc\MSDTCdemo directory. Several highlights of the most signficant parts of code are presented below: [TransactionAttribute(TransactionOption.Required)] It is significant to set this attribute of class to enable automatic transaction initializaton. Create connections to appropriate servers: string strConn = "Provider=VIRTOLEDB;Data Source=" + dsn1 + ";User Id=dba;Password=dba;Initial Catalog=Demo;Prompt=NoPrompt;"; string strConn2 = "Provider=VIRTOLEDB;Data Source=" + dsn2 + ";User Id=dba;Password=dba;Initial Catalog=Demo;Prompt=NoPrompt;"; obj_conn = new OleDbConnection(strConn); obj_conn2 = new OleDbConnection(strConn2); And, finally, execute the SQL code in the context of distributed transaction: OleDbCommand sqlc = new OleDbCommand ("ODBC_BENCHMARK(" + idx + ",1,1,12.00,\'noone\')"); sqlc.Connection = obj_conn; sqlc.ExecuteNonQuery(); sqlc = new OleDbCommand ("ODBC_BENCHMARK(" + idx + ",1,1,-12.00,\'noone\')"); sqlc.Connection = obj_conn2; sqlc.ExecuteNonQuery();
Title
  • Sample ODBC Applications
title
  • Sample ODBC Applications
created at
  • Wed, 25 Apr 2007 07:07:09 GMT
type
content:encoded
  • <H2 CLASS="sect1head"> <A NAME="sampleodbcapps">Sample ODBC Applications</A> </H2><!-- NEED 15 --> <H3 CLASS="sect2head"> <A NAME="macosxsamples">Mac OS X</A> </H3> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="odbctestmac">ODBCTEST:</A> </H4> <P>This is a simple &#39;C&#39; based and ODBC compliant Interactive SQL processor. </P> <OL> <LI> <P>Open a Terminal session, and start ODBCTEST by executing the following command:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>/Library/iodbc/bin/odbctest</PRE> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>At the SQL command prompt enter &quot;?&quot; for a list of ODBC DSNs on your machine or enter a valid ODBC Connect String. If you have a DSN named &quot;Marketing&quot; you would enter:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>DSN=Marketing;UID=username;PWD=password</PRE> </TD> </TR> </TABLE> <BR /> <P>Note: If there is no password, you must include a semicolon at the end:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>DSN=Marketing;UID=sa;PWD=;</PRE> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Any valid SQL or ODBC command may be executed through this interface. The following example shows a connection to Microsoft SQL Server 2000, making a simple query against the sample Northwind database:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> [localhost:~] openlink% /Library/iodbc/bin/odbctest iODBC Demonstration program This program shows an interactive SQL processor Enter ODBC connect string (? shows list, or DSN=...): DSN=user_tthib_sql2k SQL&gt;select au_lname, au_fname, state from authors where au_id &lt; &#39;333-33-3333&#39; au_lname |au_fname |state ----------------------------------------+--------------------+----- White |Johnson |CA Green |Marjorie |CA Carson |Cheryl |CA O&#39;Leary |Michael |CA Straight |Dean |CA 5 row(s) fetched. SQL&gt;quit Again (y/n) ? n Have a nice day. [localhost:~] openlink% </PRE> </TD> </TR> </TABLE> <BR /> </LI> </OL> <!-- NEED 15 --> <H3 CLASS="sect2head"> <A NAME="winodbcsamples">Windows 95/98/NT/2000</A> </H3> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="cppdemo32">C++ Demo</A> </H4> <OL> <LI> <P>Go to the Virtuoso &quot;Start Menu&quot; item, then click on the &quot;C++ Demo 32 Bit&quot; menu item.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="C++ Demo" SRC="../images/sampl001.gif" /> </TD> </TR> <TR> <TD> <I>C++ Demo</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Follow the Environment-&gt;Open Connection menu path. Selecting the &quot;Open Connection&quot; menu item results in the ODBC Driver Manager presenting you with a list of ODBC DSNs on your machine as depicted by the screen capture below:</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="C++ Demo" SRC="../images/sampl004.gif" /> </TD> </TR> <TR> <TD> <I>C++ Demo</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Select the ODBC DSN that you want to be connecting to, in this case &quot;Local Virtuoso Demo&quot; has been chosen since this will connect you to a sample Virtuoso database that has been populated with data. </P> </LI> <LI> <P>You are then presented with a Login Dialog by the Virtuoso driver for ODBC, enter a valid user name and password (default being user: demo and password: demo) into the appropriate fields.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="C++ Demo" SRC="../images/sampl003.gif" /> </TD> </TR> <TR> <TD> <I>C++ Demo</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>At this point you will be connected to the Virtuoso demonstration database, you can now use the SQL--&gt;Execute SQL menu path to open up the Interactive SQL input dialog. Enter a valid SQL statement (see example in screen shot) and then click on the &quot;OK&quot; button.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="C++ Demo" SRC="../images/sampl006.gif" /> </TD> </TR> <TR> <TD> <I>C++ Demo</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>You will be presented with the results of your query.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="C++ Demo" SRC="../images/sampl007.gif" /> </TD> </TR> <TR> <TD> <I>C++ Demo</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>You exit this demo by following the Environment--&gt;Close Connection menu path.</P> </LI> </OL> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="odbcbench32">ODBC Bench Test 32</A> </H4> <OL> <LI> <P>Go to the Virtuoso &quot;Start Menu&quot; item, then click on the &quot;ODBC Bench Test 32 Bit&quot; menu item. You will be presented with the &quot;Bench Test&quot; interface.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl008.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Follow the File-Connect menu path which initializes the ODBC Driver Manager which in turn presents you with a list of ODBC DSN&#39;s installed on your machine. Select the DSN that you want to benchmark, remember that by benchmarking a DSN you are benchmarking the ODBC Driver that serves the DSN in question and the backend database engine that serves the ODBC Driver. Choose the &quot;Local Virtuoso Demo&quot; DSN if you want to benchmark Virtuoso.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl009.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>You will then be presented with a Login Dialog by the Virtuoso driver for ODBC, enter a valid user name and password (default being user: demo and password: demo for the Demo database) into the appropriate fields.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl010.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Now follow the Bench--&gt;Load Tables menu path and you will be presented with a dialog that enables you to configure key elements of your benchmark. Click the &quot;Execute&quot; button to commence the process of setting up your database for the benchmark tests.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl011.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>As the process of loading data occurs, all the way up to completion, the benchmark program will provide status information into the benchmark output pane as shown below:</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl012.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Now that all the benchmark data has been loaded into your database, follow the Bench--&gt;Run Benchmark menu path and then configure your actual benchmark session parameters:</P> <P>These benchmark parameters fall into 3 categories, Timing Options, SQL Options, and Execution Options.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl013.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> <P> <STRONG>Timing Options:</STRONG> These setting allow you to configure the duration related aspects of this benchmark program</P> <P> Minutes - this is the duration of each benchmark run</P> <P> Runs - this controls how many iterations of the benchmarks you actually run (the default is one benchmark iteration with a duration of 5 minutes)</P> <P> <STRONG>SQL Options:</STRONG> These setting allow you to configure how your benchmark&#39;s SQL instructions are actually handled.</P> <P>ExecDirect with SQL Text - this means that no form of repetitive SQL execution optimization is being applied (SQL statements are prepared and executed repetitively)</P> <P>Prepare/Execute Bound Params - this means that the Parameter Binding SQL execution optimization is being applied (SQL is prepared once but executed many times without the overhead of re-preparing statements prior to execution)</P> <P>Use Stored Procedures - this means that the Stored Procedure SQL optimization is being applied (benchmark instructions are stored within database being benchmarked)</P> <P> <STRONG>Execution Options:</STRONG> These setting allow you to configure the tone of your benchmark, for instance it could have Transaction scoping and a mix of record retrieval queries, or it could simply be input and update intensive with a minimal amount of record retrieval queries (the case when the 100 row query checkbox is unchecked a typical OLTP scenario) </P> <P>Asynchronous - execute the benchmark instructions asynchronously</P> <P>Use Transactions - make the benchmark use transaction control (instructions are scoped to transaction blocks)</P> <P>Do 100 row Query - perform a simulation of a 100 record retrieval as part of the benchmark activity.</P> </LI> </OL> <OL> <LI> <P>Click on the &quot;Run All&quot; button if you would like all the different benchmark type combinations to be performed.</P> </LI> <LI> <P>When benchmark run complete benchmark data is written to the benchmark program&#39;s output pane.</P> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD> <IMG TITLE="ODBC Bench" SRC="../images/sampl014.gif" /> </TD> </TR> <TR> <TD> <I>ODBC Bench</I> </TD> </TR> </TABLE> <BR /> <P>The key pieces of benchmark data that you need to look out for are:</P> <P> <STRONG>Total Transactions: </STRONG> total number of transactions completed during the benchmark run</P> <P> <STRONG>Transactions Per Second</STRONG> number of transaction completed per second for the benchmark run</P> <P>Information from this benchmark is automatically written to an Excel format CSV (the file odbcbnch.csv) which makes it easy for you to graph and pivot data collated from several benchmark runs. A later version of this demo will actually write the benchmark data into an ODBC DSN that you provide thereby offering even more flexibility and accessibility to benchmark data.</P> </LI> </OL> <!-- NEED 15 --> <H3 CLASS="sect2head"> <A NAME="unixodbcsamp">Linux &amp; UNIX</A> </H3> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="odbctestnix">ODBCTEST:</A> </H4> <P>This is a simple &#39;C&#39; based and ODBC compliant Interactive SQL processor. </P> <OL> <LI> <P>Run the script virtuoso-enterprise.sh to set up your environment:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>. virtuoso-enterprise.sh</PRE> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Start ODBCTEST by executing the following command:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>odbctest</PRE> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>At the SQL command prompt enter &quot;?&quot; for a list of ODBC DSNs on your machine or enter a valid ODBC Connect String. If you have a DSN named &quot;Marketing&quot; you would enter:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>DSN=Marketing;UID=username;PWD=password</PRE> </TD> </TR> </TABLE> <BR /> <P>Note: If there is no password, you must include a semicolon at the end:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE>DSN=Marketing;UID=sa;PWD=;</PRE> </TD> </TR> </TABLE> <BR /> </LI> <LI> <P>Any valid SQL or ODBC command may be executed through this interface. The following example shows a connection to Microsoft SQL Server 2000, making a simple query against the sample Northwind database:</P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> [localhost:~] openlink% odbctest iODBC Demonstration program This program shows an interactive SQL processor Enter ODBC connect string (? shows list, or DSN=...): DSN=test_sql2k SQL&gt;select au_lname, au_fname, state from authors where au_id &lt; &#39;333-33-3333&#39; au_lname |au_fname |state ----------------------------------------+--------------------+----- White |Johnson |CA Green |Marjorie |CA Carson |Cheryl |CA O&#39;Leary |Michael |CA Straight |Dean |CA 5 row(s) fetched. SQL&gt;quit Again (y/n) ? n Have a nice day. [localhost:~] openlink% </PRE> </TD> </TR> </TABLE> <BR /> </LI> </OL> <!-- NEED 15 --> <H3 CLASS="sect2head"> <A NAME="MSDTCsample"> MS DTC ODBC Sample Application </A> </H3> <P>The MS DTC demo is located in the <code>&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\odbc\MSDTCdemo1</code> folder. This demo shows usage of distributed transactions driven by MS DTC through the ODBC API.</P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemo1Setup"> Setup </A> </H4> <P> The sample works with two instances of Virtuoso server. The running MS DTC service is needed. The servers must be started with MS DTC support (see Virtuoso documentation). </P> <P> First of all, edit the virt.odbc file. By default this file contains two connection strings of local Virtuoso servers running on port 1111 and port 1112, Each line begins with connection string to appropriate Virtuoso server. Initially this file contains the following lines: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> 1111 dba dba 00.sql 1112 dba dba 01.sql </PRE> </TD> </TR> </TABLE> <BR /> <P> where 1111, 1112 are ports of two Virtuoso servers. &quot;dba dba&quot; - user and password. </P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemo1Init"> Initialization </A> </H4> <P> Start <code> mtstest.exe +load </code> in the <code>&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\odbc\MSDTCdemo1</code> folder. This must check whether all needed servers are running, create and initialize tables, procedures, etc.</P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemo1Start"> Test </A> </H4> <P> Run the command in the demo&#39;s working directory: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> mtstest.exe +exec N mtstest.exe +exec 0 </PRE> </TD> </TR> </TABLE> <BR /> <P> where N - is a number of test iterations. The second command checks logical consistency of the tables.</P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemo1Description"> Description </A> </H4> <P> The demo source is <code>start.c</code> file in the <code>&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\odbc\MSDTCdemo1</code> directory. Several highlights of the most signficant parts of code are presented below: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> ITransactionDispenser *disp; ITransaction *transaction; ... HRESULT hr = DtcGetTransactionManagerC (0, 0, &amp;IID_ITransactionDispenser, 0, 0, 0, &amp;, disp); </PRE> </TD> </TR> </TABLE> <BR /> <P> The code above creates Dispenser object which represents the local instance of MS DTC. If MS DTC is not available <code>DtcGetTransactionManagerC</code> fails. The Dispenser is needed to create distributed transaction objects later. </P> <P> Begin new distributed transaction: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> disp-&gt;lpVtbl-&gt;BeginTransaction (disp, 0, ISOLATIONLEVEL_ISOLATED, 0, 0, &amp;transaction); </PRE> </TD> </TR> </TABLE> <BR /> <P> Enlist connection in the transaction: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> SQLSetConnectOption (hdbc, SQL_COPT_SS_ENLIST_IN_DTC, (DWORD) transaction); </PRE> </TD> </TR> </TABLE> <BR /> <P> And, finally, commit the transaction: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> transaction-&gt;lpVtbl-&gt;Commit (tran, 0, 0, 0); </PRE> </TD> </TR> </TABLE> <BR /> <!-- NEED 15 --> <H3 CLASS="sect2head"> <A NAME="MSDTCsample2"> MS DTC OLE DB Sample Application </A> </H3> <P>The MS DTC OLE DB demo is located in the <code>&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\odbc\MSDTCdemo2</code> folder. This demo shows usage of distributed transactions driven by MS DTC through OLE DB.</P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemo2Setup"> Setup </A> </H4> <P> The sample works with two instances of Virtuoso server. Running MS DTC service is needed. The servers must be started with MS DTC support (see Virtuoso documentation). </P> <P> The test needs two Virtuoso server instances running on ports 1111 and 1112 </P> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemoStart"> Run </A> </H4> <P> Run the command in the demo&#39;s working directory: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> voledbtest.exe </PRE> </TD> </TR> </TABLE> <BR /> <!-- NEED 15 --> <H4 CLASS="sect3head"> <A NAME="MSDTCdemoDescription"> Description </A> </H4> <P> The demo source is <code>voledbtest.cs</code> file in the <code>&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\odbc\MSDTCdemo</code> directory. Several highlights of the most signficant parts of code are presented below: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> [TransactionAttribute(TransactionOption.Required)] </PRE> </TD> </TR> </TABLE> <BR /> <P> It is significant to set this attribute of class to enable automatic transaction initializaton. </P> <P> Create connections to appropriate servers: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> string strConn = &quot;Provider=VIRTOLEDB;Data Source=&quot; + dsn1 + &quot;;User Id=dba;Password=dba;Initial Catalog=Demo;Prompt=NoPrompt;&quot;; string strConn2 = &quot;Provider=VIRTOLEDB;Data Source=&quot; + dsn2 + &quot;;User Id=dba;Password=dba;Initial Catalog=Demo;Prompt=NoPrompt;&quot;; obj_conn = new OleDbConnection(strConn); obj_conn2 = new OleDbConnection(strConn2); </PRE> </TD> </TR> </TABLE> <BR /> <P> And, finally, execute the SQL code in the context of distributed transaction: </P> <TABLE BORDER="0" WIDTH="90%"> <TR> <TD BGCOLOR="#f0f0f0"> <PRE> OleDbCommand sqlc = new OleDbCommand (&quot;ODBC_BENCHMARK(&quot; + idx + &quot;,1,1,12.00,\&#39;noone\&#39;)&quot;); sqlc.Connection = obj_conn; sqlc.ExecuteNonQuery(); sqlc = new OleDbCommand (&quot;ODBC_BENCHMARK(&quot; + idx + &quot;,1,1,-12.00,\&#39;noone\&#39;)&quot;); sqlc.Connection = obj_conn2; sqlc.ExecuteNonQuery(); </PRE> </TD> </TR> </TABLE> <BR />
is topic of
is container of of
Faceted Search & Find service v1.17_git122 as of Jan 03 2023


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3330 as of Apr 5 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (30 GB total memory, 24 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software