Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get ResultSet without jdbc connection

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am working in one company.my pl told me that i have to write a function
that should return a ResultSet without getting a connection.He told me to write method that will accept a sql string and will return ResultSet but i dont have to use connection or statement object.The method is like that

public ResultSet createResultSet(String sql){
String str="" //should contain ResultSet
............
.............
.............

return str;
}
Value of sql parameter will be passed to this method by some other method.
Now how this is possible
Please help me
Thanks
[ February 07, 2005: Message edited by: gowher amin naik ]
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gowher,

Something is wrong, either you havent understood problem correctly or there is something else.

because without conection resultset is not possible.

In any code if you create a resultset and close the connection then you can't iterate element of resultset.you wil get an exception.

thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gowher,
Welcome to JavaRanch!

I think the person was talking about a disconnected/cached resultset. You still need to get a connection, but you can close it before processing the result. Take a look at this JavaWorld article for more details.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic