aspose file tools
The moose likes JDBC and the fly likes PreparedStatement and CallableStatement? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "PreparedStatement and CallableStatement?" Watch "PreparedStatement and CallableStatement?" New topic
Author

PreparedStatement and CallableStatement?

raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
Hi guys! Can anyone give the advantages/disadvantages of PreparedStatement/CallableStatement?Which one is better to use?
thanks!
raymond
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26138
    
  66

PreparedStatement is for regular SQL. CallableStatement is for prepared statements.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
sandhiya sindhi
Ranch Hand

Joined: Sep 25, 2003
Posts: 50
Prepared statements are compiled only once and rest of the time just datas are placed
It is just same as that of writting a query in the sql plus.
like
insert into emp (id,name) values (?,?)
evey time you will say &
this same as that of prepared statement.
if you have oracle then you can see.
Callable statements are used to execute stored procedured
raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
I've read some article on the internet that says callablestatement(stored proc) is much faster than the preparedstatement.the only problem is that using stored proc, you're tied up to a certain db.what if in the future you change db?
Nehul NN
Ranch Hand

Joined: Nov 05, 2003
Posts: 45
Because you know which JDBC driver you are using. According to your driver you will write sql statement in Statement, PrepareStatement & Call... etc. As of I know all database has some variation to sql & not all has store procedure like on in Oracle using PL/SQL...just a input...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: PreparedStatement and CallableStatement?
 
Similar Threads
Sql query ignores variable
Urgent help needed! How to set NULL value to a binary field?
Collection in oracle
Statement and PreparedStatement
Prepared Statement