使用 getBinaryStream 读取单元格

发布于 2024-12-08 13:35:07 字数 590 浏览 0 评论 0原文

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

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

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

下面的文本是我的行。

“之所以称为潜在语义索引,是因为它能够关联文本集合中潜在的语义相关术语,它于 20 世纪 80 年代末在贝尔实验室首次应用于文本。该方法也称为潜在语义分析 (LSA) ),揭示了文本正文中单词的使用的潜在语义结构,以及如何使用它来响应用户查询(通常称为概念搜索)来提取文本的含义,或概念搜索,针对一组经过 LSI 的文档,将返回在概念上与搜索条件含义相似的结果,即使结果不与搜索条件共享一个或多个特定单词。”

但我只能读到这一部分

称为潜在语义索引,因为它能够关联语义相关术语

为什么我无法阅读全部内容?

I have a varchar2 typed column1 in my database table .
I read this column from java

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

I do something after this code. But I could not read whole value

Below text is my row.

"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."

But I could read only this part of it

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

Why I could not read whole of it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2024-12-15 13:35:07

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

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

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

Apparently you're not fully reading the InputStream. A common beginner's mistake is assuming that InputStream#available() returns the length of the stream and then only that amount of bytes is been read. This is not correct. You need to read it fully until InputStream#read() method returns -1. See also the Java IO tutorial. Another possible cause is that the text contains newlines and you're using BufferedReader#readLine() to read it and it is been called only once. This is also not correct. You need to call it in a loop until it returns null.

But as it's a varchar field, why don't you just use ResultSet#getString()?

String column1 = r.getString("column1");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文