我可以在 ColdFusion 中进行无缓冲查询吗?
我正在将 Java 桌面应用程序移植到 ColdFusion Web 应用程序。该桌面应用程序使用非常大的结果集(数千条文本记录)进行查询,虽然在数据库端没有问题,但如果对其进行缓冲,可能会在客户端占用大量内存。因此,应用程序明确告诉数据库驱动程序不要缓冲太多结果。
现在我正在处理 ColdFusion 端口,我遇到了缓冲问题。 ColdFusion 页面在
调用期间超时,我相当确定这是因为它尝试缓冲所有内容。
我可以在 ColdFusion 中进行无缓冲查询吗?
I'm in the process of porting a Java desktop application to a ColdFusion web app. This desktop app made queries with very large result sets (thousands of text records) that, while being all right on the database side, could take a lot of memory on the client side if they were buffered. For this reason, the app explicitly tells the database driver to not buffer results too much.
Now that I'm working on the ColdFusion port, I'm being hit by the buffering problem. The ColdFusion page times out during the <cfquery>
call, and I'm fairly sure this is because it tries to buffer everything.
Can I make an unbuffered query in ColdFusion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果分页不是一个选项(例如,您正在写一份报告),那么您必须使用 setFetchSize() 获得较低的 java 级别。请参阅此答案。请注意,答案中的代码使用 DataSourceService,该服务带有 Adobe 的最新安全补丁,在 CF8 上不再可用。您必须弄清楚如何通过 adminapi 获取连接或在 Coldfusion 之外创建连接。或者您可以将数据源转换为使用 JNDI,然后您可以自己查找资源,而无需使用 CF api。
If pagination is not an option (i.e., you're writing out a report for example), then you'll have to get low level with the java, using setFetchSize(). See this answer. Note that the code in the answer uses the DataSourceService, which, with latest security patches from Adobe, is no longer available on CF8. You'll have to figure out how to get a connection via the adminapi or create a connection outside of coldfusion. Or you could transition your datasource to use JNDI, and then you can lookup the resource yourself without using CF api's.
我几乎可以肯定 ColdFusion 不提供这样的机制。作为一种语言,它的目的是将开发人员从类似的事情中抽象出来。
我建议您研究几个选项:
上的timeout
属性来防止发生超时CreateObject()
语法实例化 JDBC 数据库连接。使用最后一个选项,您实际上要做的是访问底层 Java 类来执行查询和获取结果。看看这篇文章< /a> 快速查看
CreateObject()
函数。您还可以查看该函数的 Adobe Livedocs ,但它们似乎并没有真正的帮助。
我还没有尝试使用 CreateObject() 来对 Java 数据库访问类进行查询,但我想您可能可以让它工作。
I'm almost certain that ColdFusion does not provide such a mechanism. As a language, it was meant to abstract the developer away from things like that.
I'd suggest that you look into a few options:
timeout
attribute on the<cfquery>
to prevent timeouts from happeningCreateObject()
syntax to instantiate a JDBC database connection.With the last option, what you'd actually do is access the underlying Java classes to do the querying and getting results. Take a look at this article for a quick look at the
CreateObject()
function.You can also look at the Adobe Livedocs for the function, but they don't really seem helpful.
I haven't tried to use
CreateObject()
to do querying with the Java database access classes, but I imagine that you can probably get it to work.