开发者

How does createStatement/executeQuery/next work?

Given the following example (supposed to be correct JDBC, but I'm noob):

Connection conn = getConnection();
Statement st = conn.createStatement();

ResultSet rs = st.executeQuery("SELECT NAME FROM USERS");
while(rs.next())
{
     string name = rs.getString("NAME");
     //...
}

At what point is NAME information transferred from the database to the progra开发者_开发问答m? Is this each time that getString is called? If so, is it also possible to collect the names for all users in one I/O operation?


It may be that I misunderstand the question, but answering based on what I think you're asking:

All information is fetched from the database when you execute

ResultSet rs = st.executeQuery("SELECT NAME FROM USERS");

All operations performed on rs after that will take place in program memory, and not on the database.

I'm not sure what you mean about if it's possible to collect the names for all users in one I/O operation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜