Solaris access to a MS SQL Database
Steve Sherwood
stephens at cabletron.com
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.io.*;
import java.sql.*;
import java.net.URL;
public class foo {
public static void main(String s[])
{
Connection con;
try {
Class.forName("com.internetcds.jdbc.tds.Driver");
Class.forName("com.internetcds.jdbc.tds.SybaseDriver");
con = DriverManager.getConnection(
"jdbc:freetds://Host/Database", "Login", "Password");
Statement stmt = con.createStatement();
stmt.executeQuery("SELECT * FROM Spam");
stmt.close();
con.close();
}
catch (SQLException e) {
System.out.println(e.getMessage());
}
catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
}
}
---
Steve Sherwood - stephens at ctron.com - (01635) 810517
O---------------------------------+-----------------------O
| 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... |
O---------------------------------+-----------------------O
(A)bort (R)etry (I)nfluence with large hammer
More information about the FreeTDS
mailing list