Easysoft ODBC-Derby Driver
How do I connect Microsoft SQL Server to Apache Derby?
Use the Apache Derby ODBC Driver to connect Microsoft SQL Server to Apache Derby and:
- Use a linked server to work with Apache Derby data, just as if you were working with data stored in a SQL Server table.
- Integrate Apache Derby with SQL Server by using SQL Server Integration Services (SSIS).
The Apache Derby ODBC Driver is available to download from the Easysoft web site:
- Download the Windows Apache Derby ODBC Driver.
-
Install and license the Apache Derby ODBC Driver on the machine where SQL Server is installed.
For installation instructions, see the Apache Derby ODBC Driver documentation.
Before you can use the Apache Derby ODBC Driver to connect SQL Server to Apache Derby, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (e.g. Apache Derby) and the ODBC driver that is required to connect to it (e.g. the Apache Derby ODBC driver).
You can configure a User ODBC data source, which is only available to the user who creates it, or a System ODBC data source, which is available to all users on the machine. You configure ODBC data sources in ODBC Administrator, which is included with Windows.
There are two versions of ODBC Administrator on this platform. The version of ODBC Administrator that you need to run depends on whether you have a 32-bit or a 64-bit version of SQL Server. To find out which version of SQL Server you have, connect to your SQL Server instance, and then run this SQL statement:
select SERVERPROPERTY('edition')
If you have the 64-bit version of SQL Server and want to use a linked server with the Apache Derby ODBC driver, you need to run 64-bit version of ODBC Administrator. To do this, in the Windows Run dialog box, type:
%windir%\system32\odbcad32.exe
If you have the 32-bit version of SQL Server or want to use SSIS with the Apache Derby ODBC driver, you need to run 32-bit version of ODBC Administrator. To do this, in the Windows Run dialog box, type:
%windir%\syswow64\odbcad32.exe
Use ODBC Administrator to create your Apache Derby ODBC Driver data source:
-
Do one of the following:
-
To create a User data source, in the User DSN tab, choose Add.
–Or–
- To create a System data source, choose the System DSN tab, and then choose Add.
- In the Create New Data Source dialog box, choose Easysoft ODBC-Derby Driver, and then choose Finish.
-
Complete the Easysoft ODBC-Derby Driver DSN Setup dialog box:
Setting |
Value |
DSN |
Apache Derby |
Database |
The Apache Derby database you want to connect to. |
User Name |
If you need to specify a user name to access your Apache Derby database, enter it here. Otherwise, leave this field blank. |
Password |
The password for the Apache Derby user name, if applicable. |
- Use the Test button to verify that you can successfully connect to Apache Derby.
You can now connect SQL Server to Apache Derby.
Example: Retrieve Apache Derby Data by using a Linked Server
-
In Microsoft SQL Server Management Studio, connect to the SQL Server instance you want to create the linked server against.
You need to log on with an account that is a member of the SQL Server sysadmin fixed server role to create a linked server.
- Right-click Server Objects. From the pop-up menu choose New > Linked Server.
- In the Linked server box, type "Derby".
- From the Provider list, choose Microsoft OLE DB Provider for ODBC Drivers.
-
In the Data source box, type the name of your Apache Derby ODBC data source, and then choose OK.
SQL Server verifies the linked server by testing the connection.
- If you get the error "Specified driver could not be loaded due to system error 126: The specified module could not be found", choose Yes when prompted whether to keep the linked server. You need to restart your SQL Server instance before you can use the linked server. If SQL Server was already running when you installed the Apache Derby ODBC driver, it will not have the latest version of the System PATH environment variable. The Apache Derby ODBC driver Setup program adds entries for the driver to the System PATH. Restarting the instance makes these changes available to SQL Server, allowing it to load the Apache Derby ODBC driver.
- If you made a mistake when specifying the Apache Derby ODBC data source, you get the error "Data source name not found and no default driver specified. If you get this error, choose No when prompted whether to keep the linked server and edit the value in the Data source box.
-
You can query your Apache Derby data either by using a:
-
Pass-through query in an OPENQUERY function. For example:
SELECT * FROM OPENQUERY(DERBY, 'SELECT * FROM FIRSTTABLE')
SQL Server sends pass-through queries as uninterpreted query strings to the Apache Derby ODBC driver. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.
Example: Integrate Apache Derby with SQL Server by using SQL Server Integration Services (SSIS)
These instructions assume that:
- You have Microsoft Visual Studio and SQL Server Data Tools for Visual Studio installed.
-
Your Apache Derby ODBC Data Source connects to a database in which you have created the Derby example database, ToursDB. The example inserts records into the COUNTRIES table:
CREATE TABLE COUNTRIES
(
COUNTRY VARCHAR(26) NOT NULL,
COUNTRY_ISO_CODE CHAR(2) NOT NULL ,
REGION VARCHAR(26)
);
ALTER TABLE COUNTRIES
ADD CONSTRAINT COUNTRIES_PK Primary Key (
COUNTRY_ISO_CODE);
ALTER TABLE COUNTRIES
ADD CONSTRAINT COUNTRIES_UNQ_NM Unique (
COUNTRY);
ALTER TABLE COUNTRIES
ADD CONSTRAINT COUNTRIES_UC
CHECK (country_ISO_code = upper(country_ISO_code) );
-
Create a .csv file named countries.csv with the following contents:
COUNTRY,COUNTRY_ISO_CODE,REGION
Afghanistan,AF,Asia
Albania,AL,Europe
Algeria,DZ,North Africa
American Samoa,AS,Pacific Islands
Angola,AO,Africa
Argentina,AR,South America
Armenia,AM,Europe
Australia,AU,Australia and New Zealand
Austria,AT,Europe
Azerbaijan,AZ,Central Asia
- In Visual Studio, create a new Integration Services Project.
- Drag a Data Flow Task from the Toolbox to the Control Flow tab.
- Choose the Data Flow tab.
-
Drag a Flat File Source from the Toolbox to the Data Flow tab, and then press Return.
Flat File Source is under the Other Sources list.
- In the Flat File Source Editor, choose New.
- In the Flat File Connection Manager Editor dialog box, browse for your .csv file.
- Choose Preview, and then choose OK to exit the dialog boxes.
-
Drag an ODBC Destination from the Toolbox to the Data Flow tab, and then press Return.
ODBC Destination is in the Other Destinations list.
- Select the Flat File Source. Drag the blue arrow over to the ODBC Destination.
- Select the ODBC Destination, and then press Return.
- In the ODBC Destination dialog box, choose New.
- In the Configure ODBC Connection Manager dialog box, choose New.
- In the Connection Manager dialog box, choose your Apache Derby ODBC data source, and then use the OK button to return to the ODBC Source dialog box.
- In the Name of the table or the view list, choose Countries.
- Choose Mappings. Use the OK button to exit the ODBC Destination dialog boxes/
- Choose the Start button to insert the records from the .csv file into Apache Derby.
Applies To
-
Products
- Easysoft ODBC-Derby Driver
-
Applications
Knowledge Base Feedback