JDBC MYSQL SyntaxErrorException

时间:2011-06-16 20:51:36

标签: java mysql sphinx

我正在使用JDBC / SphinxQL(Sphinx版本2.01 Beta)执行以下查询

带有WHERE子句:

ResultSet res = stmt.executeQuery("SELECT * FROM myindex WHERE MATCH('name')");

没有WHERE CLAUSE

ResultSet res = stmt.executeQuery("SELECT * FROM myindex");

但在这两种情况下,我都遇到了以下非常大的错误:

  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
sphinxql: syntax error, unexpected WHERE, expecting $end near
 'WHERE Variable_name ='language' OR Variable_name = 
'net_write_timeout' OR Variable_name = 'interactive_timeout'
 OR Variable_name = 'wait_timeout' OR Variable_name = 
'character_set_client' OR Variable_name = 'character_set_connection'
 OR Variable_name = 'character_set' OR Variable_name 
= 'character_set_server' OR Variable_name = 'tx_isolation'
 OR Variable_name = 'transaction_isolation' OR Variable_name
 = 'character_set_results' OR Variable_name = 'timezone' 
OR Variable_name = 'time_zone' OR Variable_name = 
'system_time_zone' OR Variable_name = 'lower_case_table_names'
 OR Variable_name = 'max_allowed_packet' OR
 Variable_name = 'net_buffer_length' OR Variable_name = 
'sql_mode' OR Variable_name = 'query_cache_type' 
OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect''

我根本不理解错误...感谢帮助!

2 个答案:

答案 0 :(得分:1)

SphinxQL无法识别我们这样的不同条款 timezone,interactive_timeout,net_write_timeout等这就是为什么这些查询失败的原因。你必须使用不发布这种无限制内容的不同MySQL客户端 - 只是你的简单查询。或者您可以尝试使用SphinxSerach服务向开发人员指出该问题。

答案 1 :(得分:0)

您的MATCH谓词格式不正确。

变化:

SELECT * FROM myindex WHERE MATCH('name')

SELECT * FROM myindex WHERE MATCH(some_column) AGAINST ('name')