Posted on 2008-09-20 09:10
魚躍于淵 閱讀(136)
評論(0) 編輯 收藏 所屬分類:
精品網摘
[摘要] 作者介紹了一種較為實用的Java操作MySQL的中文處理方法。
[關鍵字] Java MySQL
這是很頭痛的問題,一直都是在困擾著我們。我有一個不算簡單也不算難的方法,這是我一直在用的方式。
1、建立一個類,包括一個格式將中文轉換為ISO8859-1編碼的方法:
publicclass Format2Chinese {
public Format2Chinese() {
}
public String format2IS08859(String str) {
try {
if (str == null str.trim().equals(""))
str = "";
else
str = new String(str.getBytes("ISO8859-1"));
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
2、你的bean里面這時就要加一些東西了,如下面這個簡單的bean:
publicclass Leavemsg
{
public Leavemsg() {