JDBC returning empty result set

前端 未结 14 1899
醉话见心
醉话见心 2020-12-15 06:15

I\'m using JDBC for very simple database connectivity.

I have created my connection/statement and executed a query. I check the query object of the statement in the

14条回答
  •  旧时难觅i
    2020-12-15 06:37

    In the past I had similar issues in code such as this:

    querystr = "your sql select query string"
    
    resultset = statement.executeQuery(querystr)
    
    while (resultset.next())
    {
    //do something with the data. 
    //if you do something fairly involved in this block (sequentially, in the same thread)
    //such as calling a function that acts on the data returned from the resultset etc.
    //it causes the resultset fetch to wait long enough for resultset.next() to 
    //unexpectedly return null in the middle of everything
    }
    

    What I did in this situation was to load up all data into a local memory data structure with minimum wait on resultset.next(). Then I did whatever I had to on the data from the local data structure after gracefully closing resultset. This behavior was with Oracle 10 on Unix backend/JDK 1.6.0_22 client under Windows XP.

    Hope this helps.

提交回复
热议问题