Java Reference
In-Depth Information
public final void loadProperties() {
hostname = props.getProperty("host_name");
port = props.getProperty("port_number");
database = props.getProperty("db_name");
username = props.getProperty("username");
password = props.getProperty("password");
driver = props.getProperty("driver");
jndi = props.getProperty("jndi");
}
/**
* Demonstrates obtaining a connection via
DriverManager
*
* @return
* @throws SQLException
*/
public Connection getConnection() throws SQLException
{
Connection conn = null;
String jdbcUrl;
if (driver.equals("derby")) {
jdbcUrl = "jdbc:derby://" + this.hostname
+ ":"
+ this.port + "/" + this.database;
} else {
jdbcUrl = "jdbc:oracle:thin:@"
+ this.hostname + ":"
+ this.port + ":" + this.database;
}
conn = DriverManager.getConnection(jdbcUrl,
username, password);
System.out.println("Successfully connected");
return conn;
}
Search WWH ::




Custom Search