import java .sql.*;
class Pro
{
public static void main(String args[]) throws Exception
{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test";
Connection conn = DriverManager.getConnection (url,"root","password");
CallableStatement cst=conn.prepareCall("{call fileproc(?,?)}");
cst.setInt(1,10);
cst.registerOutParameter(2,Types.INTEGER);
cst.execute();
int i=cst.getInt(2);
System.out.println("the number is :" +i);
cst.close();
conn.close();
}
}
In MYSQL:
fileproc:
CREATE PROCEDURE fileproc(IN x INT,OUT y INT)
BEGIN
y := x * x;
END;
/
i'm getting an error at line 3 before entering END in fileproc as
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ':= x
* x' at line 3.
what is the correct syntax? please help. Thank You.