• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Connection pooling & rs.next()

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
And then the flying monkeys attacked. My only defense was this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic