Debian Codegraph @

docs/installation/build_win_sql.html

raw symbols SCIP
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>Building the SQL API</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_win.html" title="Chapter 5.  Building Berkeley DB for Windows" />
11 <link rel="prev" href="build_win_csharp.html" title="Building the C# API" />
12 <link rel="next" href="build_win_tcl.html" title="Building the Tcl API" />
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">Building the SQL API</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="build_win_csharp.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 5. 
26 Building Berkeley DB for Windows
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="build_win_tcl.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_win_sql"></a>Building the SQL API</h2>
38 </div>
39 </div>
40 </div>
41 <div class="toc">
42 <dl>
43 <dt>
44 <span class="sect2">
45 <a href="build_win_sql.html#idp290248">Binary Compatibility With SQLite</a>
46 </span>
47 </dt>
48 <dt>
49 <span class="sect2">
50 <a href="build_win_sql.html#idp276576">Setting Preprocessor Flags
51 </a>
52 </span>
53 </dt>
54 <dt>
55 <span class="sect2">
56 <a href="build_win_sql.html#idp288280">Enabling Extensions</a>
57 </span>
58 </dt>
59 <dt>
60 <span class="sect2">
61 <a href="build_win_sql.html#win-disablechecksums">Disabling Log Checksums</a>
62 </span>
63 </dt>
64 <dt>
65 <span class="sect2">
66 <a href="build_win_sql.html#build_jdbc">Building the JDBC Driver</a>
67 </span>
68 </dt>
69 <dt>
70 <span class="sect2">
71 <a href="build_win_sql.html#idp266616">Using the JDBC Driver</a>
72 </span>
73 </dt>
74 <dt>
75 <span class="sect2">
76 <a href="build_win_sql.html#idp305704">Building the ODBC Driver</a>
77 </span>
78 </dt>
79 <dt>
80 <span class="sect2">
81 <a href="build_win_sql.html#idp320888"> Using the ADO.NET Driver
82 </a>
83 </span>
84 </dt>
85 </dl>
86 </div>
87 <p>
88 SQL support is built as part of the default build on Windows.
89 For information on the build instructions, see
90 <a class="xref" href="build_win.html" title="Chapter 5.  Building Berkeley DB for Windows">
91 Building Berkeley DB for Windows
92 </a>.
93 </p>
94 <p>
95 The SQL library is built as <code class="literal">libdb_sql53.dll</code>
96 in the Release mode or <code class="literal">libdb_sql53d.dll</code> in
97 the Debug mode. An SQL command line interpreter called
98 <code class="literal">dbsql.exe</code> is also built.
99 </p>
100 <div class="sect2" lang="en" xml:lang="en">
101 <div class="titlepage">
102 <div>
103 <div>
104 <h3 class="title"><a id="idp290248"></a>Binary Compatibility With SQLite</h3>
105 </div>
106 </div>
107 </div>
108 <p>
109 <code class="literal">libdb_sql53.dll</code> is compatible with
110 <code class="literal">sqlite3.dll</code>. You can copy
111 <code class="literal">libdb_sql53.dll</code> to
112 <code class="literal">sqlite3.dll</code> and
113 <code class="literal">dbsql.exe</code> to
114 <code class="literal">sqlite3.exe</code>, and use these applications
115 as a replacement for the standard SQLite binaries with the same
116 names. However, if you want to do this, then any legacy data in use by
117 those tools must be migrated from the standard SQLite database
118 to a Berkeley DB SQL database <span class="emphasis"><em>before</em></span> you
119 replace the standard SQLite dll and executable with the
120 Berkeley DB equivalent. For information on migrating data from
121 standard SQLite databases to a Berkeley DB SQL database, see
122 the <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide.
123 </p>
124 <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
125 <h3 class="title">Warning</h3>
126 <p>
127 Rename your dlls and executables to the standard SQLite
128 names with <span class="emphasis"><em>extreme</em></span> care. Doing this
129 will cause all existing tools to break that currently
130 have data stored in a standard SQLite database.
131 </p>
132 <p>
133 <span class="emphasis"><em>
134 For best results, rename your dlls and command
135 line tool to use the standard SQLite names only if you
136 know there are no other tools on your production
137 platform that rely on standard SQLite.
138 </em></span>
139 </p>
140 </div>
141 </div>
142 <div class="sect2" lang="en" xml:lang="en">
143 <div class="titlepage">
144 <div>
145 <div>
146 <h3 class="title"><a id="idp276576"></a>Setting Preprocessor Flags
147 </h3>
148 </div>
149 </div>
150 </div>
151 <p>
152 By default, Berkeley DB SQL generates each table as a subdatabase in
153 a single file. To generate each table in a separate file, specify
154 <span class="emphasis"><em>BDBSQL_FILE_PER_TABLE</em></span> in
155 <span class="emphasis"><em>Preprocessor Definitions </em></span>of the <code class="literal">db_sql</code> project.
156 </p>
157 <p>
158 When this option is enabled, the SQL database name is used as a
159 directory name. This directory contains one file for the metadata
160 and one file each for every table created by the SQL API. Do not add
161 or delete files from the database directory. Adding or deleting
162 files may corrupt the database. To backup just the metadata
163 (schema), make a copy of the <code class="literal">metadata</code> and
164 <code class="literal">table00001</code> files from the database directory.
165 Make a new copy whenever the schema is changed.
166
167 </p>
168 </div>
169 <div class="sect2" lang="en" xml:lang="en">
170 <div class="titlepage">
171 <div>
172 <div>
173 <h3 class="title"><a id="idp288280"></a>Enabling Extensions</h3>
174 </div>
175 </div>
176 </div>
177 <p>
178 The Berkeley DB SQL API provides extensions such as full text
179 search and R-Tree index. To enable these extensions, do the
180 following:
181 </p>
182 <div class="orderedlist">
183 <ol type="1">
184 <li>
185 Open the Berkeley DB solution in Visual Studio.
186 </li>
187 <li>
188 Specify <span class="emphasis"><em>SQLITE_ENABLE_FTS3</em></span> or
189 <span class="emphasis"><em>SQLITE_ENABLE_RTREE</em></span> in
190 <span class="emphasis"><em>Preprocessor Definitions</em></span> of the
191 <code class="literal">db_sql</code> project.
192 </li>
193 <li>
194 Re-build the <code class="literal">db_sql</code> project.
195 </li>
196 </ol>
197 </div>
198 <p>
199 See the SQLite Documentation for more information on
200 <a class="ulink" href="http://www.sqlite.org/fts3.html" target="_top">full text search</a>
201 and <a class="ulink" href="http://www.sqlite.org/rtree.html" target="_top">R-Tree</a>.
202 </p>
203 </div>
204 <div class="sect2" lang="en" xml:lang="en">
205 <div class="titlepage">
206 <div>
207 <div>
208 <h3 class="title"><a id="win-disablechecksums"></a>Disabling Log Checksums</h3>
209 </div>
210 </div>
211 </div>
212 <p>
213 You can disable checksums in log records so as to provide a
214 boost to database performance. However, this comes at the risk
215 of having undetectable log file corruption that could prevent data
216 recovery in the event of database corruption.
217 </p>
218 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
219 <h3 class="title">Note</h3>
220 <p>
221 Note that disabling log record checksums is meant to only be
222 used with the SQL interface. However, disabling checksums for
223 the SQL interface also disables checksums for the non-SQL
224 interfaces.
225 </p>
226 </div>
227 <p>
228 To disable log checksums, before you build the library edit the
229 <code class="literal">build_windows/db_config.h</code> file, and delete
230 the following line:
231 </p>
232 <pre class="programlisting">#define HAVE_LOG_CHECKSUM 1</pre>
233 </div>
234 <div class="sect2" lang="en" xml:lang="en">
235 <div class="titlepage">
236 <div>
237 <div>
238 <h3 class="title"><a id="build_jdbc"></a>Building the JDBC Driver</h3>
239 </div>
240 </div>
241 </div>
242 <p>
243 This section describes the steps to build the JDBC driver.
244 </p>
245 <div class="orderedlist">
246 <ol type="1">
247 <li>
248 <p>
249 Configure your build environment. For information on how to
250 configure to build Java applications, see
251 <a class="xref" href="build_win_java.html" title="Building the Java API">Building the Java API</a>.
252 </p>
253 </li>
254 <li>
255 <p>
256 Build the SQL project in Debug mode.
257 </p>
258 </li>
259 <li>
260 <p>
261 Open Berkeley_DB.sln or Berkeley_DB_vs2010.sln in Visual Studio.
262 If you are using Java 1.6, do the following:
263 </p>
264 <div class="itemizedlist">
265 <ul type="disc">
266 <li>
267 <p>
268 In the Solution Explorer, right-click the
269 <code class="literal">db_sql_jdbc</code> project and select
270 <span class="emphasis"><em>properties</em></span>.
271 </p>
272 </li>
273 <li>
274 <p>
275 In the <span class="emphasis"><em>Configuration Properties -&gt; Build
276 Events -&gt; Pre-Build Event</em></span> section,
277 alter the command to refer to <code class="literal">JDBC2z</code>
278 instead of <code class="literal">JDBC2x</code>.
279 </p>
280 </li>
281 </ul>
282 </div>
283 <p>
284 If you are using Java 1.7, do the following:
285 </p>
286 <div class="itemizedlist">
287 <ul type="disc">
288 <li>
289 <p>
290 In the Solution Explorer, right-click the
291 <code class="literal">db_sql_jdbc</code> project and select
292 <span class="emphasis"><em>properties</em></span>.
293 </p>
294 </li>
295 <li>
296 <p>
297 In the <span class="emphasis"><em>Configuration Properties -&gt; Build
298 Events -&gt; Pre-Build Event</em></span> section,
299 alter the command to refer to
300 <code class="literal">JDBC2z1</code> instead of
301 <code class="literal">JDBC2x</code>. Also, remove the option of
302 "-target 1.5".
303 </p>
304 </li>
305 <li>
306 <p>
307 Go to <code class="literal">db\lang\sql\jdbc\SQLite</code>, and
308 replace <code class="literal">JDBCDriver.java</code> with
309 <code class="literal">JDBCDriver.java17</code>, and replace
310 <code class="literal">JDBCDataSource.java</code> with
311 <code class="literal">JDBCDataSource.java17</code>.
312 </p>
313 </li>
314 </ul>
315 </div>
316 </li>
317 <li>
318 Build the <code class="filename">db_sql_jdbc</code> project in Visual Studio.
319 </li>
320 </ol>
321 </div>
322 <p>
323 You can test the build by entering the following commands from the
324 <code class="literal">db\build_windows\Win32\Debug</code> directory:
325 </p>
326 <table class="simplelist" border="0" summary="Simple list">
327 <tr>
328 <td> javac -cp ".;jdbc.jar" -d . ..\..\..\sql\jdbc\test3.java </td>
329 </tr>
330 <tr>
331 <td>java -cp ".;jdbc.jar" test3 </td>
332 </tr>
333 </table>
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="idp266616"></a>Using the JDBC Driver</h3>
340 </div>
341 </div>
342 </div>
343 <p>
344 This section describes the steps to download, build, and run
345 sample programs using the built JDBC driver.
346 </p>
347 <div class="sect3" lang="en" xml:lang="en">
348 <div class="titlepage">
349 <div>
350 <div>
351 <h4 class="title"><a id="idp287112"></a>Downloading JDBC Sample Code</h4>
352 </div>
353 </div>
354 </div>
355 <p>
356 The download link for JDBC sample code is available on the
357 <a class="ulink" href="http://www.oracle.com/technetwork/java/index-139949.html" target="_top">
358 Oracle Technology Network (OTN)
359 </a>. You can identify
360 the link by the "JDBC programming examples from all three
361 editions (ZIP format)" text beside it.
362 </p>
363 </div>
364 <div class="sect3" lang="en" xml:lang="en">
365 <div class="titlepage">
366 <div>
367 <div>
368 <h4 class="title"><a id="idp306216"></a>Modifying Sample Code</h4>
369 </div>
370 </div>
371 </div>
372 <p>Before running the sample code, do the following:</p>
373 <div class="orderedlist">
374 <ol type="1">
375 <li>Unzip the file containing the sample code to a new directory (for example, jdbc_ex).</li>
376 <li>Substitute <code class="literal">jdbc:sqlite:/&lt;db-file-name&gt;</code> for the generic JDBC URL that appears in the code. That is, put <code class="literal">jdbc:sqlite:/&lt;db-file-name&gt;</code> between the quotation marks in the line:
377 <p><code class="literal"> String url = "jdbc:mySubprotocol:myDataSource";</code></p><p> Note: The &lt;db-file-name&gt; can either be an absolute path name like <code class="literal">"D:\\jdbc_ex_db\\myDataSource"</code>, or a relative path-file-name like <code class="literal">"..\\jdbc_ex_db\myDataSource"</code>, or a file name, like <code class="literal">"myDataSource"</code>, in which the database file will be stored at the current directory.</p></li>
378 <li>Substitute <code class="literal">SQLite.JDBCDriver</code> for <code class="literal">myDriver.ClassName</code> in the line: <code class="literal">Class.forName("myDriver.ClassName");</code></li>
379 <li>Substitute the username and password you use for your database in the following: <code class="literal">"myLogin", "myPassword"</code>. <p>This is optional.</p></li>
380 <li>If your JDK version is above 1.5, change the variable name <code class="literal">enum</code> in <code class="literal">OutputApplet.java</code> to some other variable name because, as of JDK release 5 <code class="literal">enum</code> is a keyword and can not be used as an identifier.</li>
381 </ol>
382 </div>
383 </div>
384 <div class="sect3" lang="en" xml:lang="en">
385 <div class="titlepage">
386 <div>
387 <div>
388 <h4 class="title"><a id="idp305344"></a>Building and Running the JDBC Sample code</h4>
389 </div>
390 </div>
391 </div>
392 <p>See <a class="xref" href="build_win_sql.html#build_jdbc" title="Building the JDBC Driver">Building the JDBC Driver</a> for instructions about building JDBC driver.</p>
393 <p>To build and run the JDBC examples do the following:</p>
394 <div class="orderedlist">
395 <ol type="1">
396 <li>In the <code class="literal">db\build_windows\Win32\Debug</code> directory, run following commands:
397 <pre class="programlisting">
398 $ javac -classpath ".;jdbc.jar" -d . \path\to\jdbc_ex\*.java
399 $ java -classpath ".;jdbc.jar" &lt;ClassName, eg. CreateCoffees&gt;
400 </pre></li>
401 <li>After you run the CreateCoffees example, use the <code class="literal">dbsql</code> executable to open the <code class="literal">myDataSource</code> database file and check if the table <code class="literal">COFFEES</code> has been successfully created in the database.
402 <pre class="programlisting">
403 $ dbsql myDataSourcedbsql&gt; .tables
404 COFFEES
405 dbsql&gt; .dump
406 PRAGMA foreign_keys=OFF;
407 BEGIN TRANSACTION;
408 CREATE TABLE COFFEES (COF_NAME varchar(32),/
409 SUP_ID int, PRICE float, SALES int, TOTAL int);
410 COMMIT;
411 dbsql&gt;
412 </pre></li>
413 <li>Repeat step 2 to run other examples.
414 <p>Note: Some examples like AutoGenKeys are not yet supported by BDB JDBC driver. The <code class="literal">SQLFeatureNotSupportedException</code> is displayed for those unsupported examples.</p></li>
415 </ol>
416 </div>
417 </div>
418 </div>
419 <div class="sect2" lang="en" xml:lang="en">
420 <div class="titlepage">
421 <div>
422 <div>
423 <h3 class="title"><a id="idp305704"></a>Building the ODBC Driver</h3>
424 </div>
425 </div>
426 </div>
427 <p>
428 This section describes the steps required to build the ODBC driver.</p>
429 <div class="sect3" lang="en" xml:lang="en">
430 <div class="titlepage">
431 <div>
432 <div>
433 <h4 class="title"><a id="idp308768"></a>Configuring Your System</h4>
434 </div>
435 </div>
436 </div>
437 <p>
438 To configure your system prior to building the ODBC driver, do the following:
439 </p>
440 <div class="orderedlist">
441 <ol type="1">
442 <li>
443 Download and install the latest SQLite ODBC driver Windows installer package for <a class="ulink" href="http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe" target="_top">32 bit Windows</a> or <a class="ulink" href="http://www.ch-werner.de/sqliteodbc/sqliteodbc_w64.exe" target="_top">64 bit Windows</a>.
444 </li>
445 <li>
446 Download and install the latest
447 <a class="ulink" href="http://www.microsoft.com/download/en/details.aspx?id=21995" target="_top">
448 Microsoft Data Access Components (MDAC) SDK
449 </a>. The MDAC SDK is only required for testing the installation.
450 </li>
451 </ol>
452 </div>
453 </div>
454 <div class="sect3" lang="en" xml:lang="en">
455 <div class="titlepage">
456 <div>
457 <div>
458 <h4 class="title"><a id="idp340976"></a>Building the Library</h4>
459 </div>
460 </div>
461 </div>
462 <div class="orderedlist">
463 <ol type="1">
464 <li>
465 Build the SQL project in Release mode. See <a class="xref" href="build_win_sql.html" title="Building the SQL API">Building the SQL API</a>.
466 </li>
467 <li>Open Visual Studio.</li>
468 <li>Load the Berkeley_DB solution file into Visual Studio.</li>
469 <li>Set the build target to <span class="emphasis"><em>Release</em></span></li>
470 <li>Build the solution.</li>
471 <li>
472 Select <span class="emphasis"><em>File</em></span> -&gt; <span class="emphasis"><em>Add</em></span> -&gt; <span class="emphasis"><em>Existing Project</em></span>.
473 </li>
474 <li>Select <code class="filename">build_windows</code>.</li>
475 <li>
476 Select the appropriate directory for your compiler: <code class="filename">VS8</code> or <code class="filename">VS10</code>.
477 </li>
478 <li>
479 Select <code class="filename">db_sql_odbc.vcproj</code> and add it to the Berkeley_DB solution.
480 This adds the <code class="filename">db_sql_odbc</code> Visual Studio project to the Berkeley_DB solution file.
481 </li>
482 <li>Build the <code class="filename">db_sql_odbc</code> project. This can be done by right-clicking the <code class="filename">db_sql_odbc</code> project in the project explorer panel, and selecting <code class="literal">build</code>.</li>
483 </ol>
484 </div>
485 <p>The <code class="literal">sqlite3odbc.dll</code>, <code class="literal">libdb_sql53.dll</code> and <code class="literal">libdb53.dll</code> files are now built.</p>
486 </div>
487 <div class="sect3" lang="en" xml:lang="en">
488 <div class="titlepage">
489 <div>
490 <div>
491 <h4 class="title"><a id="idp299552"></a>Installing the Library</h4>
492 </div>
493 </div>
494 </div>
495 <p>Copy the dll files built in the <span class="emphasis"><em>Building the Library</em></span> section to the Windows system folder.</p>
496 <p>The Windows system folder is different on different systems, but is often <code class="literal">C:\WINDOWS\System32</code>.</p>
497 </div>
498 <div class="sect3" lang="en" xml:lang="en">
499 <div class="titlepage">
500 <div>
501 <div>
502 <h4 class="title"><a id="idp334400"></a>Testing the ODBC Install</h4>
503 </div>
504 </div>
505 </div>
506 <p>The steps to verify that the installed driver works are as follows:</p>
507 <div class="orderedlist">
508 <ol type="1">
509 <li>Open the Unicode ODBCTest application. On Windows XP: <span class="emphasis"><em>Windows start</em></span> -&gt; <span class="emphasis"><em>Microsoft Data Access SDK 2.8</em></span> -&gt; <span class="emphasis"><em>ODBCTest (Unicode, x86).</em></span></li>
510 <li>Select the <span class="emphasis"><em>Conn</em></span> -&gt; <span class="emphasis"><em>Full Connect...</em></span> menu item.</li>
511 <li>Select <code class="literal">SQLite3 Datasource</code> and click <code class="literal">OK</code>.</li>
512 <li>Select the <span class="emphasis"><em>Stmt</em></span> -&gt; <span class="emphasis"><em>SQLExecDirect...</em></span> menu item.</li>
513 <li>Enter <code class="literal">CREATE TABLE t1(x);</code> in the <code class="literal">Statement</code> text box and click <code class="literal">OK</code>.</li>
514 <li>Verify that no error messages were output to the error window.</li>
515 </ol>
516 </div>
517 </div>
518 </div>
519 <div class="sect2" lang="en" xml:lang="en">
520 <div class="titlepage">
521 <div>
522 <div>
523 <h3 class="title"><a id="idp320888"></a> Using the ADO.NET Driver
524 </h3>
525 </div>
526 </div>
527 </div>
528 <p>
529 Go to the
530 <a class="ulink" href="http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html" target="_top">Oracle Berkeley DB download page</a>,
531 and download the ADO.NET package. Build the package by following
532 the <a href="../bdb-sql/buildinstall.html#ado_net" class="olink">instructions</a> included
533 in the package.
534 </p>
535 </div>
536 </div>
537 <div class="navfooter">
538 <hr />
539 <table width="100%" summary="Navigation footer">
540 <tr>
541 <td width="40%" align="left"><a accesskey="p" href="build_win_csharp.html">Prev</a> </td>
542 <td width="20%" align="center">
543 <a accesskey="u" href="build_win.html">Up</a>
544 </td>
545 <td width="40%" align="right"> <a accesskey="n" href="build_win_tcl.html">Next</a></td>
546 </tr>
547 <tr>
548 <td width="40%" align="left" valign="top">Building the C# API </td>
549 <td width="20%" align="center">
550 <a accesskey="h" href="index.html">Home</a>
551 </td>
552 <td width="40%" align="right" valign="top"> Building the Tcl API</td>
553 </tr>
554 </table>
555 </div>
556 </body>
557 </html>