Close
jGuru Forums
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
/*** 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(""+" ");}} con.close(); }catch(Exception e) { out.println(" exception occurred");}%>
Posted By: John_Zukowski Posted On: Wednesday, March 28, 2001 09:51 PM