[英]Is there any way to retrieve the executed query from java ResultSet?
我现在在运行时创建了一个称为public static ResultSet ExecuteSQLQuery(String myQuery)
,我需要从ResultSet中检索执行的查询。
我想知道是否可以从ResultSet中检索执行的查询吗?
简而言之: 不 。
可能可以使用ResultSet中的getStatement
。 一些JDBC驱动程序可能会在语句的toString
方法中公开查询,但是即使是这种情况,也不应该依赖该查询。
如果要以后使用它,则必须保存该查询并将其保留。
您可以创建一种新的ResultSet类型,其中包括查询并返回:
public class ResultSetWithQuery extends ResultSet {
private String query
...
}
public static ResultSetWithQuery ExecuteSQLQuery(String myQuery);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.