| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 4. JDBC</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.72.0"><link rel="start" href="manual.html" title="Apache OpenJPA User's Guide"><link rel="up" href="ref_guide.html" title="Part 3. Reference Guide"><link rel="prev" href="ref_guide_logging_custom.html" title="6. Custom Log"><link rel="next" href="ref_guide_dbsetup_thirdparty.html" title="2. Using a Third-Party DataSource"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. |
| JDBC |
| </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ref_guide_logging_custom.html">Prev</a> </td><th width="60%" align="center">Part 3. Reference Guide</th><td width="20%" align="right"> <a accesskey="n" href="ref_guide_dbsetup_thirdparty.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en" id="ref_guide_dbsetup"><div class="titlepage"><div><div><h2 class="title"><a name="ref_guide_dbsetup"></a>Chapter 4. |
| JDBC |
| </h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ref_guide_dbsetup.html#ref_guide_dbsetup_builtin">1. |
| Using the OpenJPA DataSource |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_thirdparty.html">2. |
| Using a Third-Party DataSource |
| </a></span></dt><dd><dl><dt><span class="section"><a href="ref_guide_dbsetup_thirdparty.html#ref_guide_dbsetup_thirdparty_enlist">2.1. |
| Managed and XA DataSources |
| </a></span></dt></dl></dd><dt><span class="section"><a href="ref_guide_dbsetup_sqlconn.html">3. |
| Runtime Access to DataSource |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_dbsupport.html">4. |
| Database Support |
| </a></span></dt><dd><dl><dt><span class="section"><a href="ref_guide_dbsetup_dbsupport.html#ref_guide_dbsetup_dbdictprops">4.1. |
| DBDictionary Properties |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_dbsupport.html#ref_guide_dbsetup_dbsupport_mysql">4.2. |
| MySQLDictionary Properties |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_dbsupport.html#ref_guide_dbsetup_dbsupport_oracle">4.3. |
| OracleDictionary Properties |
| </a></span></dt></dl></dd><dt><span class="section"><a href="ref_guide_dbsetup_isolation.html">5. |
| Setting the Transaction Isolation |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_sql92.html">6. |
| Setting the SQL Join Syntax |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_multidb.html">7. |
| Accessing Multiple Databases |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_retain.html">8. |
| Configuring the Use of JDBC Connections |
| </a></span></dt><dt><span class="section"><a href="ref_guide_dbsetup_lrs.html">9. |
| Large Result Sets |
| </a></span></dt><dt><span class="section"><a href="ref_guide_schema_def.html">10. |
| Default Schema |
| </a></span></dt><dt><span class="section"><a href="ref_guide_schema_info.html">11. |
| Schema Reflection |
| </a></span></dt><dd><dl><dt><span class="section"><a href="ref_guide_schema_info.html#ref_guide_schema_info_list">11.1. |
| Schemas List |
| </a></span></dt><dt><span class="section"><a href="ref_guide_schema_info.html#ref_guide_schema_info_factory">11.2. |
| Schema Factory |
| </a></span></dt></dl></dd><dt><span class="section"><a href="ref_guide_schema_schematool.html">12. |
| Schema Tool |
| </a></span></dt><dt><span class="section"><a href="ref_guide_schema_xml.html">13. |
| XML Schema Format |
| </a></span></dt></dl></div><a class="indexterm" name="d0e17024"></a><p> |
| OpenJPA uses a relational database for object persistence. |
| It communicates with the database using the Java DataBase Connectivity (JDBC) |
| APIs. This chapter describes how to configure OpenJPA to work with the JDBC |
| driver for your database, and how to access JDBC functionality at runtime. |
| </p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="ref_guide_dbsetup_builtin"></a>1. |
| Using the OpenJPA DataSource |
| </h2></div></div></div><a class="indexterm" name="d0e17032"></a><a class="indexterm" name="d0e17037"></a><p> |
| OpenJPA includes its own simple <code class="classname">javax.sql.DataSource</code> |
| implementation. If you choose to use OpenJPA's <code class="classname">DataSource |
| </code>, then you must specify the following properties: |
| </p><div class="itemizedlist"><ul type="disc"><li><p> |
| <a class="indexterm" name="d0e17054"></a> |
| <code class="literal">openjpa.ConnectionUserName</code>: The JDBC user name for |
| connecting to the database. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17064"></a> |
| <code class="literal">openjpa.ConnectionPassword</code>: The JDBC password for the above |
| user. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17074"></a> |
| <code class="literal">openjpa.ConnectionURL</code>: The JDBC URL for the database. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17084"></a> |
| <code class="literal">openjpa.ConnectionDriverName</code>: The JDBC driver class. |
| </p></li></ul></div><p> |
| To configure advanced features, use the following optional |
| properties. The syntax of these property strings follows the syntax of OpenJPA |
| plugin parameters described in <a href="ref_guide_conf_plugins.html" title="4. Plugin Configuration">Section 4, “ |
| Plugin Configuration |
| ”</a>. |
| </p><div class="itemizedlist"><ul type="disc"><li><p> |
| <a class="indexterm" name="d0e17099"></a> |
| <a href="ref_guide_conf_openjpa.html#openjpa.ConnectionProperties" title="5.18. openjpa.ConnectionProperties"><code class="literal"> |
| openjpa.ConnectionProperties</code></a>: If the listed driver is an |
| instance of <code class="classname">java.sql.Driver</code>, this string will be parsed |
| into a <code class="classname">Properties</code> instance, which will then be used to |
| obtain database connections through the <code class="methodname">Driver.connect(String url, |
| Properties props)</code> method. If, on the other hand, the listed driver |
| is a <code class="classname"> javax.sql.DataSource</code>, the string will be treated |
| as a plugin properties string, and matched to the bean setter methods of the |
| <code class="classname">DataSource</code> instance. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17125"></a> |
| <a href="ref_guide_conf_openjpa.html#openjpa.ConnectionFactoryProperties" title="5.14. openjpa.ConnectionFactoryProperties"><code class="literal"> |
| openjpa.ConnectionFactoryProperties</code></a>: OpenJPA's built-in |
| <code class="classname">DataSource</code> allows you to set the following options via |
| this plugin string: |
| </p><div class="itemizedlist"><ul type="circle"><li><p> |
| <a class="indexterm" name="d0e17140"></a> |
| <code class="literal">QueryTimeout</code>: The maximum number of seconds the JDBC driver |
| will wait for a statement to execute. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17152"></a> |
| <code class="literal">PrettyPrint</code>: Boolean indicating whether to pretty-print |
| logged SQL statements. |
| </p></li><li><p> |
| <a class="indexterm" name="d0e17164"></a> |
| <code class="literal">PrettyPrintLineLength</code>: The maximum number of characters in |
| each pretty-printed SQL line. |
| </p></li></ul></div></li></ul></div><div class="example"><a name="ref_guide_dbsetup_builtin_ex"></a><p class="title"><b>Example 4.1. |
| Properties for the OpenJPA DataSource |
| </b></p><div class="example-contents"><pre class="programlisting"> |
| <property name="openjpa.ConnectionUserName" value="user"/> |
| <property name="openjpa.ConnectionPassword" value="pass"/> |
| <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:db-hypersonic"/> |
| <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver"/> |
| <property name="openjpa.ConnectionFactoryProperties" |
| value="PrettyPrint=true, PrettyPrintLineLength=80"/> |
| </pre></div></div><br class="example-break"></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ref_guide_logging_custom.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref_guide.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ref_guide_dbsetup_thirdparty.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">6. |
| Custom Log |
| </td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top"> 2. |
| Using a Third-Party DataSource |
| </td></tr></table></div></body></html> |