how to fetch data from database using prepared statement

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@ page import="java.util.*" %>
<%@page import="java.sql.*"%>
<!DOCTYPE html>
<html lang="en">
<body>

<%@ include file="orgoSidebarAdd.jsp" %>
<div class="col-md-9">



 <%


 Class.forName("com.mysql.jdbc.Driver");
 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/inventory","root","root");
 PreparedStatement ps=conn.prepareStatement("select * from region") ;
 ResultSet rs = ps.executeQuery();

%>

<form class="form-horizontal" role="form" action="OrganizationInsert.jsp">



<div class="form-group">
      <span class="control-label col-sm-4" for="AsSetComponent">Site Name</span>
      <div class="col-sm-5">
        <input type="text" class="form-control" id="AsSetComponent" name="sName" placeholder="Enter Site name">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="Site">Site Description</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="desc" placeholder="Site Description">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="Site">Site Region</span>
      <div class="col-sm-5">
        <div class="dropdown">
  <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
 
  <%  while(rs.next()){ %>
            <li><%= rs.getString(1)%></li>
        <% } %>
 
  </ul>
</div>



</div>
       
 </div>

<div class="form-group">
      <span class="control-label col-sm-4" for="Software">Address:</span>
      <div class="col-sm-5">
        <textarea class="form-control" row="5" name="addr" placeholder="Enter Address">
      </textarea>
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="City">City</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="City" placeholder="Enter Organization City">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="pCode">postal Code</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="pCode" placeholder="Enter Postal Code">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="State">State</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="State" placeholder="Enter State ">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="Country">Country</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="Country" placeholder="Enter Country ">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="eId">Email Id</span>
      <div class="col-sm-5">
        <input type="email" class="form-control"  name="eId" placeholder="Enter Email Id ">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="pNo">Phone No</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="pNo" placeholder="Enter Phone Number ">
      </div>
</div>

<div class="form-group">
      <span class="control-label col-sm-4" for="wUrl">Web url</span>
      <div class="col-sm-5">
        <input type="text" class="form-control"  name="wUrl" placeholder="Enter web url ">
      </div>
</div>

    <div class="form-group">      
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" class="btn btn-success btn-lg">Submit</button>
      </div>
    </div>
  </form>
</div>
</name>


Post a Comment

0 Comments

Recent in Recipes

3/Food/post-list