Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Steps for Making JDBC connection

  Date: Nov 24    Category: Java    Views: 389
  

This is a very simple Example . it will get you started .. you have to do the rest by
reading books.

Steps for Making JDBC connection :

These steps are quite similar to ASP's . As in ASPs you have to follow the
same routine

/**************************************************************/

1. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

// Here you are telling that what are the kind of drivers that are going to
be used

2. Connection con = DriverManager.getConnection("jdbc:odbc:jobz");

// Here you are telling the DSN name of the DB that will tell the location
of DB .. jobz is the DSN name

3. Statement stmt = con.createStatement();

// Here you are creating an instance of Statement through which you will
execute Queries

4. ResultSet rs = stmt.executeQuery("select * from jobs");

// In ASP's the word recordset is used and in JSP it is ResultSet . Now you
can use methods of resultset to move pointer ahead or back.

Java Gives 2 methods to execute Queries.

Select query ResultSet rs=stmt.executeQuery("query");
now you can move rs by using .. rs.next() method .
Insert / delete / Update int c = stmt.executeUpdate("query");
where c is the number of rows effected

for more details i am sending you a Java Bean that makes connection to a DB
. This can help you explain more . If you have any queries then plz send
them again . I would really appreciate if some of the guyz from this group
will also participate in solving problems .

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Steps for Making JDBC connection Or get search suggestion and latest updates.




Tagged: