Easysoft ODBC-Derby Driver

How do I connect Microsoft SQL Server to Apache Derby?

Article:
01075
Last Reviewed:
30th January 2024
Revision:
1

Use the Apache Derby ODBC Driver to connect Microsoft SQL Server to Apache Derby and:

The Apache Derby ODBC Driver is available to download from the Easysoft web site:

  1. Download the Windows Apache Derby ODBC Driver.
  2. 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:

  1. 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.
  2. In the Create New Data Source dialog box, choose Easysoft ODBC-Derby Driver, and then choose Finish.
  3. 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.
  4. 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

  1. 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.

  2. Right-click Server Objects. From the pop-up menu choose New > Linked Server.
  3. In the Linked server box, type "Derby".
  4. From the Provider list, choose Microsoft OLE DB Provider for ODBC Drivers.
  5. 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.
  6. 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:

  1. 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
  2. In Visual Studio, create a new Integration Services Project.
  3. Drag a Data Flow Task from the Toolbox to the Control Flow tab.
  4. Choose the Data Flow tab.
  5. 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.

  6. In the Flat File Source Editor, choose New.
  7. In the Flat File Connection Manager Editor dialog box, browse for your .csv file.
  8. Choose Preview, and then choose OK to exit the dialog boxes.
  9. Drag an ODBC Destination from the Toolbox to the Data Flow tab, and then press Return.

    ODBC Destination is in the Other Destinations list.

  10. Select the Flat File Source. Drag the blue arrow over to the ODBC Destination.
  11. Select the ODBC Destination, and then press Return.
  12. In the ODBC Destination dialog box, choose New.
  13. In the Configure ODBC Connection Manager dialog box, choose New.
  14. 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.
  15. In the Name of the table or the view list, choose Countries.
  16. Choose Mappings. Use the OK button to exit the ODBC Destination dialog boxes/
  17. Choose the Start button to insert the records from the .csv file into Apache Derby.
Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)