Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 791

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="4. Sample ODBC &amp; JDBC Applications" />
  <meta name="dc.subject" content="4. Sample ODBC &amp; JDBC Applications" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="sampleapps.html" title="Chapter Contents" />
  <link rel="prev" href="sampleodbcapps.html" title="Sample ODBC Applications" />
  <link rel="next" href="contents.html" title="Contents" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>4. Sample ODBC &amp; JDBC Applications</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="jdbcdemos" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>4. Sample ODBC &amp; JDBC Applications</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="sampleapps.html">Chapter Contents</a> | <a class="link" href="sampleodbcapps.html" title="Sample ODBC Applications">Prev</a> | <a class="link" href="concepts.html" title="Conceptual Overview">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="sampleapps.html">Sample ODBC &amp; JDBC Applications</a>
   </div>
    <br />
   <div>
      <a href="binsrcloc.html">Binary &amp; Source File Locations</a>
   </div>
   <div>
      <a href="sampleodbcapps.html">Sample ODBC Applications</a>
   </div>
   <div class="selected">
      <a href="jdbcdemos.html">Sample JDBC Applications &amp; Applets</a>
    <div>
        <a href="#JDBCDemo" title="JDBCDemo Java Application">JDBCDemo Java Application</a>
        <a href="#ScrollDemo2" title="ScrollDemo2 Java Application">ScrollDemo2 Java Application</a>
        <a href="#ScrollDemo2Applet" title="ScrollDemo2 Java Applet">ScrollDemo2 Java Applet</a>
        <a href="#JBenchApplication" title="JBench Application">JBench Application</a>
        <a href="#JTADemo" title="JTA Demo Application">JTA Demo Application</a>
    </div>
   </div>
    <br />
  </div>
  <div id="text">
		<a name="jdbcdemos" />
    <h2>4.3. Sample JDBC Applications &amp; Applets</h2>
		
			<a name="JDBCDemo" />
    <h3>4.3.1. JDBCDemo Java Application</h3>
			<ol>
      <li>
					<p>Go to the Virtuoso &quot;Start Menu&quot; program group and then follow the JDBC
        Samples--&gt;JDBCDemo (JDK1.1&amp;1.2) menu path, this will execute a DOS batch program that
        initializes the Java demo application. </p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JDBC Demo" src="../images/vjdemo1.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.1.1. JDBC Demo</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Set the JDBC Driver Name and URL settings for your connection to the Virtuoso
        demonstration database. The &quot;Driver Name&quot; field identifies the Virtuoso Driver.
        If it is left blank, then it defaults to &quot;virtuoso.jdbc.Driver&quot;, which is the
        Virtuoso Driver for JDBC 1.0.  The &quot;Connection URL&quot; field requires a valid
        Virtuoso JDBC URL.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JDBC Demo" src="../images/vjdemo2.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.1.1. JDBC Demo</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Enter a valid SQL statement and then click the &quot;Query&quot; button, the example
        below uses a fully qualified Virtuoso SQL statement requesting all records from the
        &quot;Demo&quot; database table &quot;Customers&quot; owned by the Virtuoso user
        &quot;DBA&quot;.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JDBC Demo" src="../images/vjdemo3.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.1.1. JDBC Demo</td>
      </tr>
        </table>
				</li>
    </ol>
		<br />
		
			<a name="ScrollDemo2" />
    <h3>4.3.2. ScrollDemo2 Java Application</h3>
			<ol>
      <li>
					<p>Go to the Virtuoso Lite &quot;Start Menu&quot; program group and then follow the JDBC
        Samples--&gt;ScrollDemo2 (JDK1.2) menu path, this will execute a DOS batch program that
        initializes the Java demo application. </p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Scroll Demo 2" src="../images/sampl015.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.2.1. Scroll Demo 2</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Set the JDBC Driver Name and URL settings for your connection to the Virtuoso
        demonstration database. The &quot;Driver Name&quot; field identifies the Virtuoso Driver.
        If it is left blank, then it defaults to &quot;virtuoso.jdbc2.Driver&quot;, which is the
        Virtuoso Driver for JDBC 2.0.  The &quot;Connection URL&quot; field requires a valid
        Virtuoso JDBC URL.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Scroll Demo 2" src="../images/sampl016.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.2.1. Scroll Demo 2</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Enter a valid SQL statement and then click the &quot;Query&quot; button, the example
        below uses a fully qualified Virtuoso SQL statement requesting all records from the
        &quot;Demo&quot; database table &quot;Customers&quot; owned by the Virtuoso user
        &quot;DBA&quot;.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Scroll Demo 2" src="../images/sampl017.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.2.1. Scroll Demo 2</td>
      </tr>
        </table>
				</li>
      <li>
					<p>You can now use the navigational buttons to Scroll backwards and forwards, each of these
        navigational buttons highlights Virtuoso&#39;s full implementation of the JDBC 2.0 Scrollable
        Cursors specifications.</p>
				</li>
    </ol>
		<br />
		
			<a name="ScrollDemo2Applet" />
    <h3>4.3.3. ScrollDemo2 Java Applet</h3>
			<ol>
      <li>
					<p>Start the Virtuoso Admin Assistant and then follow the Sample Applications--&gt;JDBC
        Applet Demos menu path.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Scroll Demo 2" src="../images/sampl018.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.3.1. Scroll Demo 2</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Click on the &quot;ScrollDemo2&quot; hyperlink which initializes the ScrollDemo2 applet,
        if you do not have a Java 1.2 or Java 2.0 compliant browser you will not be able to run
        this Applet demo. The other way to experience this demo is to run the Application version
        which uses your operating systems Java Virtual Machine (JVM) instead of a JVM inherently
        linked to a Web Browser.</p>
				</li>
    </ol>
		<br />
		
			<a name="JBenchApplication" />
    <h3>4.3.4. JBench Application</h3>
			<ol>
      <li>
					<p>Go to the Virtuoso &quot;Start Menu&quot; program group and then follow the JDBC
        Samples--&gt;Jbench (JDK1.1) or Jbench (JDK1.2) menu path, depending on the JVM you have
        installed. This will execute a DOS batch program that initializes the JBench application. </p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JBench" src="../images/sampl019.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.4.1. JBench</td>
      </tr>
        </table>
				</li>
      <li>
					<p>The follow the File--&gt;Connect menu path to make your initial connection. You will
        need to identify your JDBC Driver (by providing appropriate Driver Name values in the JDBC
        Driver field) and then provide a valid JDBC URL for your specific JDBC Driver (Jbench uses
        a valid Virtuoso Driver for JDBC URL that points to the demonstration database listening
        at port 1112 as its default).</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JBench" src="../images/sampl020.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.4.1. JBench</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Follow the Results--&gt;Table URL menu path, this is how you identify (using a JDBC URL)
        the location of the &quot;Results&quot; tables into which you will be storing your
        benchmark data. The default URL is the current JDBC URL (the one used to establish your
        initial connection), but this can be a totally different database to the one being
        benchmarked.</p>
				</li>
      <li>
					<p>Follow the Results--&gt;Create menu path, this is how you actually perform the
        &quot;Results&quot; table creation in the database identified by the URL in the previous
        step.</p>
				</li>
      <li>
					<p>Follow the TPC-A--&gt;Load Tables menu path to prepare your database for the TPC-A
        benchmark, select a database schema type that matches the database engine that you are
        benchmarking. If your database is not listed ANSI should suffice (as long as this is an
        ANSI SQL compliant database).</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JBench" src="../images/sampl021.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.4.1. JBench</td>
      </tr>
        </table>
				</li>
      <li>
					<p>Follow the TPC-A--&gt;Load Procedures menu path to Load the Virtuoso TPC-A stored
        procedures.</p>
				</li>
      <li>
					<p>Now that all the benchmark data and stored procedures have been loaded into your
        database, follow the TPC-A--&gt;Run Benchmark menu path and then configure your actual
        benchmark session parameters:</p>
					<p>The benchmark parameters fall into 4 categories, Bench execution mode, Run Options, SQL
        Options, and Execution Options.</p>
					<table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="JBench" src="../images/sampl022.gif" />
       </td>
      </tr>
      <tr>
            <td>Figure: 4.3.4.1. JBench</td>
      </tr>
        </table>
					<p>
          <strong>Bench execution mode:</strong>
						These setting allow you to configure the threads used for the benchmark.</p>
						<p>Decide on a single or multiple threads test.</p>
						<p>No. Threads - this is the number of concurrent threads to be used during the benchmark.</p>
						<p>
          <strong>Run Options:</strong>
						These setting allow you to configure the duration related aspects of this benchmark program.</p>
						<p>No. runs - this controls how many iterations of the benchmarks you actually run (the
        default is 100 benchmark iterations).</p>
						<p>Duration (mins.) - this is the duration in minutes of each benchmark run.</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>Run All - this implies you want to perform all of the above benchmarks</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>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>
      <li>
					<p>Run your TPC-A benchmark.</p>
				</li>
      <li>
					<p>Follow the TPC-A--&gt;Cleanup menu path to clean up your database so that you can then
        run other benchmarks (TPC-C like benchmark).</p>
				</li>
      <li>
					<p>To run the TPC-C  benchmark simply follow the appropriate menu path, create the
        benchmark tables &amp; stored procedures, load the benchmark data and then run the TPC-C
        benchmark.</p>
				</li>
    </ol>
		<br />
		
			<a name="JTADemo" />
    <h3>4.3.5. JTA Demo Application</h3>
			<p>The JTA demo is located in the
<span class="computeroutput">&lt;VIRTUOSO_INSTALLATION_DIRECTORY&gt;\samples\jdbc\JTADemo</span>
folder.</p>
			
				<a name="JTADemoSetup" />
    <h4>4.3.5.1. Software Setup</h4>
				<ol>
      <li>
						<p>The sample requires
2 or 3 Virtuoso instances and an instance of a J2EE 1.3.1 server properly
set up and running on the same computer or on the network. To build the sample
it&#39;s also necessary to have a J2SE 1.4 SDK installed.</p>
					</li>
      <li>
						<p>The JAVA_HOME and
J2EE_HOME environment variables must be set to the J2SE SDK and J2EE
installation path respectively.</p>
					</li>
      <li>
						<p>The virtjdbc3.jar file
must be in the classpath of the J2EE server. The setting of the classpath
differs across different J2EE servers. For J2EE Reference Implementation (RI)
the J2EE_CLASSPATH variable might be set in %J2EE_HOME%\bin\userconfig.bat
on Windows or $(J2EE_HOME)/bin/userconfig.sh on Unix.</p>
<div>
          <pre class="programlisting">
    set J2EE_CLASSPATH=C:/Virtuoso/lib/virtjdbc3.jar
</pre>
        </div>
or
<div>
          <pre class="programlisting">
    J2EE_CLASSPATH=/home/login/virtuoso/lib/virtjdbc3.jar
    export J2EE_CLASSPATH
</pre>
        </div>
					</li>
      <li>
						<p>Add the Virtuoso
XA datasources to J2EE server. For J2EE RI this is done like this:</p>
<div>
          <pre class="programlisting">
    j2eeadmin -addJdbcXADatasource jdbc/Virtuoso1 virtuoso.jdbc3.VirtuosoXADataSource dba dba -props serverName=localhost portNumber=1111
    j2eeadmin -addJdbcXADatasource jdbc/Virtuoso2 virtuoso.jdbc3.VirtuosoXADataSource dba dba -props serverName=localhost portNumber=2222
    j2eeadmin -addJdbcXADatasource jdbc/Virtuoso3 virtuoso.jdbc3.VirtuosoXADataSource dba dba -props serverName=localhost portNumber=3333
</pre>
        </div>
						<p>Please note that the
newly added datasources take effect only after restart of the J2EE server.</p>
					</li>
    </ol>
			<br />
			
				<a name="JTADemoConfig" />
    <h4>4.3.5.2. Configuration</h4>
				<p>The sample folder contains the
jtademo.properties file which can be used to configure the sample application.
The configuration options are described within the file.</p>
			<br />
			
				<a name="JTADemo_Deploy" />
    <h4>4.3.5.3. Building and Deployment</h4>
				<p>The sample folder contains
build and deploy scripts (build.sh and deploy.sh for Linux and Unix and
build.bat and deploy.bat for Windows).</p>
				<p>Use the build script to build the
sample application from the source files.</p>
				<p>Deploy the application to the J2EE
server. The deploy script performs this task for J2EE RI. Other J2EE application
servers might provide different ways for application deployment.</p>
			<br />
			
				<a name="JTADemoRun" />
    <h4>4.3.5.4. Running the Sample</h4>
				<p>The sample folder contains
the run scripts for Linux/Unix and Windows.</p>
				<p>The run script accepts the
following commands:</p>
				<table class="varlist">
    <tr>
        <td align="right" valign="top" class="varterm" nowrap="nowrap">create:</td>
        <td>Creates and populates
the necessary tables.</td>
    </tr>
    <tr>
        <td align="right" valign="top" class="varterm" nowrap="nowrap">check:</td>
        <td>Verifies data
consistency.</td>
    </tr>
    <tr>
        <td align="right" valign="top" class="varterm" nowrap="nowrap">drop:</td>
        <td>Removes data and
tables from the databases.</td>
    </tr>
    <tr>
        <td align="right" valign="top" class="varterm" nowrap="nowrap">run:</td>
        <td>Executes a number of
transactions over database tables.</td>
    </tr>
    </table>
				<p>The first action to do is to initialize
the data with the create command. After this the command might be used
one or more times. This executes a series of concurrent updates on the
distributed data. The check command verifies that this updates left
databases in the consistent state.</p>
				<p>For instance, for Unix:</p>
<div>
      <pre class="programlisting">
    run.sh create
    run.sh run
    run.sh check
</pre>
    </div>
				<p>And for Windows:</p>
<div>
      <pre class="programlisting">
    run.bat create
    run.bat run
    run.bat check
</pre>
    </div>
			<br />
		<br />
	<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="sampleodbcapps.html" title="Sample ODBC Applications">Previous</a>
          <br />Sample ODBC Applications</td>
     <td align="center" width="34%">
          <a href="sampleapps.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="concepts.html" title="Conceptual Overview">Next</a>
          <br />Contents of Conceptual Overview</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>