使用带有null ResultSet的JDBC的临时表 [英] Temporary tables using JDBC with null ResultSet

查看:289
本文介绍了使用带有null ResultSet的JDBC的临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MS SQL驱动程序版本3.0 通过标准 JDBC连接执行存储过程。

I am executing a stored procedure via standard JDBC Connection using MS SQL Driver version 3.0.

我发现当我创建和将数据插入临时表中,存储过程无法正常执行。

I have found that when I create and insert data into a temporary table the stored procedure doesn't execute properly.

Java代码不会抛出异常,而是 javax。 sql.ResultSet 将是 null

The Java code won't throw a exception, but the javax.sql.ResultSet will be null.

存储过程中的失败点是当我取消评论 INSERT INTO #TBL CLM_NAME VALUES('VAL')

The point of failure in the stored procedure is when I un-comment the INSERT INTO #TBL CLM_NAME VALUES('VAL')

当我执行声明使用 SQL Studio管理器,它可以毫不费力地执行,并且数据符合预期。

When I execute the statement using SQL Studio Manager it executes without hassle and the data as expected.

有没有人遇到这个或知道为什么会这样呢?

Has anyone come across this or know why its the case?

最初我认为它是因为SQL驱动程序,我仍然认为它是?

Initially I thought its because of the SQL driver and I still think it is?

谢谢。

推荐答案

也许这将有所帮助


建议如果要使用临时表,则不应调用prepareStatement。您可以直接从语句对象执行查询。

It is recommended that if you want to use temp tables, you should not call "prepareStatement". You can directly execute the query from the statement object.

例如:

String sql = "select uuid, name from Component";

Statement stmt = dbCon.createStatement();
ResultSet rs = stmt.executeQuery(sql);

如果你必须调用prepareStatement,那么你需要创建一个真实的表,如果需要的话,之后删除表格。

If you must call "prepareStatement", then you will need to create a real table and, if needed, delete the table afterwards.

这篇关于使用带有null ResultSet的JDBC的临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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