Mysql jdbc程序使用callable语句查找数字的平方(存储过程)

Mysql jdbc程序使用callable语句查找数字的平方(存储过程),mysql,jdbc,syntax,Mysql,Jdbc,Syntax,在MYSQL中: 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","pas

在MYSQL中:

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();
}
}
在fileproc中输入END之前,我在第3行遇到一个错误

fileproc:
CREATE  PROCEDURE fileproc(IN x INT,OUT y INT)
BEGIN
y := x * x;
END;
/
正确的语法是什么? 请帮忙。 谢谢。

mysql>创建数据库;
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.
->使用; 分隔符// 创建过程fileproc(输入x int,输出y int) 开始 设置y=x*x; 结束// mysql>分隔符; mysql>call(10,@y); mysql>选择@y;
mysql>create database <database-name>;
     ->use <database-name>;
      delimiter //
      Create Procedure fileproc(in x int, out y int)
      begin
      set y = x * X;
      end //
mysql> delimiter ;
mysql> call(10,@y);
mysql> Select @y;