0
嗨,大家好我有簡單的mysql腳本。<jdbc:initialize-database>不能正常工作
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中運行的腳本或蟾蜍它工作正常,但當春天嘗試運行它給了我以下異常:
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