我正在從Oracle數據庫讀取BLOB數據類型表。但特殊字符正在逃避。下面是我的代碼。從BLOB數據類型中引用特殊字符
public static void main(String args[]) throws FileNotFoundException
{
System.out.println("Oracle Connect START.");
Connection conn = null;
String url = "jdbc:oracle:thin:@localhost:1521:";
String dbName = "xe";
String driver = "oracle.jdbc.OracleDriver";
String userName = "T24DBA";
String password = "ABCD123abcd";
int locationofp=0;
ResultSet orset = null;
ResultSet rs1 = null;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
Statement stmt = conn.createStatement();
orset =stmt.executeQuery("select RECID, XMLRECORD from karthi");
Blob lob = null;
FileOutputStream fos = new FileOutputStream("C:/DataRead/fbnk.txt");
DataOutputStream dos = new DataOutputStream(fos);
while (orset.next()) {
String RECID = orset.getString(1);
lob=orset.getBlob("XMLRECORD");
byte[] bdata = lob.getBytes(1, (int) lob.length());
String text = new String(bdata);
System.out.println("TEXT "+ text);
}
}
在數據庫中的記錄是
EUR100011510þGBP100011200þGBP100011250þGBP100011500þGB
,但我得到的輸出是
EUR100011510�GBP100011200�GBP100011250�GBP100011500�GB
我所有的場標記字符(TH)都正被泄露。
任何幫助將不勝感激。我奮力這對於過去兩天
感謝
OP,這是[標籤:爪哇]?我添加了java標籤,但如果不是,我的道歉。 – Passerby
是的,僅限Java! – user2742540