例子
package netabcadmin;
import javaio*;
import javasql*;
import javautil*;
public class ConnectionBean
{
private static Connection conn = null;
public static Connection getConnection()
{
if (conn == null)
{
try
{
DriverManagerregisterDriver(new oraclejdbcdriverOracleDriver());
conn = DriverManagergetConnection(jdbc:oracle:thin:@+hostname+:+port+:+dbSIDusernamepassword);
} catch(SQLException e)
{
eprintStackTrace();
}
// if(conn == null)
// Systemoutprintln(database connection error);
}
return conn;
}
}