Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection

 
Panday Manako
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic