<
% @ Page ContentType = "text / html" language = "java" import = "java.sql. *, java.io. *"%>
<%
Try {
Class.Forname ("org.gjt.mm.mysql.driver");
// Load the drive.
Connection Connect = DriverManager.getConnection ("JDBC: MySQL: // LocalHost / Database Name", "User Name", "Password");
//establish connection.
PREPAREDSTATEMENT PSTMT = Connect.PrepareStatement ("INSERT INTO Name VALUES (?,?,?,?,,?,?,?)
PSTMT.SetString (1, Request.getParameter ("1st column name));
PSTMT.SetString (2, Request.getParameter ("Lesson 2nd Name));
PSTMT.SetString (3, Request.getParameter ("3rd column name));
PSTMT.STSTRING (4, Request.getParameter ("4th column name));
PSTMT.SetString (5, Request.getParameter ("5th column name));
PSTMT.SETSTRING (6, Request.getParameter ("5th column name");
PSTMT.SetString (7, Request.getParameter ("7th column name));
Pstmt.execute ();
Statement Stmt = connect.createstatement ();
ResultSet RS = Stmt.executeQuery ("SELECT * FROM Name");
While (rs.next ())
{
Out.println (Rs.getstring (1));
Out.println (rs.getstring (2));
Out.println (Rs.getstring (3));
Out.println (rs.getstring (4));
Out.println (Rs.getstring (5));
Out.println (Rs.getstring (6));
Out.println (Rs.getstring (7));
}
CONNECT.CLOSE ();
}
Catch (Exception E)
{
E.PrintStackTrace ();
}
%>
body>
html>