2011-06-08 40 views
0

我想通過使用mysql-connector-java-5.1.15的ant任務在mysql服務器上運行以下sql腳本,但它不起作用並且在第三個命令中出現以下錯誤。我可以讓其他腳本在螞蟻中正常工作,因此它不是連接問題。MySQL工作臺和mysql-connector-java-5.1.15之間的區別

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 TABLE IF 
EXISTS `tmp_cui_desc`; 
CREATE TABLE `tmp_cui_desc` (
    CUI CHAR(8' at line 15 

奇怪的是,腳本在連接到相同服務器的MySql工作臺(v5.2.31)中工作得非常好。爲什麼要這樣呢?數據庫是latin1,字符集系統是uft8。這可能是問題的一部分嗎?如果是的話,我需要做些什麼來解決它?

非常感謝任何幫助 Rob。

 

USE umls; 

/* 
* creates a summary view of the umls_mrconso table which abstracts most of the detail from atoms to concepts 
* this is a table with a single row per CUI 
* 
*/ 

/* 
* Create a temporary table based on the sources of a given cui 
*/ 
DROP TABLE IF EXISTS tmp_cui_sabs; 
CREATE TABLE tmp_cui_sabs (
    CUI CHAR(8) NOT NULL, 
    SABS VARCHAR(255), 
    PRIMARY KEY (CUI) 
) 
SELECT 
    u.CUI as CUI, 
    GROUP_CONCAT(DISTINCT u.SAB ORDER BY u.SAB ASC SEPARATOR '|') as SABS 
FROM umls_mrconso u 
GROUP BY u.CUI; 

/* 
* Create a temporary table containing the best available description for any given cui 
*/ 
DROP TABLE IF EXISTS tmp_cui_desc; 
CREATE TABLE tmp_cui_desc (
    CUI CHAR(8) NOT NULL, 
    TERM VARCHAR(255), 
    PRIMARY KEY (CUI) 
) 
SELECT 
    u.CUI as CUI, 
    MIN(u.STR) as TERM 
FROM umls_mrconso u 
WHERE u.ISPREF='Y' 
AND u.LAT='ENG' 
AND u.TS='P' 
GROUP BY u.CUI; 

/* 
* Create a permanent table as the join of the 2 temporary tables 
* contains a preferred description, and all the sources that map to this cui, 
* as well as the CUI itself. 
* TODO: could be useful to include semantic type info here as well? 
*/ 
DROP TABLE IF EXISTS bmj_cui_summary; 
CREATE TABLE bmj_cui_summary (
    CUI CHAR(8) NOT NULL, 
    TERM VARCHAR(255), 
    SABS VARCHAR(255), 
    PRIMARY KEY (CUI) 
) 
SELECT 
    sabs.CUI as CUI, 
    LOWER(descs.TERM) as TERM, 
    sabs.SABS as SABS 
FROM 
    tmp_cui_sabs sabs, 
    tmp_cui_desc descs 
WHERE sabs.CUI=descs.CUI; 

/* 
* clean up tmp tables 
*/ 
DROP TABLE IF EXISTS tmp_cui_sabs; 
DROP TABLE IF EXISTS tmp_cui_desc; 

+0

不知道jdbc,但通常您只能通過c-lib在一段時間內共享一條sql語句。 (我猜也是由jdbc使用的)。如果你使用ant,你不能直接調用mysql客戶端。例如'mysql -uusername -ppassword Rufinus 2011-06-08 15:43:25

回答

0

只是猜測,但你可能只能發送一個命令每個查詢。所以把它們分開;並單獨查詢。我用另一種語言解決了這個問題。

+0

似乎可以發送多個命令,但jdbc引擎在提交之前會執行一些查詢解析。在這種情況下,它不喜歡\ * * \評論風格,並且它曾經用#語法替換過 – 2011-06-28 15:56:12