Solution to the writing of Java in the database Chinese character data

xiaoxiao2021-03-06  41

Other Filter and other methods, most websites have introduced, not much here

1: Re-pair string Code String sname = rs.getstring ("sname"); sname = new string (Sname.getbytes ("ISO-8859-1"), "GBK"); at this time, the Chinese can display correctly

Note: When writing data in SQL Server, write directly, read directly (if the write or query parameters are transmitted through the JSP page, that is, use the request.getParameter () method, the data taken is re-encoded. )

In MySQL, when writing data, re-encode, read, write directly

(Implemented above JSP) 2: Connection declaration: Connect Sybase with JConnect to ensure that the database uses Chinese character sets, such as Eucgb, UTF8, CP936, and setting the necessary connection properties when JConnect programming, including charset (requirement to keep it with database) Consistent) and JCONNECT_VERSION.

E.g:

JCONN3:

JDBC: Sybase: TDS: Hostname: Port / DBNAME? CHARSET = CP850 & JCONNECT_VERSION = 3

And the data obtained is still the character transcoding of 1 steps can be displayed normally in Java.

转载请注明原文地址:https://www.9cbs.com/read-65226.html

New Post(0)