java如何访问Oracle的long类型?
来源:互联网 发布:ubuntu add to dash 编辑:程序博客网 时间:2024/05/01 15:54
我现在想用一个字段来存长字符串(在于4000,varchar2不能满足),想到用LONG,但是用JDBC连的时报SQL不正确,请高人指点,相当紧急!!!!
Do a search with Google... e.g.
Sample demonstrating the usage of LONG type
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/basic/LongSample/Readme.html
// Populate the ResultSet
while(resultSet.next()) {
InputStream insurancedata; // Holds the LONG data
StringBuffer dataBuffer = new StringBuffer();
/* Obtain the LONG data into a byte array. LONG data can be accessed in
two ways: 1) By retrieving all the data in one shot (getBytes method)
2) By using streams. The LONG data is made available to the program
as an Ascii or Unicode stream, and the data can be retrieved chunk by
chunk, which is more eficient in terms of memory usage
In this sample we illustrate retrieval using streams */
insurancedata = resultSet.getAsciiStream(1);
while((chunk = insurancedata.read()) != -1) {
dataBuffer.append((char)chunk);
}
Code for inserting Long Data public void insertData(String code, String name, String partner,
String textfile) throws Exception {
// Create a File to read data from the specified text file (textfile)
File file =
new File(getClass().getClassLoader().getResource(textfile).getFile());
// Prepare the statement for inserting a row into the OTN_AIRLINES_LONG
PreparedStatement pstmt = connection.prepareStatement(" INSERT INTO "+
"otn_airlines_long( code, name, partner,"+
"airline_insurance_data) VALUES(?, ?, ?, ?)");
// Bind the parameter values for the above statement
pstmt.setString(1, code);
pstmt.setString(2, name);
pstmt.setString(3, partner);
// Bind the AIRLINE_INSURANCE_DATA column to an input Ascii stream that
// returns the Ascii data to be inserted into the LONGRAW column
pstmt.setCharacterStream(4, new FileReader(file), (int)file.length());
// Execute the statement
pstmt.execute();
}
}
................
................
Code for retrieving Long Data
public void displayLongData(String code) { |
- java如何访问Oracle的long类型?
- 访问oracle数据库Long类型字段遇到的问题!
- 关于Oracle的LONG类型
- java读取显示/写入oracle long类型
- java中Long类型和long类型的大小比较
- oracle的long类型字段的应用
- oracle的long类型字段的应用
- Oracle的long类型,坑爹的
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- oracle里long类型的总结
- ORACLE中LONG类型字段的存取
- oracle里long类型的总结
- 常见内存问题
- 时间越来越紧了!
- Widows下自旋锁的实现
- SQL Server安全认证知识【2】
- Penetration Testing IPsec VPNs
- java如何访问Oracle的long类型?
- 关于Debug和Release之本质区别的讨论
- 北大2218题
- 汉化英文游戏有什么意义?
- 一个无聊男人的疯狂《数据结构与算法分析-C++描述》学习笔记 用C++/lua/python/bash的四重实现(5)欧几里得算法欧几里得算法求最大公约数
- 说“诡”道“诈”——解读“兵者,诡道也”+——文献综述
- 北大2339题
- 代码--C++全排列和子集的实现
- 访问oracle数据库Long类型字段遇到的问题!