Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

main JDBC Interfaces

java.sql.DriverManager
java.sql.Connection
java.sql.Statement
java.sql.ResultSet
Class.forName("oracle.jdbc.driver.OracleDriver");//register driver
Connection connection=
DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe",
"username","password");//establish the connection

////////////////////////////////////////////
String sEmplSQL="";
String sDeptSQL="";
Statement stmEmpl=null;
Statement stmDept=null;
//con stands for connection
try{

con.setAutoCommit(false);
stmtEmpl=con.createStatement();
stmtDept=con.createStatement();
stmtEmpl.executeUpdate(sEmplSQL);
stmtDept.executeUpdate(sDeptSQL);
con.commit();
}catch(SQLEXCEPTION sqle){
con.rollback();
}finally{
if(stmtEmpl !=null) stmtEmpl.close();
if(stmtDept !=null) stmtDept.close();
}

You might also like