freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Pier Paolo Bortone" <pierpaolo.bortone AT netengineering.it>
- To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
- Subject: Re: JDBC Connection string?
- Date: Mon, 11 Dec 2000 16:59:19 +0100
Hi,
here is an example to test connection.
Remember to modify username, password, hostname,
dbname.
Good work.
Pier Paolo.
import java.sql.*;
import java.util.*; public class MSSQLServerTestConnection
{
/**/
static String username = "xxxxxxx"; static String password = "xxxxxxx"; static String thinConn = "jdbc:freetds:sqlserver://hostname/dbname"; static String driverClass = "com.internetcds.jdbc.tds.Driver"; /**/ public static Connection
getConnection() throws SQLException {
Connection cn = null;
try
{
Driver d = (Driver)Class.forName(driverClass).newInstance(); cn = DriverManager.getConnection(thinConn,username,password); return
cn;
} catch
(Exception e)
{
e.printStackTrace(System.out); throw new SQLException("Error Loading JDBC Driver"); } } public
static void main(String argv[]) {
try
{
Connection conn = getConnection();
if (conn == null)
{
System.out.println("Connessione nulla!!!"); System.exit(0); } else { boolean b = conn.getAutoCommit(); System.out.println("Connessione riuscita!!!"); System.out.println("AutoCommit " + b); } } catch (SQLException e) { e.printStackTrace(); } } }
|
-
JDBC Connection string?,
Daniel Selin, 12/11/2000
- <Possible follow-up(s)>
- Re: JDBC Connection string?, Pier Paolo Bortone, 12/11/2000
- SV: Re: JDBC Connection string?, Daniel Selin, 12/11/2000
Archive powered by MHonArc 2.6.24.