Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

New to JDBC Callable Satement

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am learning Callable statement. Just I have the following questions. please help me .

public class Example1{
public static void main(String[] args) {
Connection conn=null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/Movie","root","root");
CallableStatement cast= conn.prepareCall("{call movieproc(?,?)}");
cast.setString(1,"Raja Hindhustani");
cast.setInt(2,1995);
int records= cast.exceuteUpdate();
system.out.println(records+"has been inserted");
}
catch(Exception e){
e.printStackTrace();
}
finally{
conn.close();
}

In this example do we need to define the procedure movieproc seperately?
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In this example do we need to define the procedure movieproc seperately?

Yes. You have to create that procedure in your database. It is called a stored procedure.

 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic