//Creating a Statement reference
import java.sql.*;
public class Statement_obj
{
public static void main(String args[])
{
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("thin driver is registerd");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
System.out.println("Connection is established to DB");
Statement stmt=con.createStatement();
System.out.println("Statement object is created");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Registeration faild");
}
}
}
/*
Explanation:
Here we are not creating a Statement object but
we are creating a reference variable to Statement interface
and we are creating a object which implements the Statement interface
(Most of the Techniclal Lazy people calls it as Statement object)
*/
No comments:
Post a Comment