gpt4 book ai didi

java - 使用 getBinaryStream 读取单元格

转载 作者:行者123 更新时间:2023-12-01 15:43:09 24 4
gpt4 key购买 nike

我的数据库表中有一个 varchar2 类型的 column1 。我从 java 读到了这个专栏

 java.sql.ResultSet r = s.executeQuery("Select * from table1");
InputStream is = r.getBinaryStream("column1");

我在这段代码之后做了一些事情。但我无法读取整个值

下面的文字是我的行。

"Called Latent Semantic Indexing because of its ability to correlate semantically related terms that are latent in a collection of text, it was first applied to text at Bell Laboratories in the late 1980s. The method, also called latent semantic analysis (LSA), uncovers the underlying latent semantic structure in the usage of words in a body of text and how it can be used to extract the meaning of the text in response to user queries, commonly referred to as concept searches. Queries, or concept searches, against a set of documents that have undergone LSI will return results that are conceptually similar in meaning to the search criteria even if the results don’t share a specific word or words with the search criteria."

但是我只能读到这一部分

Called Latent Semantic Indexing because of its ability to correlate semantically related terms

为什么我无法阅读全文?

最佳答案

显然您没有完全阅读 InputStream 。初学者常见的一个错误是假设 InputStream#available()返回流的长度,然后仅读取该数量的字节。这是不正确的。您需要完整阅读它,直到 InputStream#read()方法返回-1。另请参阅Java IO tutorial 。另一个可能的原因是文本包含换行符并且您正在使用 BufferedReader#readLine()读取它并且只被调用一次。这也是不正确的。您需要循环调用它,直到返回null

但由于它是一个 varchar 字段,为什么不直接使用 ResultSet#getString()

String column1 = r.getString("column1");

关于java - 使用 getBinaryStream 读取单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7662117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com