This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connection pooling & rs.next() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Connection pooling & rs.next()" Watch "Connection pooling & rs.next()" New topic
Author

Connection pooling & rs.next()

Nimish Patel
Ranch Hand

Joined: Jun 29, 2005
Posts: 84
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

Joined: Mar 06, 2001
Posts: 13459

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection pooling & rs.next()
 
Similar Threads
Interfaces v/s Imports.
What is Connection Pooling? And how to use It
JDBC Connections Freezing with Multiple Users Accessing DB
JDBC
DriverManager class and JNDI