| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Configuring the SQL Interface</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Installation and Build Guide" /> |
| 10 | <link rel="up" href="build_unix.html" title="Chapter 7. Building Berkeley DB for UNIX/POSIX" /> |
| 11 | <link rel="prev" href="build_unix_conf.html" title="Configuring Berkeley DB" /> |
| 12 | <link rel="next" href="build_unix_small.html" title="Building a small memory footprint library" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Configuring the SQL Interface</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="build_unix_conf.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 7. |
| 26 | Building Berkeley DB for UNIX/POSIX |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="build_unix_small.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="build_unix_sql"></a>Configuring the SQL Interface</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <div class="toc"> |
| 42 | <dl> |
| 43 | <dt> |
| 44 | <span class="sect2"> |
| 45 | <a href="build_unix_sql.html#config_sql">Changing Compile Options</a> |
| 46 | </span> |
| 47 | </dt> |
| 48 | <dt> |
| 49 | <span class="sect2"> |
| 50 | <a href="build_unix_sql.html#idp500824">Enabling Extensions</a> |
| 51 | </span> |
| 52 | </dt> |
| 53 | <dt> |
| 54 | <span class="sect2"> |
| 55 | <a href="build_unix_sql.html#build_unix_jdbc">Building the JDBC Driver</a> |
| 56 | </span> |
| 57 | </dt> |
| 58 | <dt> |
| 59 | <span class="sect2"> |
| 60 | <a href="build_unix_sql.html#idp571856">Using the JDBC Driver</a> |
| 61 | </span> |
| 62 | </dt> |
| 63 | <dt> |
| 64 | <span class="sect2"> |
| 65 | <a href="build_unix_sql.html#idp593744">Building the ODBC Driver</a> |
| 66 | </span> |
| 67 | </dt> |
| 68 | <dt> |
| 69 | <span class="sect2"> |
| 70 | <a href="build_unix_sql.html#bfile">Building the BFILE extension</a> |
| 71 | </span> |
| 72 | </dt> |
| 73 | </dl> |
| 74 | </div> |
| 75 | <p> |
| 76 | There are a set of options you can provide to |
| 77 | <span class="command"><strong>configure</strong></span> in order to control how the Berkeley DB |
| 78 | SQL interface is built. These configuration options include: |
| 79 | </p> |
| 80 | <div class="variablelist"> |
| 81 | <dl> |
| 82 | <dt> |
| 83 | <span class="term">--disable-log-checksum</span> |
| 84 | </dt> |
| 85 | <dd> |
| 86 | Disables checksums in log records. This provides a boost to |
| 87 | performance at the risk of log files having undetectable |
| 88 | corruption that could prevent proper data recovery in case of |
| 89 | database corruption. |
| 90 | <p> |
| 91 | Note that while this option is meant for use with the SQL |
| 92 | interface, it will also disable checksum for the non-SQL |
| 93 | interfaces. |
| 94 | </p></dd> |
| 95 | <dt> |
| 96 | <span class="term">--enable-sql</span> |
| 97 | </dt> |
| 98 | <dd> |
| 99 | Causes the <span class="command"><strong>dbsql</strong></span> command line interpreter to |
| 100 | be built. Along with <span class="command"><strong>dbsql</strong></span>, this argument |
| 101 | also builds the libdb_sqlXX.{so|la} library, a C API library |
| 102 | that mirrors the SQLite C API. |
| 103 | </dd> |
| 104 | <dt> |
| 105 | <span class="term">--enable-sql_compat</span> |
| 106 | </dt> |
| 107 | <dd> |
| 108 | <p> |
| 109 | Causes the <span class="command"><strong>sqlite3</strong></span> command line tool to |
| 110 | be built. This tool is identical to the |
| 111 | <span class="command"><strong>dbsql</strong></span> command line tool, except that it |
| 112 | has the same name as the command line tool that comes with |
| 113 | standard SQLite. |
| 114 | </p> |
| 115 | <p> |
| 116 | In addition, the libsqlite3.{so|la} C API library is built |
| 117 | if this option is specified. This library is identical to |
| 118 | the libdb_sqlXX.{so|la} library that is normally built for Berkeley |
| 119 | DB's sql interface, except that it has the same name as the |
| 120 | library which is built for standard SQLite. |
| 121 | </p> |
| 122 | <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 123 | <h3 class="title">Warning</h3> |
| 124 | <p> |
| 125 | Use this compatibility option with |
| 126 | <span class="emphasis"><em>extreme</em></span> care. Standard SQLite is |
| 127 | used by many programs and utilities on many different |
| 128 | platforms. Some platforms, such as Mac OS X, come with |
| 129 | standard SQLite built in because default applications for the |
| 130 | platform use that library. |
| 131 | </p> |
| 132 | <p> |
| 133 | <span class="bold"><strong>Use of this option on platforms where standard SQLite |
| 134 | is in production use can cause unexpected runtime |
| 135 | errors either for your own application, or for |
| 136 | applications and utilities commonly found on the |
| 137 | platform, depending on which library is found first |
| 138 | in the platform's library search path.</strong></span> |
| 139 | </p> |
| 140 | <p> |
| 141 | Use this option <span class="emphasis"><em>only</em></span> if you know |
| 142 | exactly what you are doing. |
| 143 | </p> |
| 144 | </div> |
| 145 | <p> |
| 146 | This option is provided so that there is an easy upgrade |
| 147 | path for legacy SQLite tools and scripts that want to use |
| 148 | BDB SQL without rewriting the tool or script. However, |
| 149 | data contained in standard SQLite databases must be |
| 150 | manually migrated from the old database to your BDB SQL |
| 151 | database even if you use this option. See the |
| 152 | <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide for information on |
| 153 | migrating data from standard SQLite to BDB SQL databases. |
| 154 | </p> |
| 155 | <p> |
| 156 | Note that in addition to the renamed command line tool and |
| 157 | library, this option also causes versions of the command |
| 158 | line tool and library to be built that use the normal BDB |
| 159 | SQLite names (<span class="command"><strong>dbsql</strong></span> and libdb_sqlXX.{so|la}). |
| 160 | </p> |
| 161 | </dd> |
| 162 | <dt> |
| 163 | <span class="term">--enable-test</span> |
| 164 | </dt> |
| 165 | <dd> |
| 166 | Cause the Berkeley DB SQL interface test suite to be built. |
| 167 | This argument can also be used with either |
| 168 | <code class="literal">--enable-sql</code> or |
| 169 | <code class="literal">--enable-sql_compat</code> to build the SQLite Tcl |
| 170 | test runner. |
| 171 | </dd> |
| 172 | <dt> |
| 173 | <span class="term">--enable-jdbc</span> |
| 174 | </dt> |
| 175 | <dd> |
| 176 | <p> |
| 177 | Causes the JDBC driver to be built. Setting this option |
| 178 | implies that <code class="literal">--enable-sql</code> is set, which |
| 179 | means that the Berkeley DB SQL API will be built too. |
| 180 | </p> |
| 181 | </dd> |
| 182 | </dl> |
| 183 | </div> |
| 184 | <p> |
| 185 | The following configuration options are useful when debugging applications: |
| 186 | </p> |
| 187 | <div class="variablelist"> |
| 188 | <dl> |
| 189 | <dt> |
| 190 | <span class="term"> |
| 191 | <a class="link" href="build_unix_conf.html#build_unix_conf.--enable-debug">--enable-debug</a> |
| 192 | </span> |
| 193 | </dt> |
| 194 | <dd> |
| 195 | Builds the Berkeley DB SQL interface with debug symbols. |
| 196 | </dd> |
| 197 | <dt> |
| 198 | <span class="term"> |
| 199 | <a class="link" href="build_unix_conf.html#build_unix_conf.--enable-diagnostic">--enable-diagnostic</a> |
| 200 | </span> |
| 201 | </dt> |
| 202 | <dd> |
| 203 | Builds the Berkeley DB SQL interface with run-time debugging checks. |
| 204 | </dd> |
| 205 | </dl> |
| 206 | </div> |
| 207 | <p> |
| 208 | Any arguments that you can provide to the standard SQLite configure |
| 209 | script can also be supplied when configuring Berkeley DB SQL interface. |
| 210 | </p> |
| 211 | <div class="sect2" lang="en" xml:lang="en"> |
| 212 | <div class="titlepage"> |
| 213 | <div> |
| 214 | <div> |
| 215 | <h3 class="title"><a id="config_sql"></a>Changing Compile Options</h3> |
| 216 | </div> |
| 217 | </div> |
| 218 | </div> |
| 219 | <p>There are several configuration options you can specify as an argument to the configure script using the standard environment variable, CFLAGS.</p> |
| 220 | <div class="variablelist"> |
| 221 | <dl> |
| 222 | <dt> |
| 223 | <span class="term">BDBSQL_DEFAULT_PAGE_SIZE</span> |
| 224 | </dt> |
| 225 | <dd> |
| 226 | To set the default page size when you create a database, specify the BDBSQL_DEFAULT_PAGE_SIZE flag. |
| 227 | The value assigned must be a 0, 512, 1024, 2048, 4096, 8192 16384, 32768, or 65536. The default value is 4096. |
| 228 | If the value is set to zero, Berkeley DB queries the file system to determine the best page size, |
| 229 | and the value of SQLITE_DEFAULT_PAGE_SIZE is used to calculate the cache size, as the cache size is specified as a number of pages. |
| 230 | </dd> |
| 231 | <dt> |
| 232 | <span class="term">BDBSQL_FILE_PER_TABLE</span> |
| 233 | </dt> |
| 234 | <dd> |
| 235 | To generate each table in a separate file, rather than as subdatabases in a single file, specify the BDBSQL_FILE_PER_TABLE flag. |
| 236 | When this option is enabled, the SQL database name is used as a directory name. This directory contains one file for the metadata and one file each for every table created by the SQL API. |
| 237 | Note that adding or deleting files from the database directory may corrupt your database. |
| 238 | To backup the metadata (schema), make a copy of the <code class="literal">metadata</code> and <code class="literal">table00001</code> files from the database directory. |
| 239 | Make a new copy whenever the schema is changed. |
| 240 | </dd> |
| 241 | <dt> |
| 242 | <span class="term">BDBSQL_LOG_REGIONMAX</span> |
| 243 | </dt> |
| 244 | <dd> |
| 245 | To configure the log region size for the underlying storage engine, specify the BDBSQL_LOG_REGIONMAX flag. For more information, see |
| 246 | <a href="../api_reference/C/envget_lg_regionmax.html" class="olink">DB_ENV->get_lg_regionmax()</a>. |
| 247 | |
| 248 | </dd> |
| 249 | <dt> |
| 250 | <span class="term">BDBSQL_OMIT_LEAKCHECK |
| 251 | </span> |
| 252 | </dt> |
| 253 | <dd>For Berkeley DB to use the default system allocation routines rather than the SQLite allocation routines, specify the BDBSQL_OMIT_LEAKCHECK flag. |
| 254 | </dd> |
| 255 | <dt> |
| 256 | <span class="term">BDBSQL_OMIT_LOG_REMOVE |
| 257 | </span> |
| 258 | </dt> |
| 259 | <dd>Berkeley DB automatically removes log files that are not required any more, that is, files that are older than the most recent checkpoint. To disable this functionality, specify the BDBSQL_OMIT_LOG_REMOVE flag. It is necessary to provide this flag if you are using replication with Berkeley DB SQL. |
| 260 | </dd> |
| 261 | <dt> |
| 262 | <span class="term">BDBSQL_OMIT_SHARING |
| 263 | </span> |
| 264 | </dt> |
| 265 | <dd>To create a private environment rather than a shared environment, specify the BDBSQL_OMIT_SHARING flag. That is, the cache and other region files will be created in memory rather than using file backed shared memory. For more information, see the DB_PRIVATE flag of <a href="../api_reference/C/envopen.html" class="olink">DB_ENV->open()</a>. |
| 266 | </dd> |
| 267 | <dt> |
| 268 | <span class="term">BDBSQL_SINGLE_THREAD |
| 269 | </span> |
| 270 | </dt> |
| 271 | <dd>To disable locking and thread safe connections, specify the BDBSQL_SINGLE_THREAD flag. If an application is going to use Berkeley DB from a single thread and a single process, enabling this flag can deliver significant performance advantages. |
| 272 | </dd> |
| 273 | <dt> |
| 274 | <span class="term">SQLITE_DEFAULT_CACHE_SIZE |
| 275 | </span> |
| 276 | </dt> |
| 277 | <dd>SQLite provides an in-memory cache which you size according to the maximum number of |
| 278 | database pages that you want to hold in memory at any given time. |
| 279 | Berkeley DB's in-memory cache feature performs the same function as SQLite. |
| 280 | To specify the suggested maximum number of pages of disk cache that will be allocated per open database file specify the SQLITE_DEFAULT_CACHE_SIZE flag. Default value is 2000 pages. |
| 281 | For more information, see the SQLite documentation on <a class="ulink" href="http://www.sqlite.org/pragma.html#pragma_default_cache_size" target="_top">PRAGMA default_cache_size</a>. |
| 282 | </dd> |
| 283 | <dt> |
| 284 | <span class="term">SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT |
| 285 | </span> |
| 286 | </dt> |
| 287 | <dd> |
| 288 | For SQLite, this pragma identifies the maximum size that the journal file is allowed |
| 289 | to be. Berkeley DB does not have a journal file, but it writes and uses log files. A new log file is |
| 290 | created when the current log file has reached the defined maximum size. |
| 291 | To define this maximum size for a log file, specify the SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT flag. |
| 292 | Default value is 10 MB for the Berkeley DB SQL interface. |
| 293 | </dd> |
| 294 | </dl> |
| 295 | </div> |
| 296 | </div> |
| 297 | <div class="sect2" lang="en" xml:lang="en"> |
| 298 | <div class="titlepage"> |
| 299 | <div> |
| 300 | <div> |
| 301 | <h3 class="title"><a id="idp500824"></a>Enabling Extensions</h3> |
| 302 | </div> |
| 303 | </div> |
| 304 | </div> |
| 305 | <p> |
| 306 | The Berkeley DB SQL API provides extensions such as full text |
| 307 | search and R-Tree index. By default, these extensions are |
| 308 | disabled. To enable an extension in the Berkeley DB SQL interface, |
| 309 | specify the related option as an argument to the configure script |
| 310 | using the standard environment variable, CPPFLAGS. |
| 311 | </p> |
| 312 | <p></p> |
| 313 | <div class="variablelist"> |
| 314 | <dl> |
| 315 | <dt> |
| 316 | <span class="term">SQLITE_ENABLE_FTS3</span> |
| 317 | </dt> |
| 318 | <dd> |
| 319 | Enable building the Berkeley DB full text search layer |
| 320 | </dd> |
| 321 | <dt> |
| 322 | <span class="term">SQLITE_ENABLE_RTREE</span> |
| 323 | </dt> |
| 324 | <dd> |
| 325 | Enables the Berkeley DB R-Tree layer. |
| 326 | </dd> |
| 327 | </dl> |
| 328 | </div> |
| 329 | <p> |
| 330 | See the SQLite Documentation for more information on |
| 331 | <a class="ulink" href="http://www.sqlite.org/fts3.html" target="_top">full text search</a> |
| 332 | and <a class="ulink" href="http://www.sqlite.org/rtree.html" target="_top">R-Tree</a>. |
| 333 | </p> |
| 334 | </div> |
| 335 | <div class="sect2" lang="en" xml:lang="en"> |
| 336 | <div class="titlepage"> |
| 337 | <div> |
| 338 | <div> |
| 339 | <h3 class="title"><a id="build_unix_jdbc"></a>Building the JDBC Driver</h3> |
| 340 | </div> |
| 341 | </div> |
| 342 | </div> |
| 343 | <p> |
| 344 | This section describes how to build the JDBC driver code using |
| 345 | <code class="literal">autoconf</code>, which is the only method supported and |
| 346 | tested by the Berkeley DB team. |
| 347 | </p> |
| 348 | <p> |
| 349 | To build the JDBC driver, you must have Sun Java Development Kit |
| 350 | 1.1 or above installed. |
| 351 | </p> |
| 352 | <pre class="programlisting">cd build_unix |
| 353 | ../dist/configure --enable-jdbc --prefix=<install path> |
| 354 | make install</pre> |
| 355 | <p> |
| 356 | You can test the build by entering the following commands from the |
| 357 | <code class="literal">build_unix/jdbc</code> directory: |
| 358 | </p> |
| 359 | <table class="simplelist" border="0" summary="Simple list"> |
| 360 | <tr> |
| 361 | <td>javac -classpath ./sqlite.jar test3.java</td> |
| 362 | </tr> |
| 363 | <tr> |
| 364 | <td>java -Djava.library.path=./.libs -classpath ./sqlite.jar:. test3 </td> |
| 365 | </tr> |
| 366 | </table> |
| 367 | </div> |
| 368 | <div class="sect2" lang="en" xml:lang="en"> |
| 369 | <div class="titlepage"> |
| 370 | <div> |
| 371 | <div> |
| 372 | <h3 class="title"><a id="idp571856"></a>Using the JDBC Driver</h3> |
| 373 | </div> |
| 374 | </div> |
| 375 | </div> |
| 376 | <p> |
| 377 | This section describes how to download, build, and run sample |
| 378 | programs using the built JDBC driver. |
| 379 | </p> |
| 380 | <div class="sect3" lang="en" xml:lang="en"> |
| 381 | <div class="titlepage"> |
| 382 | <div> |
| 383 | <div> |
| 384 | <h4 class="title"><a id="idp572352"></a>Downloading JDBC Sample Code</h4> |
| 385 | </div> |
| 386 | </div> |
| 387 | </div> |
| 388 | <p> |
| 389 | The download link for JDBC sample code is available on the |
| 390 | <a class="ulink" href="http://www.oracle.com/technetwork/java/index-139949.html" target="_top"> |
| 391 | Oracle Technology Network (OTN) |
| 392 | </a> page. You can identify the link by the "JDBC |
| 393 | programming examples from all three editions (ZIP format)" text |
| 394 | beside it. |
| 395 | </p> |
| 396 | </div> |
| 397 | <div class="sect3" lang="en" xml:lang="en"> |
| 398 | <div class="titlepage"> |
| 399 | <div> |
| 400 | <div> |
| 401 | <h4 class="title"><a id="idp552800"></a>Modifying Sample Code</h4> |
| 402 | </div> |
| 403 | </div> |
| 404 | </div> |
| 405 | <p> |
| 406 | Before running the example code, do the following: |
| 407 | </p> |
| 408 | <div class="orderedlist"> |
| 409 | <ol type="1"> |
| 410 | <li> |
| 411 | Unzip the file containing the sample code to a new |
| 412 | directory (for example, jdbc_ex). |
| 413 | </li> |
| 414 | <li> |
| 415 | <p> |
| 416 | Substitute |
| 417 | <code class="literal">jdbc:sqlite:/<db-file-name></code> for |
| 418 | the generic JDBC URL that appears in the code. That is, put |
| 419 | <code class="literal">jdbc:sqlite:/<db-file-name></code> |
| 420 | between the quotation marks in the line: |
| 421 | </p> |
| 422 | <p> |
| 423 | <code class="literal">String url = "jdbc:mySubprotocol:myDataSource";</code> |
| 424 | </p> |
| 425 | <p> |
| 426 | Note: The <db-file-name> can either be an |
| 427 | absolute path name like |
| 428 | <code class="literal">"/jdbc_ex_db/myDataSource"</code>, or a |
| 429 | relative path-file-name like |
| 430 | <code class="literal">"../jdbc_ex_db/myDataSource"</code>, or a |
| 431 | file name, like <code class="literal">"myDataSource"</code>, in |
| 432 | which case the database file will be stored at the current |
| 433 | directory.</p> |
| 434 | </li> |
| 435 | <li> |
| 436 | Substitute <code class="literal">SQLite.JDBCDriver</code> for |
| 437 | <code class="literal">myDriver.ClassName</code> in the line: |
| 438 | <code class="literal">Class.forName("myDriver.ClassName");</code></li> |
| 439 | <li> |
| 440 | <p> |
| 441 | Optionally substitute the username and password you use for your |
| 442 | database in the following: |
| 443 | <code class="literal">"myLogin", "myPassword"</code>. |
| 444 | </p> |
| 445 | </li> |
| 446 | <li> |
| 447 | If your JDK version is above 1.5, change the variable name |
| 448 | <code class="literal">enum</code> in |
| 449 | <code class="literal">OutputApplet.java</code> to some other variable |
| 450 | name because, as of JDK release 5 <code class="literal">enum</code> |
| 451 | is a keyword and can not be used as an |
| 452 | identifier. |
| 453 | </li> |
| 454 | </ol> |
| 455 | </div> |
| 456 | </div> |
| 457 | <div class="sect3" lang="en" xml:lang="en"> |
| 458 | <div class="titlepage"> |
| 459 | <div> |
| 460 | <div> |
| 461 | <h4 class="title"><a id="idp568208"></a>Building and Running the JDBC Sample code</h4> |
| 462 | </div> |
| 463 | </div> |
| 464 | </div> |
| 465 | <p> |
| 466 | See |
| 467 | <a class="xref" href="build_unix_sql.html#build_unix_jdbc" title="Building the JDBC Driver">Building the JDBC Driver</a> |
| 468 | for instructions on building the JDBC driver. |
| 469 | </p> |
| 470 | <p> |
| 471 | To build and run the JDBC examples do the following: |
| 472 | </p> |
| 473 | <div class="orderedlist"> |
| 474 | <ol type="1"> |
| 475 | <li> |
| 476 | Copy <code class="literal">build_unix/jdbc/sqlite.jar</code> and |
| 477 | <code class="literal">build_unix/jdbc/.libs/libsqlite_jni.so</code> |
| 478 | to the <code class="literal">jdbc_ex</code> directory. |
| 479 | </li> |
| 480 | <li> |
| 481 | <p> |
| 482 | In the <code class="literal">jdbc_ex</code> directory, run the |
| 483 | following commands: |
| 484 | </p> |
| 485 | <pre class="programlisting"> |
| 486 | $ javac -classpath ./sqlite.jar *.java |
| 487 | $ java -classpath .:sqlite.jar -Djava.library.path=. \ |
| 488 | <ClassName, eg. CreateCoffees> |
| 489 | </pre> |
| 490 | </li> |
| 491 | <li> |
| 492 | After you run the CreateCoffees example, use the |
| 493 | <code class="literal">dbsql</code> executable to open the |
| 494 | <code class="literal">myDataSource</code> database file and check if |
| 495 | the table <code class="literal">COFFEES</code> has been successfully |
| 496 | created in the database. |
| 497 | <pre class="programlisting"> |
| 498 | $ dbsql myDataSourcedbsql> .tables |
| 499 | COFFEES |
| 500 | dbsql> .dump |
| 501 | PRAGMA foreign_keys=OFF; |
| 502 | BEGIN TRANSACTION; |
| 503 | CREATE TABLE COFFEES (COF_NAME varchar(32),\ |
| 504 | SUP_ID int, PRICE float, SALES int, TOTAL int); |
| 505 | COMMIT; |
| 506 | dbsql> |
| 507 | </pre></li> |
| 508 | <li> |
| 509 | <p> |
| 510 | Repeat step 3 to run other examples. |
| 511 | </p> |
| 512 | <p> |
| 513 | Note: Some examples, such as AutoGenKeys, are not yet |
| 514 | supported by BDB JDBC driver. The |
| 515 | <code class="literal">SQLFeatureNotSupportedException</code> is |
| 516 | displayed for those unsupported examples. |
| 517 | </p> |
| 518 | </li> |
| 519 | </ol> |
| 520 | </div> |
| 521 | </div> |
| 522 | </div> |
| 523 | <div class="sect2" lang="en" xml:lang="en"> |
| 524 | <div class="titlepage"> |
| 525 | <div> |
| 526 | <div> |
| 527 | <h3 class="title"><a id="idp593744"></a>Building the ODBC Driver</h3> |
| 528 | </div> |
| 529 | </div> |
| 530 | </div> |
| 531 | <p> |
| 532 | This section describes how to build the ODBC driver. |
| 533 | </p> |
| 534 | <div class="sect3" lang="en" xml:lang="en"> |
| 535 | <div class="titlepage"> |
| 536 | <div> |
| 537 | <div> |
| 538 | <h4 class="title"><a id="idp587184"></a>Configuring Your System</h4> |
| 539 | </div> |
| 540 | </div> |
| 541 | </div> |
| 542 | <p> |
| 543 | To configure your system prior to building the ODBC driver, do |
| 544 | the following: |
| 545 | </p> |
| 546 | <div class="orderedlist"> |
| 547 | <ol type="1"> |
| 548 | <li> |
| 549 | Download and install the latest |
| 550 | <a class="ulink" href="http://www.unixodbc.org" target="_top">unixODBC</a> |
| 551 | if ODBC is not already installed on your system. |
| 552 | </li> |
| 553 | <li> |
| 554 | Configure the ODBC server to work with SQLite databases. Follow |
| 555 | <a class="ulink" href="http://www.ch-werner.de/sqliteodbc/html/index.html" target="_top">these instructions</a> |
| 556 | from Christian Werner. |
| 557 | </li> |
| 558 | </ol> |
| 559 | </div> |
| 560 | </div> |
| 561 | <div class="sect3" lang="en" xml:lang="en"> |
| 562 | <div class="titlepage"> |
| 563 | <div> |
| 564 | <div> |
| 565 | <h4 class="title"><a id="idp598600"></a>Building the Library</h4> |
| 566 | </div> |
| 567 | </div> |
| 568 | </div> |
| 569 | <p> |
| 570 | To build the library, do the following: |
| 571 | </p> |
| 572 | <pre class="programlisting"> |
| 573 | $ cd db-5.3.XX/build_unix |
| 574 | $ CFLAGS="-fPIC" ../dist/configure --enable-sql_compat --disable-shared |
| 575 | $ make |
| 576 | $ cd ../lang/sql/odbc |
| 577 | $ CFLAGS="-DHAVE_ERRNO_H -I../../../build_unix -I../../../src/dbinc \ |
| 578 | -I../sqlite/src" LDFLAGS="../../../build_unix/libdb-5.3.a" \ |
| 579 | ./configure --with-sqlite3=../generated |
| 580 | $ make |
| 581 | </pre> |
| 582 | <p> |
| 583 | The <code class="literal">libsqlite3odbc.so</code> library containing a |
| 584 | statically linked version of Berkeley DB SQL is now |
| 585 | built. |
| 586 | </p> |
| 587 | <p> |
| 588 | NOTE: The final <code class="literal">make</code> command above is known |
| 589 | to generate a warning when using GCC. The warning states: |
| 590 | <code class="literal">Warning: Linking the shared library libsqlite3odbc.la |
| 591 | against the static library ../../build_unix/libdb-5.3.a is |
| 592 | not portable!</code>. It is generally safe to ignore the |
| 593 | warning when using the generated library. |
| 594 | </p> |
| 595 | </div> |
| 596 | <div class="sect3" lang="en" xml:lang="en"> |
| 597 | <div class="titlepage"> |
| 598 | <div> |
| 599 | <div> |
| 600 | <h4 class="title"><a id="idp600992"></a>Testing the ODBC Driver</h4> |
| 601 | </div> |
| 602 | </div> |
| 603 | </div> |
| 604 | <p> |
| 605 | The steps to verify that the installed driver works are as follows: |
| 606 | </p> |
| 607 | <div class="orderedlist"> |
| 608 | <ol type="1"> |
| 609 | <li> |
| 610 | Alter the <code class="literal">/etc/odbcinst.ini</code> and |
| 611 | <code class="literal">~/.odbc.ini</code> configuration files to refer |
| 612 | to the libsqlite3odbc.so file built above. |
| 613 | </li> |
| 614 | <li> |
| 615 | <p> |
| 616 | Create a data source, and launch a data source viewer |
| 617 | application by doing the following: |
| 618 | </p> |
| 619 | <pre class="programlisting">$ mkdir ~/databases |
| 620 | $ cd ~/databases |
| 621 | $ /path/to/Berkeley DB/build_unix/sqlite3 mytest.db |
| 622 | dbsql> CREATE TABLE t1(x); |
| 623 | dbsql> .quit; |
| 624 | $ DataManager </pre> |
| 625 | <p> |
| 626 | The final step opens a GUI application that displays |
| 627 | ODBC data sources on a system. You should be able to |
| 628 | find the <code class="literal">mytest.db</code> data source just |
| 629 | created. |
| 630 | </p> |
| 631 | </li> |
| 632 | </ol> |
| 633 | </div> |
| 634 | </div> |
| 635 | </div> |
| 636 | <div class="sect2" lang="en" xml:lang="en"> |
| 637 | <div class="titlepage"> |
| 638 | <div> |
| 639 | <div> |
| 640 | <h3 class="title"><a id="bfile"></a>Building the BFILE extension</h3> |
| 641 | </div> |
| 642 | </div> |
| 643 | </div> |
| 644 | <p> |
| 645 | The BFILE extension allows you to store binary files outside of |
| 646 | the database, but still operate upon them as if they were |
| 647 | stored within the database. To enable this extension, use the |
| 648 | <code class="literal">--enable-load-extension</code> configuration flag. |
| 649 | For example: |
| 650 | </p> |
| 651 | <pre class="programlisting">$ cd <db>/build_unix |
| 652 | $ export DBSQL_DIR=$PWD/../install |
| 653 | $ ../dist/configure --enable-sql --enable-load-extension \ |
| 654 | --prefix=$DBSQL_DIR && make && make install |
| 655 | $ cd ../lang/sql/sqlite/ext/bfile/build |
| 656 | $ make && make install</pre> |
| 657 | <p> |
| 658 | BFILE extensions are only supported for Unix platforms. |
| 659 | </p> |
| 660 | <p> |
| 661 | Note that the extension support has two |
| 662 | interfaces: SQL expressions and a C-functions API. By default, |
| 663 | the SQL expressions are built when you use |
| 664 | <code class="literal">--enable-load_extension</code>. To use the |
| 665 | C-functions API, edit <code class="literal"><db>/lang/sql/ext/bfile/build/Makefile</code> |
| 666 | and set <code class="literal">ENABLE_BFILE_CAPI</code> |
| 667 | to <code class="literal">1</code>. |
| 668 | </p> |
| 669 | <p> |
| 670 | Once you have enabled the extension and built the library, you |
| 671 | can run the included example: |
| 672 | </p> |
| 673 | <pre class="programlisting">$ cd lang/sql/sqlite/ext/bfile/build |
| 674 | $ export LD_LIBRARY_PATH=$PWD:$DBSQL_DIR/lib |
| 675 | $ ./bfile_example_sql # for SQL expressions interface |
| 676 | $ ./bfile_example_capi # for C-functions API</pre> |
| 677 | <p> |
| 678 | For more information on using the BFILE extension, see the |
| 679 | <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide. |
| 680 | </p> |
| 681 | </div> |
| 682 | </div> |
| 683 | <div class="navfooter"> |
| 684 | <hr /> |
| 685 | <table width="100%" summary="Navigation footer"> |
| 686 | <tr> |
| 687 | <td width="40%" align="left"><a accesskey="p" href="build_unix_conf.html">Prev</a> </td> |
| 688 | <td width="20%" align="center"> |
| 689 | <a accesskey="u" href="build_unix.html">Up</a> |
| 690 | </td> |
| 691 | <td width="40%" align="right"> <a accesskey="n" href="build_unix_small.html">Next</a></td> |
| 692 | </tr> |
| 693 | <tr> |
| 694 | <td width="40%" align="left" valign="top">Configuring Berkeley DB </td> |
| 695 | <td width="20%" align="center"> |
| 696 | <a accesskey="h" href="index.html">Home</a> |
| 697 | </td> |
| 698 | <td width="40%" align="right" valign="top"> Building a small memory footprint library</td> |
| 699 | </tr> |
| 700 | </table> |
| 701 | </div> |
| 702 | </body> |
| 703 | </html> |