0
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.sql.*;" %> 
<%@ page import="java.io.*;" %>>
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Database Page</title>
</head>

<body background="AC.jpg">

<a href="home.jsp"><font color="white"size="3"><b>Back to Home</b></font></a>
<% try
{
String a=request.getParameter("Book_Id"); 
String b=request.getParameter("Book Name");
String c=request.getParameter("Author name");
String d=request.getParameter("Publisher name");
String e=request.getParameter("Department");
String f=request.getParameter("Edition");
String g=request.getParameter("no_of_copy");

Connection con = DriverManager.getConnection("jdbc:odbc:proj","","");
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String query ="select * from BookMaster where Book_Id='" + a + "'";
ResultSet rs=stmt.executeQuery(query);
if(rs.next())
{

response.sendRedirect("BookMasterForm.jsp?result=Book_Id already exists");
}
else
{
rs.updateString("Book_Id",a);
rs.updateString("Book Name",b);
rs.updateString("Author name",c);
rs.updateString("Publisher name",d);
rs.updateString("Department",e);
rs.updateString("Edition",f);
rs.updateString("no_of_copy",g);
rs.insertRow();

response.sendRedirect("BookMasterForm.jsp?result=Succesfully inserted");	
}

rs.close();
stmt.close();
con.close();
}
catch(Exception e)
{ e.printStackTrace();
}

%>


</body>
</html>

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by peter_budo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.