MySQL workbench和mysql-connector-java-5.1.15之间的区别

时间:2011-06-08 15:39:50

标签: mysql ant jdbc mysql-workbench

我试图通过使用mysql-connector-java-5.1.15的ant任务在mysql服务器上运行以下sql脚本,但它不起作用,我在第三个命令上收到以下错误。我可以从ant获得其他脚本正常工作,因此它不是连接问题。

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。这可能是问题的一部分吗?如果是这样,我需要做些什么来解决它?

非常感谢任何帮助 罗布。


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;

1 个答案:

答案 0 :(得分:0)

只是一个猜测,但你可能只能为每个查询发送一个命令。所以把他们分开;并单独查询。我用另一种语言解决了这个问题。