如何在Java中保留原始unicode字符串?

时间:2019-04-18 04:12:36

标签: java

我是一名新的Java开发人员。在我的项目中,我创建了一个unicode字符串(越南语),考试:“vượtngưỡng80%”。但是,当我使用java项目将此数据插入数据库时​​,该数据会转换为“ v?t ng?ng 80%”。数据库表的列已用UTF-8更改。当我尝试使用HeidiSql插入Sql Statemane时,数据未转换。这意味着数据库中的数据为:“ v%80%”。 请帮我。 感谢您的阅读。 这是我的课:

package com.wecommit.criticalService.createWarning;

import java.nio.charset.Charset;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wecommit.criticalService.entity.TableSpace;
import com.wecommit.criticalService.entity.TableSpaceWarning;
import com.wecommit.criticalService.repository.TableSpaceWarningRepository;

@Service
public class TablespaceCreateWarning {

TableSpace tableSpace;
TableSpaceWarning tableSpaceWarning;
byte[] bytes = new byte[10];

String currientString;

List<TableSpaceWarning> listLastTableSpaceWarning;

@Autowired
TableSpaceWarningRepository tableSpaceWarningRepository;


public void setTablespaceCreateWarning
    (TableSpace tableSpace,
    TableSpaceWarning tableSpaceWarning)
{   
    this.currientString = "";
    this.tableSpace = tableSpace;
    this.tableSpaceWarning = tableSpaceWarning;
}

public void doTablespaceCreateWarning() {
    setflagWarning();
}

//all method
public void setflagWarning() {

    if (tableSpace.getUse_percentage() > 80) {
        tableSpaceWarning.setFull_flag(1);
        setReportWarningFlowTableSpace(this.currientString," vượt ngưỡng 80%");
    } 
}


public void setReportWarningFlowTableSpace(String currentWarning, String addedWarning) {

    currentWarning = currentWarning + "\r\n";
    currentWarning = currentWarning + tableSpace.getName() + addedWarning;
    currientString = currentWarning;
    tableSpaceWarning.setReport_warning(currentWarning);
}

public TableSpaceWarning getTableSpaceWarning() {
    return this.tableSpaceWarning;
}

}

0 个答案:

没有答案
相关问题