Skip to content

Instantly share code, notes, and snippets.

@arockwell
Created September 10, 2010 16:03
Show Gist options
  • Select an option

  • Save arockwell/573893 to your computer and use it in GitHub Desktop.

Select an option

Save arockwell/573893 to your computer and use it in GitHub Desktop.
package edu.ufl.vivo;
import java.sql.*;
public class Demo {
static Connection connection = null;
static final String dbDriver = "net.sourceforge.jtds.jdbc.Driver";
static final String dbUrl = "jdbc:jtds:sqlserver://erp-beta-odbc.ad.ufl.edu:1433/ODBCWH;domain=UFAD";
static final String dbUser = "user";
static final String dbPassword = "password";
public Connection getConnection() {
if ( connection != null )
return connection;
try {
connection = DriverManager.getConnection(
dbUrl, dbUser, dbPassword );
} catch( Exception e ) {
System.err.println(e);
}
return connection;
}
public static void main(String[] args) {
Demo demo = new Demo();
System.out.println("Getting Database driver" );
try {
Class.forName( dbDriver );
} catch( ClassNotFoundException e ) {
System.err.println(e);
}
System.out.println("Getting Database connection" );
Connection connection = demo.getConnection();
if ( connection == null ) {
System.exit(0);
}
System.out.println( "Database ready" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment