Experience to solve mySQL garbled problems

xiaoxiao2021-03-06  39

1. Connecting the database STRING URL = "JDBC: mysql: // localhost: 3306 / test /? User = root & useunicode = true & characterencoding = GBK"; // Note that GBK

2. When writing to the database: used to convert the encoding

Public string ex_chinese (string str) {Try {string temp = new string (Str.getbytes ("ISO8859-1"), "GBK"); Return Temp;} Catch (Exception E) {} Return "NULL";}

3. Each JSP page plus

<% @ Page ContentType = "Text / HTML; Charset = GBK" Language = "Java" Import = "java.sql. *" ErrorPage = ""%>

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

New Post(0)