• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets connection

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,
I want to connect the database through servlets ...I have made the html pages ... now i donno how do I make the servlets connections...
Please help me out...as I am a beginner and am new to server side ...previously I was working on the client side...
Kajol
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kajol,
All u have to write is a JDBC code in ur servlets......
register the driver
connect to the database
and make the query and get the result set
tell me if u want the full code,
Harpal
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Harpal,
Can u give me some example to do that....
That would be really nice...
Kajol
[This message has been edited by Kajol Shroff (edited June 06, 2001).]
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kajol,
A very good sample from Sun's JDBC tutorial itself, Also try to read this tutorial. It is very good.
http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/getstart/SimpleSelect.doc.html
regds
maha anna
 
Harpal Singh
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kajol,

maha anna has given an excellent link ....I think i need not provide u with an example.....maha at her best......as usual
Harpal
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maha,
The link was really helpfull to me.. and very much to the point ..thanks again...
Harpal thanks to you too...
Kajol
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi kajol,
All u have to do is to write the JDBD code in ur service method of ur servlet.
The code follows:
private Connection con;Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:aadsn","scott","tiger");
Statement stmt=con.createStatement();
ResultSet rs= stmt.executeQuery("select * from tablename");
rs.close();
stmt.close();
con.close();
bye
amit
 
reply
    Bookmark Topic Watch Topic
  • New Topic