Showing posts with label Database Access with JSP. Show all posts
Showing posts with label Database Access with JSP. Show all posts

Sunday, February 5, 2023

Database Access with JSP

 

LAB- 2

Database Access with JSP



//addbook.html

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

      <form action="registerbook.jsp" method="post">

            <table>

                  <tr>

                        <td>ISBN</td>

                        <td><input type="text" name="isbn"></td>

                  </tr>

                  <tr>

                        <td>name</td>

                        <td><input type="text" name="name"></td>

                  </tr>

                  <tr>

                        <td>price</td>

                        <td><input type="text" name="price"></td>

                  </tr>

                  <tr>

                        <td>author</td>

                        <td><input type="text" name="author"></td>

                  </tr>

                  <tr>

                        <td>Submit</td>

                        <td><input type="submit" value="addBook"></td>

                  </tr>

            </table>

      </form>

</body>

</html>

// registerbook.jsp

 

<html>

<body>

<%

String i = request.getParameter("isbn");

String n = request.getParameter("name");

String p = request.getParameter("price");

String a = request.getParameter("author");

%>

 

<h2> 

 

<%@ page import = "java.sql.*" %>

<%

//out.println(n);

 

 String dburl = "jdbc:mysql://localhost:3306/demodb";

 String dbuname = "root";

 String dbpassword = "";

 String dbdriver = "com.mysql.jdbc.Driver";

 

 Class.forName(dbdriver);

 

 Connection con = DriverManager.getConnection(dburl, dbuname, dbpassword);

 

Statement stmt =  con.createStatement();

String sql = "insert into book values ('"+i+"','"+n+"','"+p+"','"+a+"')";

 

stmt.executeUpdate(sql);

out.println("Book added success");

 

%>

</h2>

</body>

</html>


 

CORBA Java Tutorial using Netbeans and Java 8.

CORBA-Example A simple CORBA implementation using Java Echo.idl module EchoApp{ interface Echo{ string echoString(); }; }; ...