在Java Servlet 中如何获取Oracle中long数据类型的数据

Jking 2001-05-21 09:34:00
各位老师:

我想问在Java Servlet 中如何获取Oracle中long数据类型的数据.

...全文
56 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
skyyoung 2001-05-21
4. Streams: Long columns in JDBC are streamed.


* To set a long (Stream) column
pstmt.setAsciiStream (1, <input-stream>, <input-stream-length>);

If the string data is in Unicode format, then use setUnicodeStream.
pstmt.setUnicodeStream (1, <input-stream>, <input-stream-length>);

For long raw columns, use setBinaryStream
pstmt.setBinaryStream (1, <input-stream>, <input-stream-length>);



create table streamexample (data long)

PreparedStatement pstmt =
conn.prepareStatement ("insert into streamexample values (?)");
InputStream is = new FileInputStream ("notes.txt");
File file = new File ("notes.txt");
pstmt.setAsciiStream (1, is, (int)file.length ());


* To retrieve a long column
ResultSet rset =
stmt.executeQuery ("select * from streamexample");

InputStream ascii_data = rset.getAsciiStream (1);

// Loop, reading from the gif stream and writing to the file
int c;
while ((c = ascii_data.read ()) != -1)
Systemm.out.print(c);

回复
Jking 2001-05-21
用getString()在运行时会产生内存冲突错误,把weblogic服务器停止,可能是数据太多的原因。
回复
emily_wang 2001-05-21
getString().
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-05-21 09:34
社区公告
暂无公告