訪問oracle資料庫Long類型欄位遇到的問題!
來源:互聯網
上載者:User
long形欄位的問題我曾經遇到過,如果要取long型欄位的數值,必須見過處理。
添加新的方法:
/**
* Insert the method´s description here.
* Creation date: (2002-6-4 17:37:55)
*/
public static String getLargerString(java.io.Reader reader) throws Exception {
char[] content = new char[1024000];
char[] buffer = new char[1024];
int len = 0;
int off = 0;
int contentLen = 1024000;
while(true)
{
len = reader.read(buffer);
if( len == -1)
break;
if( off + len > contentLen )
{
char[] tmp = new char[contentLen + 1024000];
System.arraycopy(content, 0, tmp, 0, off);
content = tmp;
contentLen = contentLen + 1024000;
}
System.arraycopy(buffer, 0, content, off, len);
off = off + len;
}
return new String(content, 0, off);
}
在你的程式中需要加入這幾段語句:
if(rs.next()){
java.io.Reader reader = (java.io.Reader)rs.getCharacterStream("N_TOTAL_POINT");
String strtmp = (String)getLargerString(reader);
}
這是取long型欄位的方法,如果要在資料庫中插入long型欄位,也需要處理一下