00001 /* 00002 * SCTDBInterface.java 00003 * 00004 * Created on 08 September 2003, 12:31 00005 */ 00006 00007 package ProdDatabase; 00008 import java.sql.*; 00013 public class SCTDBInterface implements DBAccessInfo { 00014 private static SCTDBInterface instance = new SCTDBInterface(); 00015 public Connection connection; 00016 private String DBusername = "SCTREAD"; 00017 00019 private SCTDBInterface() { 00020 Refresh(); 00021 } 00022 00023 public static SCTDBInterface getInstance() { 00024 return instance; 00025 } 00026 00027 public void Refresh() { 00028 try { 00029 if(connection==null) { 00030 System.out.println("Trying to connect to production database ..."); 00031 // Load Oracle driver 00032 DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); 00033 DriverManager.setLoginTimeout(10); // give it 10 seconds max before timing out 00034 connection = DriverManager.getConnection (connectionName, DBusername, DBpassword); 00035 System.out.println("Connection to SCT database established."); 00036 } 00037 }catch(Exception e){System.out.println("Failed to connect to database: "+e.toString());} 00038 00039 } 00040 public boolean isConnected() { 00041 return (connection!=null); 00042 } 00043 }