1
|
import java.sql.Connection;
|
2
|
import java.sql.DriverManager;
|
3
|
import java.sql.SQLException;
|
4
|
|
5
|
/**
|
6
|
* A suite of utility classes for the metadata catalog server
|
7
|
*/
|
8
|
public class MetaCatUtil {
|
9
|
|
10
|
static String user = "jones";
|
11
|
static String password = "your-pw-goes-here";
|
12
|
static String defaultDB = "jdbc:oracle:thin:@localhost:1521:test";
|
13
|
|
14
|
/**
|
15
|
* Utility method to establish a JDBC database connection
|
16
|
*
|
17
|
* @param dbDriver the string representing the database driver
|
18
|
* @param connection the string representing the database connectin parameters
|
19
|
* @param user name of the user to use for database connection
|
20
|
* @param password password for the user to use for database connection
|
21
|
*/
|
22
|
public static Connection openDBConnection(String dbDriver, String connection,
|
23
|
String user, String password)
|
24
|
throws SQLException, ClassNotFoundException {
|
25
|
|
26
|
// Load the Oracle JDBC driver
|
27
|
Class.forName (dbDriver);
|
28
|
|
29
|
// Connect to the database
|
30
|
Connection conn = DriverManager.getConnection( connection, user, password);
|
31
|
return conn;
|
32
|
}
|
33
|
}
|