Solaris access to a MS SQL Database

Steve Sherwood stephens at
Thu Nov 11 13:16:11 EST 1999

On Wed, 10 Nov 1999 13:1:44, Dan Gregoria wrote:

>Compiling and running my Java program (uses JDBC)on NT gave a useful result 
>in that I was able to access a MS SQL Server database located on a separate 
>NT server.
>Moving the source to a new install of JDK 1.1.8 on Solaris 2.5.1, then 
>comiling and running it gave the following error messsages.  My code put 
>out diagnostics with "***" prefix:

Don't use the ODBC bridge for java, it's buggy. Get the FreeTDS JDBC
drivers, install in your classpath, and do something like the code below.
I use the same code for solaris, linux and NT, connecting to MSSQL 6.5 and 7
with no problems.

import java.sql.*;

public class foo {
	public static void main(String s[])
		Connection con;
		try {

			con = DriverManager.getConnection(
				"jdbc:freetds://Host/Database", "Login", "Password");

			Statement stmt = con.createStatement();
			stmt.executeQuery("SELECT * FROM Spam");

		catch (SQLException e) {
		catch (ClassNotFoundException e) {

   Steve Sherwood - stephens at - (01635) 810517
| Just like Pariah I have no name | Never feed your cat   |
| Living in a blaze of obscurity  | anything that clashes |
| Need courage to survive the day | with the carpet...    |
       (A)bort (R)etry (I)nfluence with large hammer

More information about the FreeTDS mailing list