Created
September 10, 2010 16:03
-
-
Save arockwell/573893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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