Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

DoctorDb.java

Go to the documentation of this file.
00001 import java.sql.DriverManager;
00002 import java.sql.Connection;
00003 import java.sql.SQLException;
00004 
00005 // Database configuration information is all in here
00006 
00007 class DoctorDb implements ConnectionFactory
00008 {
00009   // Practice number for this practice (kludge)
00010   public static final int PRACTICE_ID = 67;
00011   
00012   public Connection connect() throws ClassNotFoundException, SQLException
00013   {
00014     Class.forName("org.postgresql.Driver");
00015     Connection conn = DriverManager.getConnection(
00016       "jdbc:postgresql://localhost/doctor",
00017       "postgres", "lewrujop"
00018     );
00019     return conn;
00020   }
00021   
00022   public void disconnect(Connection conn) throws SQLException
00023   {
00024     if (conn != null) conn.close();
00025   }
00026   
00027   
00028   
00029   // guessing this is a happy way to make a singleton in java
00030   
00031   static DoctorDb singleton;
00032   
00033   public static DoctorDb getSingleton()
00034   {
00035     if (singleton == null) singleton = new DoctorDb();
00036     return singleton;
00037   }
00038   
00039 }

Generated on Mon Mar 6 23:34:34 2006 by  doxygen 1.4.4