How can you create JDBC statements?

A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. E.g. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object stmt :Statement stmt = con.createStatement();

Showing Answers 1 - 7 of 7 Answers

saadu

  • Oct 22nd, 2005
 

First create

  Was this answer useful?  Yes

rameshvdnv

  • Apr 25th, 2007
 

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con;
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","scott","tiger");
Statement stmt=con.createStatement();

  Was this answer useful?  Yes

trinadh gantla

  • May 3rd, 2007
 

Using Statement interface we can create JDBC statements as follows 

Statement stmt=con.createStatement();

here con is the connection object reference


Different types of statements are
Prepared Statement - whenever we want to execute single query multiple times then
we will goto this statement
Callable Statement - whenever we want to call the stored procedures from database
server then we will use this statement

Thank u
3nadh
 


  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