Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql <;jdbc:初始化数据库>;它不起作用了_Mysql_Spring - Fatal编程技术网

Mysql <;jdbc:初始化数据库>;它不起作用了

Mysql <;jdbc:初始化数据库>;它不起作用了,mysql,spring,Mysql,Spring,大家好,我这里有一个简单的mysql脚本 delimiter $$ use ta DROP FUNCTION IF EXISTS bin2uuid; CREATE FUNCTION bin2uuid(bin BINARY(16)) RETURNS char(36) CHARSET utf8 DETERMINISTIC BEGIN DECLARE hex CHAR(32); IF(bin IS NULL) THEN RETURN NULL; ELSE SET

大家好,我这里有一个简单的mysql脚本

delimiter $$
use ta

DROP FUNCTION IF EXISTS bin2uuid;
CREATE FUNCTION bin2uuid(bin BINARY(16)) RETURNS char(36) CHARSET utf8
    DETERMINISTIC
BEGIN
  DECLARE hex CHAR(32);
  IF(bin IS NULL) THEN
    RETURN NULL;
  ELSE
    SET hex = HEX(bin);
    RETURN LOWER(CONCAT(LEFT(hex, 8),'-'
                          ,SUBSTR(hex, 9,4),'-'
                          ,SUBSTR(hex,13,4),'-'
                          ,SUBSTR(hex,17,4),'-'
                          ,RIGHT(hex, 12)
                          ));
  END IF;
END;

DROP FUNCTION IF EXISTS uuid2bin;

CREATE FUNCTION `uuid2bin`(guid CHAR(36))
   RETURNS binary(16)
   DETERMINISTIC
   BEGIN
      IF (guid IS NULL)
      THEN
         RETURN NULL;
      ELSE
         SET @newguid = IFNULL(guid, UUID());
         RETURN UNHEX(REPLACE(@newguid, '-', ''));
      END IF;
   END;

DROP FUNCTION IF EXISTS calcAllocTradPartyName;   

CREATE FUNCTION calcAllocTradPartyName(vTradeId varchar(36))
  RETURNS varchar(200)
  BEGIN
    DECLARE pTradingPartName varchar(200);

  SELECT
    IF(tpo.broker = 1,IFNULL(GROUP_CONCAT(DISTINCT  IFNULL(tp.symbol,otp.name) SEPARATOR ', '),'TRADAIR'),tpo.name) INTO pTradingPartName
    FROM trades t
    INNER JOIN orderslogadd o ON t.orderId = o.orderId
    INNER JOIN users u ON o.userId = u.guid
    LEFT JOIN orgs tpo ON u.orgId = tpo.guid
    LEFT JOIN tradesAlloc tra ON t.guid = tra.tradeId
    LEFT JOIN tradingparty tp ON tra.tradingpartyId = tp.id
    LEFT JOIN orgs otp ON tra.tradingpartyId = otp.guid
    WHERE t.guid = uuid2bin(vTradeId);

  RETURN pTradingPartName;
  END;   


$$
下面是我的
app context.xml
中初始化数据库的一部分。问题是,当我在mysql或TOAD中运行脚本时,它工作正常,但当Spring尝试运行时,它会给我以下异常:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'CREATE FUNCTION bin2uuid(bin BINARY(16)) RETURNS char(36) CHARSET utf8     DETER' at line 1
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'delimiter' at line 1
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'DROP FUNCTION IF EXISTS bin2uuid; CREATE FUNCTION bin2uuid(bin BINARY(16)) RETUR' at line 1
我试图在没有分隔符的情况下运行它,但在出现以下异常时失败:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'CREATE FUNCTION bin2uuid(bin BINARY(16)) RETURNS char(36) CHARSET utf8     DETER' at line 1
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'delimiter' at line 1
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'DROP FUNCTION IF EXISTS bin2uuid; CREATE FUNCTION bin2uuid(bin BINARY(16)) RETUR' at line 1

您还没有显示您的配置,但我猜您也需要向Spring介绍分隔符(没有标准的SQL脚本语句分隔符)。元素具有用于此目的的分隔符属性