<%@ page language="java" import="java.sql.*" %> <% String driver = "org.gjt.mm.mysql.Driver"; Class.forName(driver).newInstance(); Connection con=null; ResultSet rst=null; Statement stmt=null; try{ String url="jdbc:mysql://localhost/books?user=deepak&password=deepak"; con=DriverManager.getConnection(url); stmt=con.createStatement(); }catch(Exception e){ System.out.println(e.getMessage()); } if(request.getParameter("action") != null){ String bookname=request.getParameter("bookname"); String author=request.getParameter("author"); stmt.executeUpdate("insert into books_details(book_name,author) values('"+bookname+"','"+author+"')"); rst=stmt.executeQuery("select * from books_details"); %>

Books List

<% int no=1; while(rst.next()){ %> <% no++; } rst.close(); stmt.close(); con.close(); %>
S.NoBook NameAuthor
<%=no%><%=rst.getString("book_name")%><%=rst.getString("author")%>
<%}else{%> Book Entry FormDocument

Book Entry Form

 
Book Name:
Author:
<%}%>