neo4j JDBC Chinese garbled

Source: Internet
Author: User
Tags neo4j

NEO4J's JDBC connection is actually sending an HTTP request (using the httpclient), for Chinese, when inserting data, JDBC uses UTF-8 encoded post submission, but when the Chinese data is returned, it does not indicate that the data is UTF-8 encoding. Therefore, HttpClient will use the platform to parse the data, if the platform encoding is GBK and other coding, the good case, the platform can be encoded after parsing the resultset, and then the correct code to parse the data; in bad cases, the data cannot be parsed when the resultset is dumped. Throw an exception directly.

Solution:

Because NEO4J uses the Restlet processing request, you can modify the Restlet's Clientresource post method, as follows:

 /*** Posts a representation.     If a success status is no returned, then A * resource exception is thrown. *      * @paramEntity * the posted entity. * @returnThe optional result entity. * @throwsresourceexception *@see<a * href= "http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5 ">http * POST method</a>*/     PublicRepresentation post (representation entity)throwsresourceexception {representation R=handle (Method.post, entity);   R.setcharacterset (Characterset.utf_8); //through many experiments, neo4j only use this post method, the other post methods do not need to set        returnR; }

Then in the change of the source code into a jar package, you can solve the problem of Chinese garbled.

A good bag of Jar:http://pan.baidu.com/s/152uia

neo4j JDBC Chinese garbled

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.