aspose file tools*
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
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).]
 
Consider Paul's rocket mass heater.
 
subject: Connection