aspose file tools*
The moose likes Servlets and the fly likes Servlets connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets connection" Watch "Servlets connection" New topic
Author

Servlets connection

Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
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
Harpal Singh
Ranch Hand

Joined: Oct 10, 2000
Posts: 229
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

Joined: Dec 04, 2000
Posts: 160
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).]
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
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

Joined: Oct 10, 2000
Posts: 229
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

Joined: Dec 04, 2000
Posts: 160
Thanks Maha,
The link was really helpfull to me.. and very much to the point ..thanks again...
Harpal thanks to you too...
Kajol
Rinku Sharma
Greenhorn

Joined: Mar 30, 2001
Posts: 18
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
 
Don't get me started about those stupid light bulbs.
 
subject: Servlets connection