00001 import java.sql.DriverManager;
00002 import java.sql.Connection;
00003 import java.sql.SQLException;
00004
00005
00006
00007 class DoctorDb implements ConnectionFactory
00008 {
00009
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
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 }