Search code examples
javajdbcodbc-bridge

Connecting to SQLServer using JDBC-ODBC Bridge


I'm writing an applicationt hat was prototyped on MySQL and is now connecting to an Oracle database.

All I had to do to connect to the oracle database (having built up the table structure) was change the connection string.

What is the format to connect to a SQL Server DB on another machine?

I've read some tutorials which tell you to use the SQL Server JDBC adaptor but I'd rather configure the application so that it's database agnostic, and just have the connection string specify the protocol etc.

Any references I've seen which tell you how to use the bridge with SQL Server require the ODBC Data Source to be installed, this is less than ideal as my app may run on Linux or windows.

I'm not doing anything complicated just inserts.


Solution

  • You should not use the JDBC-ODBC bridge in a production environment. It is much slower than other JDBC drivers and only necessary when a JDBC driver is not available.

    SQL Server has a JDBC driver available from Microsoft. If you use it then you will get the required result.

    With the ODBC bridge you have no choice but to install the ODBC driver.

    This article describes the connection string you will need to use to connect to the SQL Server.