Connecting to SQLServer Using JDBC-ODBC Bridge
I am writing an application that has been prototyped in MySQL and now connects to an Oracle database.
All I had to do to connect to the oracle database (by creating the table structure) was to change the connection string.
What is the format for connecting to a SQL Server database on another computer?
I have read several tutorials that tell you how to use the SQL Server JDBC adapter, but I would prefer to configure the application so that it is not database agnostic and just enter the connection string, etc.
Any links I have seen explaining how to use bridging with SQL Server requires an ODBC data source to be installed, this is not as ideal as my application might run on Linux or Windows.
I'm not doing anything complicated, just pasting.
source to share
You should not use JDBC-ODBC bridge in production. It is much slower than other JDBC drivers and is only needed when a JDBC driver is not available.
SQL Server has a JDBC driver available from Microsoft. If you use it, you will get the desired result.
With ODBC bridging, you have no choice but to install the ODBC driver.
This article describes the connection string that you will need to use to connect to SQL Server.
source to share
DO NOT use the JDBC-ODBC bridge driver. This was purely for testing purposes, not production. You can still make your aggregated application database with drivers optimized for the database you want to connect to. Just change the username, password database driver name, and link string, and don't use SQL specific SQL and you should be fine.
To connect to SQL Server use the jTDS driver http://jtds.sourceforge.net/ The format of the connection string is as follows:
: jtds JDBC: SQLServer: // localhost / my_database
There are several other options you can include, separated by semicolons, but I think that's all it takes. Obviously, when you connect, you need to provide a username and password.
source to share
These days its a pretty easy to use Factory Pattern and then load JDBC drivers to work with your data data. This architecture gives the best of both worlds, that is, flexibility and efficiency. The only downside to this is the bit configuration / programming to handle dynamic loading, but I hope if you want to make it database agnostic that's the way to go.
source to share