English 中文(简体)
facedate () 通过结果板查询, 丢出当前行无例外
原标题:getdate() query via resultset throwing no current row exception

我有一个问题,我想做的是 得到当前的日期 和一张桌子上的专栏。这是我目前为止的代码:

s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rset = s.executeQuery("select getdate() as date, tglpengiriman from orders");
java.sql.Date date = rset.getDate("date");
java.sql.Date tglkirim = rset.getDate("tglpengiriman"); 

And throwing exception "no current row in ResultSet" in line 3 of my code above. What s wrong with my code? Missunderstanding usage of ResultSet, maybe?

谢谢你的回答...

EDIT: answered. Please see post from @Christopher below. Thanks

最佳回答

您需要在调用任何结果Set. get* 方法前先拨打结果Set. ext 。 请查看对帐单、 结果Set 等的文档。 还要确定在最后一个街区中关闭您的所有资源 。

问题回答

You need to call rset.next() before getting the data from the result set. It is also wise to check that rset.next() returned true.

切换结果组的数据 像这样

while (resultSet.next()) {
java.sql.Date date = rset.getDate("date");
java.sql.Date tglkirim = rset.getDate("tglpengiriman"); 
}

因为结果集的初始位置总是在第一个记录之前, 也就是在第一个记录开始的时候, 此结果Set. next () 将结果设置为指向第一个记录 。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签