• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection pooling & rs.next()

 
Nimish Patel
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Have a good day...

we use rs.next() in jdbc code.
here rs is the refrence of resultset. here Resultset is an interface.

so where actually next() method is implemented. because Resultset is an interface, so no method implementation in it.
and how can we directly write rs.next() ?

and How can I create connection pooling ?
How to use connection store in connection pooling ?

please help me,
Thanks in anticipation.

rgds,
Nimish
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your first question:

and how can we directly write rs.next()

You've seen the code like Class.forName("name.of.Driver"); at the start of JDBC code? There is a bit of a trick here. This causes the Driver class to be loaded, and when it loads it registers itself with the DriverManager.

When you call DriverManager.getConnection(jdbcURL), the DriverManager asks each of the registered Drivers (there can be many) who understands the string. If you set things up correctly, your Driver says "I do!", and then returns a Connection.

What you get passed is a Connection (ie an interface), but the implementing Class gets decided by the DriverManager and Driver working together. The Connection decides which Statement to pass to you, and the Statement gives you a ResultSet. They are all interfaces, but under the covers there are concrete implementations starting with the Driver.

As to your second question:

How can I create connection pooling ?
Don't. Download an existing implementation. Connection Pooling is easy to do badly and hard to do well. There are free versions out there, so just use them.
How to use connection store in connection pooling ?
It's all in the configuration. Rather than including the JDBC settings in code, you usually put the Connection Pool setup info in a config file and it just works. Rather than talking to the DriverManager to get Connections, you get them from the Connection Pool instead.

Finally,
It is better to ask separate questions in separate threads, then we can cover them in their individual merits.

Hope this helps,
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic