How to retieve values from database
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   meena_subramanian
Posted On:   Wednesday, March 28, 2001 09:07 PM

How to retrieve values from a database and display it as a dropdownlist to the user using JSP or Servlets?

Re: How to retieve values from database

Posted By:   Narendra_Yalavarthi  
Posted On:   Thursday, March 29, 2001 08:33 AM

HI


/**
* copy this code either in JSP or in
* servlet this pice of code is for JSP
* make sure that u have proper driver.
**/
<%
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con;

con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
System.out.println(con);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from Emp");

/**
* to display the results in list box
* i haven't compiled and tested this
* code u can get some errors here,but * this is one of the way to do.
**/

while rs.next(){
for (i=0; i< rs.getFetchSize(); i++;){
out.println("