Building the SQL API
Prev | Chapter 4. Building Berkeley DB for Windows | Next

## Building the SQL API

SQL support is built as part of the default build on Windows. For information on the build instructions, see Building Berkeley DB for Windows .

The SQL library is built as `libdb_sql50.dll` in the Release mode or `libdb_sql50d.dll` in the Debug mode. An SQL command line interpreter called `db_sql_shell.exe` is also built.

### Binary Compatibility With SQLite

Both `libdb_sql50.dll` and `libdb_sql50d.dll` are compatible with sqlite3.dll. You can rename `libdb_sql50.dll` to `sqlite3.dll` and `db_sql_shell.exe` to `sqlite3.exe`, and use these applications as a replacement for the standard SQLite binaries with same names.

### Enabling Extensions

The Berkeley DB SQL API provides extensions such as full text search and R-Tree index. To enable these extensions, do the following:

1. Open the Berkeley DB solution in Visual Studio.
2. Specify `SQLITE_ENABLE_FTS3` or `SQLITE_ENABLE_RTREE` in Preprocessor Definitions of the db_sql project.
3. Re-build the db_sql project.

See the SQLite Documentation for more information on full text search and R-Tree.

### Building the JDBC Driver

This section describes the steps to build the JDBC driver.

1. Configure your build environment. For information on how to configure to build Java applications, see Building the Java API.
2. Build the SQL project in Debug mode.
3. Open Visual Studio.
4. Select `File`->`Add`->`Existing Project`.
5. Select `build_windows/db_sql_jdbc.vcproj` and add it to the Berkeley_DB solution. This adds the db_sql_jdbc Visual Studio project to the Berkeley_DB solution file.
6. Build the `db_sql_jdbc` project in Visual Studio.

You can test the build by entering the following commands from the `db\build_windows\Win32\Debug` directory:

javac -cp ".;jdbc.jar" -d . ..\..\..\sql\jdbc\test3.java
java -cp ".;jdbc.jar" test3

### Building the ODBC Driver

This section describes the steps required to build the ODBC driver.

#### Configuring Your System

To configure your system prior to building the ODBC driver, do the following:

1. Download and install the latest SQLite ODBC driver Windows installer package for 32 bit Windows or 64 bit Windows.
2. Download and install the latest Microsoft Data Access Components (MDAC) SDK. The MDAC SDK is only required for testing the installation.

#### Building the Library

1. Build the SQL project in Release mode. See Building the SQL API.
2. Open Visual Studio.
3. Load the Berkeley_DB solution file into Visual Studio.
4. Set the build target to Release
5. Build the solution.
6. Select `File`->`Add`->`Existing Project`.
7. Select `build_windows/db_sql_odbc.vcproj` and add it to the Berkeley_DB solution. This adds the db_sql_odbc Visual Studio project to the Berkeley_DB solution file.
8. Build the `db_sql_odbc` project. This can be done by right-clicking the `db_sql_odbc` project in the project explorer panel, and selecting `build`.

The `sqlite3odbc.dll`, `libdb_sql50.dll` and `libdb50.dll` files are now built.

#### Installing the Library

Copy the dll files built in the Building the Library section to the Windows system folder.

The Windows system folder is different on different systems, but is often `C:\WINDOWS\System32`.

#### Testing the ODBC Install

The steps to verify that the installed driver works are as follows:

1. Open the Unicode ODBCTest application. On Windows XP: `Windows start`->`Microsoft Data Access SDK 2.8`->`ODBCTest (Unicode, x86).`
2. Select the `Conn`->`Full Connect...` menu item.
3. Select `SQLite3 Datasource` and click `OK`.
4. Select the `Stmt`->`SQLExecDirect...` menu item.
5. Enter `CREATE TABLE t1(x);` in the `Statement` text box and click `OK`.
6. Verify that no error messages were output to the error window.

Prev | Up | Next
Building the C# API | Home | Building the Tcl API