在Railo中如何将Java结果集转换为ColdFusion查询? [英] How does one convert from a Java resultset to ColdFusion query in Railo?

查看:204
本文介绍了在Railo中如何将Java结果集转换为ColdFusion查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下在CFMX 7和CF8中工作正常,我也假设CF9:

The following works fine in CFMX 7 and CF8, and I'd assume CF9 as well:

<!--- 'conn' is a JDBC connection --->
<cfset stat = conn.createStatement() />
<cfset rs = stat.executeQuery(trim(arguments.sql)) />

<!--- convert this Java resultset to a CF query recordset --->
<cfset queryTable = CreateObject("java", "coldfusion.sql.QueryTable")>
<cfset queryTable.init(rs) >
<cfset query = queryTable.FirstTable() />

这将使用JDBC驱动程序创建语句,对其执行查询, ,然后coldfusion.sql.QueryTable被实例化,传递Java resulset对象,然后queryTable.FirstTable()被调用,它返回一个实际的coldfusion resultset(cfloop等)。

This creates a statement using a JDBC driver, executes a query against it, putting it into a java resultset, and then coldfusion.sql.QueryTable is instantiated, passed the Java resulset object, and then queryTable.FirstTable() is called, which returns an actual coldfusion resultset (for cfloop and the like).

问题出现在Railo的实现中有所不同。在Railo中运行此代码会返回以下错误:没有找到与coldfusion.sql.QueryTable(org.sqlite.RS)匹配的构造函数。

The problem comes with a difference in Railo's implementation. Running this code in Railo returns the following error: No matching Constructor for coldfusion.sql.QueryTable(org.sqlite.RS) found.

我转储了Railo java对象,并且在方法中没有看到init()。我缺少一些简单的东西吗?我很想在Railo中工作。

I've dumped the Railo java object, and don't see init() among the methods. Am I missing something simple? I'd love to get this working in Railo as well.

请注意:我正在做一个无DSN连接到SQLite数据库。我理解如何设置CF数据源。我现在唯一的打嗝是从Java结果集到Railo查询的翻译。

Please note: I am doing a DSN-less connection to a SQLite db. I understand how to set up a CF datasource. My only hiccup at this point is doing the translation from a Java result set to a Railo query.

推荐答案

查看Railo源代码,我看到 railo.runtime.type.QueryImpl 可能符合您的需要。它实现 railo.runtime.type.Query 并在其构造函数中接受一个ResultSet,但它似乎不实现 QueryTable

Looking at the Railo source code, I see that railo.runtime.type.QueryImpl might fit your needs. It implements railo.runtime.type.Query and accepts a ResultSet in its constructor, but it does not seem to implement QueryTable.

如果这是正确的类,您将需要传入一个ResultSet和一个字符串作为查询名称,因为它没有一个构造函数采用ResultSet。

If that's the right class, you'll want to pass in a ResultSet and a string for the query name, as it doesn't have a constructor that only takes a ResultSet.

这篇关于在Railo中如何将Java结果集转换为ColdFusion查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆