Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Sanchit/WebContent/AddBook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Add Book</title>
</head>
<body>
<H2> ADD BOOK </H2>

<form action="MainServlet" method="post"><br>
<pre>
ISBN Number : <input type = "text" name="isbn" required><br>
Book Name : <input type = "text" name ="bookname" required><br>
Book Type : <input type = "text" name="booktype" placeholder="G/T " required><br>
Author Code : <input type = "number" name="author" required><br>
Cost : <input type = "number" name="cost" required><br>
<input type="submit" name="operation" value="AddBook"><br>
</pre>
</form>

</body>
</html>
10 changes: 10 additions & 0 deletions Sanchit/WebContent/Failure.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
The operation could not be completed
</body>
</html>
10 changes: 10 additions & 0 deletions Sanchit/WebContent/Invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Sorry You have given invalid data
</body>
</html>
3 changes: 3 additions & 0 deletions Sanchit/WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

12 changes: 12 additions & 0 deletions Sanchit/WebContent/Menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Menu</title>
</head>
<body>
<h1 style ="align:center">Main Menu</h1><br>
<a href ="AddBook.html">Add Book</a><br>
<a href ="ViewBook.html">View Book</a><br>
</body>
</html>
14 changes: 14 additions & 0 deletions Sanchit/WebContent/ViewBook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>View Book</title>
</head>
<body>
<h2> View Book</h2>
<form action="MainServlet" method="post">
ISBN :<input type="text" name ="isbn" required><br>
<input type="submit" name="operation" value="Search">
</form>
</body>
</html>
Binary file added Sanchit/WebContent/WEB-INF/lib/ojdbc14.jar
Binary file not shown.
12 changes: 12 additions & 0 deletions Sanchit/WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>LMS</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions Sanchit/src/com/wipro/book/bean/AuthorBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.wipro.book.bean;

public class AuthorBean {
private int authorCode;
private String authorName;
private long contactNumber;
public int getAuthorCode() {
return authorCode;
}
public void setAuthorCode(int authorCode) {
this.authorCode = authorCode;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public long getContactNumber() {
return contactNumber;
}
public void setContactNumber(long contactNumber) {
this.contactNumber = contactNumber;
}

}
42 changes: 42 additions & 0 deletions Sanchit/src/com/wipro/book/bean/BookBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.wipro.book.bean;

public class BookBean {
private String isbn;
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public AuthorBean getAuthor() {
return author;
}
public void setAuthor(AuthorBean author) {
this.author = author;
}
public char getBookType() {
return bookType;
}
public void setBookType(char bookType) {
this.bookType = bookType;
}
public float getCost() {
return cost;
}
public void setCost(float cost) {
this.cost = cost;
}
private String bookName;
private AuthorBean author;
private char bookType;
private float cost;



}
59 changes: 59 additions & 0 deletions Sanchit/src/com/wipro/book/dao/AuthorDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.wipro.book.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.wipro.book.bean.AuthorBean;
import com.wipro.book.util.DBUtil;

public class AuthorDao {
public AuthorBean getAuthor(int authorCode){
Connection conn = DBUtil.getDBConnection();
PreparedStatement ps;
try {
ps = conn.prepareStatement("select * from author_tbl_me12 where author_code=?");
ps.setInt(1, authorCode);
ResultSet rs = ps.executeQuery();
AuthorBean bean = null;
while(rs.next()){
bean = new AuthorBean();
bean.setAuthorCode(authorCode);
bean.setAuthorName(rs.getString(2));
bean.setContactNumber(rs.getLong(3));
}
return bean;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(NullPointerException e){
System.out.println("error"+authorCode);
}

return null;
}

public AuthorBean getAuthor(String authorName){
Connection conn = DBUtil.getDBConnection();
PreparedStatement ps;
try {
ps = conn.prepareStatement("select * from author_tbl_me12 where author_name=?");
ps.setString(1, authorName);
ResultSet rs = ps.executeQuery();
AuthorBean bean = new AuthorBean();
while(rs.next()){
bean.setAuthorCode(rs.getInt(1));
bean.setAuthorName(rs.getString(2));
bean.setContactNumber(rs.getLong(3));
}
return bean;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return null;
}
}
60 changes: 60 additions & 0 deletions Sanchit/src/com/wipro/book/dao/BookDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.wipro.book.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.wipro.book.bean.BookBean;
import com.wipro.book.util.DBUtil;

public class BookDao {
public BookBean fetchBook(String ISBN){
Connection conn = DBUtil.getDBConnection();
PreparedStatement ps;
try {
ps = conn.prepareStatement("select * from book_tbl_me12 where ISBN=?");
ps.setString(1, ISBN);
ResultSet rs = ps.executeQuery();
BookBean bean =null;
while(rs.next()){
bean = new BookBean();
bean.setIsbn(ISBN);
bean.setBookName(rs.getString(2));
bean.setBookType(rs.getString(3).charAt(0));
bean.setAuthor( new AuthorDao().getAuthor(rs.getInt(4)));
bean.setCost(rs.getFloat(5));
}
return bean;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(NullPointerException e){
System.out.println("error"+ISBN);

}

return null;
}

public int createBook(BookBean book){
Connection conn = DBUtil.getDBConnection();
try {
PreparedStatement ps = conn.prepareStatement("insert into book_tbl_me12 values(?,?,?,?,?)");
ps.setString(1, book.getIsbn());
ps.setString(2, book.getBookName());
ps.setString(3,((Character)book.getBookType()).toString());
ps.setInt(4, book.getAuthor().getAuthorCode());
ps.setFloat(5, book.getCost());
ps.execute();
return 1;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return 0;
}


}

}
26 changes: 26 additions & 0 deletions Sanchit/src/com/wipro/book/service/Administrator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.wipro.book.service;

import com.wipro.book.bean.BookBean;
import com.wipro.book.dao.BookDao;

public class Administrator {
public String addBook(BookBean bean){
if(bean==null||bean.getBookName().equals("")||bean.getIsbn().equals("")||bean.getBookType()!='T'&&bean.getBookType()!='G'||bean.getCost()<=0||bean.getAuthor().getAuthorName()==null||bean.getAuthor().getAuthorName().equals("")){
return "INVALID";
}
int res = new BookDao().createBook(bean);
if(res == 1){
return "SUCCESS";

}
else{
return "FAILURE";
}
}
public BookBean viewBook(String isbn){
if(isbn.equals(""))
return null;
return new BookDao().fetchBook(isbn);
}

}
Loading