What are the common tasks of JDBC?

  • Create an instance of a JDBC driver or load JDBC drivers through jdbc.drivers
  • Register a driver
  • Specify a database
  • Open a database connection
  • Submit a query
  • Receive results

Showing Answers 1 - 3 of 3 Answers

Prass

  • Jul 12th, 2005
 

and also close connection

  Was this answer useful?  Yes

Jayachandran

  • Jan 3rd, 2006
 

please Can any post the sample code for this set of operations. How do we register ?. Through DirverManager or what else ?

  Was this answer useful?  Yes

srilatha

  • Jan 22nd, 2006
 

import java.sql.*;
class Type1
{
 public static void main(String[] args)throws Exception
 {
  Connection c=null;
  try
  {
    Driver d=new Driver("sun.jdbc.odbc.JdbcOdbc");
     //or  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c=DriverManager.getConnection("jdbc:odbc:emp1","scott","tiger");
    Statement s=c.createStatement();
    s.executeUpdate("insert into dept(deptno,loc)values(60,'hyd')");
  }
  catch(Exception e)
  {
    e.printStackTrace();
  }
  finally
  {
    c.close();
  }
 }
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions