This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection" Watch "Connection" New topic
Author

Connection

Panday Manako
Ranch Hand

Joined: Mar 29, 2001
Posts: 80
I'm very new to jdbc. I hope you can help.
How can I automatically connect to the database when my program somehow got disconnected from it. What if I'm already accessing for example the 4th row then I got disconnected. How could I go back to where I got disconnected? Can you please show it by editing my codes below.
Thank you in advance.
panday
<PRE>
import java.sql.* ;
class DbBroker
{
static Connection c = null ;
static Statement s = null ;
static String dbUrl = "jdbc dbc:Books" ;
static ResultSet rs = null ;

static void connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c = DriverManager.getConnection( dbUrl,"","" );
}
catch( Exception e )
{
e.printStackTrace();
}
}

public static void main( String args[] )
{
try
{
connect();
s = c.createStatement();
rs = s.executeQuery("Select FirstName from TitleAuthor");


while ( rs.next() )
{
System.out.println( rs.getString(1) );
}
}
catch( Exception e )
{

}

}
}
</PRE>
[This message has been edited by Panday Manako (edited July 07, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection
 
Similar Threads
Right usage of static modifier ?
using data base Access
Hi,I have a problem in database connection
using and passing a multidimensional array to jsp
how to connect to mysql database ?