java对oracle数据库连接操作
导入classes12.java
public class ConnectOracleTools {
private final String driverName="oracle.jdbc.driver.OracleDriver";
private final String serverName="10.11.104.213";
private final String portNumber="1521";
private String sid="oracle";
private String username;
private String password;
public Connection getConnectionOracle(String username,String password)
{
try {
Class.forName(driverName);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String url="jdbc:oracle:thin:@"+serverName+":"+portNumber+":"+sid;
this.username=username;
this.password=password;
Connection con =null;
try {
con = DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
}