package jdbc;
import java.sql.*;
public class Mango {
public static void main(String[] args) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@66.66.66.128:1521:xe","SYSTEM","matrix");
Statement comm = con.createStatement();
comm.executeQuery("insert into a values('a',1)");
ResultSet res = comm.executeQuery("SELECT * FROM A");
comm.executeQuery("insert into a values('a',1)");
while(res.next()) {
System.out.println(res.getString(1) + " " + res.getInt(2));
}
System.out.println("con class is "+ con.getClass());
System.out.println("comm class is "+ comm.getClass());
System.out.println("res class is "+ res.getClass());
}
}
output:
con class is class oracle.jdbc.driver.T4CConnection
comm class is class oracle.jdbc.driver.T4CStatement
res class is class oracle.jdbc.driver.OracleResultSetImpl
T4CConnection implements the interface Connection T4CStatement implements the interface Statement OracleResultSetImpl implements the interface ResultSet
If connection, statement and resultset are interface's how am I able to invoke them ? I read here that I can never instantiate an interface, but look at this following program here ...