openaccount.jsp 978 Bytes
Newer Older
OscarGonzalez97 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<%@ page import="java.sql.*" language="java"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>


<%!
    Connection con;
	PreparedStatement ps;

	public void jspInit() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "root", "test");
			ps = con.prepareStatement("insert into account value(?,?,?,?)");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void jspDestroy() {
		try {

			ps.close();
			con.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}%>

<%
	int accno = Integer.parseInt(request.getParameter("accno"));
	String lastName = request.getParameter("lastname");
	String firstName = request.getParameter("firstname");
	int bal = Integer.parseInt(request.getParameter("bal"));

	ps.setInt(1, accno);
	ps.setString(2, lastName);
	ps.setString(3, firstName);
	ps.setInt(4, bal);

	ps.executeUpdate();
%>


<%@ include file="openaccount.html" %>