Project

General

Profile

1
/**
2
 *        Name: MetaCatUtil.java
3
 *     Purpose: A Class that implements utility methods for a metadata catalog
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Matt Jones
7
 * 
8
 *     Version: '$Id: MetaCatUtil.java 110 2000-05-31 17:50:59Z bojilova $'
9
 */
10

    
11
package edu.ucsb.nceas.metacat;
12

    
13
import java.sql.Connection;
14
import java.sql.DriverManager;
15
import java.sql.SQLException;
16

    
17
/**
18
 * A suite of utility classes for the metadata catalog server
19
 */
20
public class MetaCatUtil {
21

    
22
  static  String 	user = "jones";
23
  static  String 	password = "your-pw-goes-here";
24
  static  String 	defaultDB = "jdbc:oracle:thin:@localhost:1521:test";
25

    
26
  /** 
27
   * Utility method to establish a JDBC database connection 
28
   *
29
   * @param dbDriver the string representing the database driver
30
   * @param connection the string representing the database connectin parameters
31
   * @param user name of the user to use for database connection
32
   * @param password password for the user to use for database connection
33
   */
34
  public static Connection openDBConnection(String dbDriver, String connection,
35
                String user, String password)
36
                throws SQLException, ClassNotFoundException {
37

    
38
     // Load the Oracle JDBC driver
39
     Class.forName (dbDriver);
40

    
41
     // Connect to the database
42
     Connection conn = DriverManager.getConnection( connection, user, password);
43
     return conn;
44
  }
45
}
(18-18/20)