Last change
on this file since 8717 was 8717, checked in by schweer, 19 years ago |
started to rework control flow, user authentication
|
-
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 | */
|
---|
9 | package org.greenstone.gsdlas.database;
|
---|
10 |
|
---|
11 | import java.sql.Connection;
|
---|
12 | import 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 | */
|
---|
21 | public 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";
|
---|
40 | try {
|
---|
41 | Class.forName("com.mysql.jdbc.Driver").newInstance();
|
---|
42 | Connection connection = 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.