The server-hibernate is used to operate mysql. Chinese characters cannot be found during fuzzy query, and numbers and English characters can be found.

Source: Internet
Author: User
Hibernate is used for fuzzy query. the parameter passed on the page also handles the garbled @ Action (value & quot; searchNameByad & quot;) publicStringsearchNameByad () throwsException {System. out. println (& quot; android sends the request to get the parameter: & quot; + buildingname); solve the garbled problem StringbnnewString (buildingname. getBytes (& quot; iso-88 server mysql remote connection hibernate

Hibernate is used for fuzzy query, and the parameters passed on the page are also garbled.
@ Action (value = "searchNameByad ")
Public String searchNameByad () throws Exception {
System. out. println ("The parameter obtained by the android sending request is:" + buildingname );
// Solve the garbled problem
String bn = new String (buildingname. getBytes ("iso-8859-1"), "UTF-8 ");
List buildings = buildingService. getByName (bn );
In the local test, data can be found by passing Chinese parameters, but after being uploaded to the server, the Chinese parameters cannot be found. only numbers and English words can be found. I used a local remote connection to the server database, and the data was not found by Chinese parameters... You can also query the database on the server .. Solution
This is the hql statement after the local remote connection to the server database
Hibernate: select building0 _. buildingid as buildingid11 _, building0 _. area as area11 _, building0 _. buildingname as building3_11 _, building0 _. linkman as linkman11 _, building0 _. linkphone as linkphone11 _, building0 _. email as email11 _, building0 _. qrcode as qrcode11 _, building0 _. province as province11 _, building0 _. city as city11 _ from airquality. building building0 _ where building0 _. buildingname like '% Guang %'

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.