This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Stored Procedure Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Stored Procedure Problem" Watch "Stored Procedure Problem" New topic
Author

Stored Procedure Problem

Gil Li
Greenhorn

Joined: May 27, 2004
Posts: 15
hi
I have added a stored procedure in mySQL database. that stored funstion just gets the input integer and gives with adding number 10.When I execute in mySQL promt that works fine. I tried Java code to get the output. Here is the code. Here i got Exception like 'CallableStatements not Supported' . I dont know what is the problme here. Help me..


import java.sql.*;
import java.io.*;

public class proc
{
public static void main(String a[])
{
try
{

Class.forName("org.gjt.mm.mysql.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jobsearch?user=root&password=");
CallableStatement cs = con.prepareCall("{? = call pr(?)}");


cs.registerOutParameter(1,Types.INTEGER);
cs.setInt(1,5);

cs.execute();

System.out.println(cs.getInt(1));


} catch(Exception e){ System.out.println(e);}



}
}


Regards,<br /> <br />GILLI
Jyothi Lature
Ranch Hand

Joined: Oct 31, 2001
Posts: 60
Hi,

Which version of MySQL are u using? Bcoz, MySQL 3.x lacks support of callable statements via the JDBC API. I guess, using the older version is the problem...


Jyothi<br />Sun Certified Java Programmer<br />Brainbench Certified for Javascript
Gil Li
Greenhorn

Joined: May 27, 2004
Posts: 15
Jyothi...

I am using the latest version mySQL 5.0 which supports stored procedure. But I am not able to invoke the stored procedure via JDBC...I dont know where is the problem....
Thomas Risberg
Greenhorn

Joined: Aug 17, 2004
Posts: 4
Looks like the JDBC driver you are using does not support this new feature. You need to download the latest development driver (3.1.4-beta)


Thomas
Gil Li
Greenhorn

Joined: May 27, 2004
Posts: 15
Thats it...


Thankyou Thomas...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stored Procedure Problem
 
Similar Threads
help: null pointer exception
calling of stored procedure with out parater in hibernate?
java.sql.SQLException: Callable Statements not supported
Problem with stored procedure table parameter
Insertion Values not get stored in sql server using stored procdure in struts2