source: trunk/gsdl3/extensions/gsdl-as/src/org/greenstone/gsdlas/database/DatabaseManager.java@ 8738

Last change on this file since 8738 was 8738, checked in by schweer, 19 years ago

user authentication works; user information and subscriptions/predicates are stored to thedatabase

  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1/*
2 * Created on Dec 1, 2004
3 * Copyright (C) Andrea Schweer, 2004
4 *
5 * This file is part of the Greenstone Alerting Service.
6 * Refer to the COPYING file in the base directory of this package
7 * for licensing information.
8 */
9package org.greenstone.gsdlas.database;
10
11import java.sql.Connection;
12import java.sql.DriverManager;
13
14
15/**
16 * @author andrea
17 *
18 * TODO To change the template for this generated type comment go to
19 * Window - Preferences - Java - Code Style - Code Templates
20 */
21public class DatabaseManager {
22
23 private static DatabaseManager instance;
24 private Connection database;
25
26 private DatabaseManager() {
27 // hide constructor
28 }
29
30 public static DatabaseManager getInstance() {
31 if (instance == null) {
32 instance = new DatabaseManager();
33 }
34 return instance;
35 }
36
37 public Connection getDatabaseConnection() throws DatabaseException {
38 if(database == null) {
39 String connectionString = "jdbc:mysql://localhost/alerting?user=gsdl3admin";
40 try {
41 Class.forName("com.mysql.jdbc.Driver").newInstance();
42 database = DriverManager.getConnection(connectionString);
43 } catch (Exception e) {
44 throw new DatabaseException("Could not establish connection to database (" + connectionString + ")", e);
45 }
46 }
47 return database;
48 }
49
50
51}
Note: See TracBrowser for help on using the repository browser.