talking to SphinxQL from java

since a while Sphinx search can be queried not only by their own non-standard interface but also using regular mysql client. they call this feature SphinxQL.

so my work‘s backend no longer has to rely on my own failover code for sphinx – i can leave the dirty details to resin. appserv is already providing resiliency for communication with mysql servers.

but.. it turned out it was not enough to configure database driver pointing to a sphinx server. when i did it i was getting exceptions:

[08:56:11.466] Caused by: java.lang.IllegalArgumentException: Null charset name
[08:56:11.466] at java.nio.charset.Charset.lookup(Charset.java:429)
[08:56:11.466] at java.nio.charset.Charset.forName(Charset.java:502)
[08:56:11.466] at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1936)

so i added at the end of the connection string:

characterEncoding=utf8

but then i got this:

[09:15:58.498] appserv.ParalellEntitySearcher - problems occured com.mysql.jdbc.PacketTooBigException: Packet for query is too large (26 > -1). You can change this value on the server by setting the max_allowed_packet' variable.
[09:15:58.498] at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:612)
[09:15:58.498] at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:415)
[09:15:58.498] at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2576)
[09:15:58.498] at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1757)

so i added this at the end of the connection string:

maxAllowedPacket=512000

quite a generous number, probably 1/20th would do a trick too.

maybe someone will find this useful..

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *