Package Dbbean;
Import java.sql.*;
public class contactbean{
Private Connection con; Initialize the connection.
Public Contactbean () {
try {class.forname ("Oracle.jdbc.driver.oracledriver"). newinstance ();
String Url= "Jdbc:oracle:thin: @localhost: 1521:HCM";
String user= "jsp tutorial Dev";
String password= "19831007";
con= drivermanager.getconnection (Url,user,password);
}
catch (Instantiationexception e)
{//Todo auto-generated catch block
E.printstacktrace ();
catch (Illegalaccessexception e)
{//Todo auto-generated catch block
E.printstacktrace ();
}
catch (ClassNotFoundException e)
{
System.out.println ("Driver not found!");
Con=null;
}
catch (SqlException E)
{con=null; }
}
Code two
Class.forName ("Oracle.jdbc.driver.oracledriver"). newinstance ();?
String?url= "Jdbc:oracle:thin: @localhost: 1521:ORCL";
ORCL for the SID of your database tutorial?
String?user= "Scott";?
String?password= "Tiger";?
Connection?conn=?drivermanager.getconnection (Url,user,password);?
//
Class.forName ("Oracle.jdbc.driver.oracledriver"). newinstance ();?
String?url= "Jdbc:oracle:thin: @localhost: 1521:ORCL";
//orcl is the SID of your database?
String?user= "Scott";?
string?password= "Tiger";?
Connection?conn=?drivermanager.getconnection (Url,user,password);?
Statement?stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable
%>