There's a error when I run this jsp file --> " pstmt.executeUpdate();".
"org.apache.jasper.JasperException: An exception occurred processing JSP page /TestAdd.jsp at line 39"
My code essentially have a text box for users to enter a value, and then the value is sent to the MySQL database.
Any help is appreciated ~
<body>
<FORM action="Testadd.jsp" method="post">
<table border="1">
<tr>
<td>Size</td>
<td><input type='text' size=15 name='Size'></td>
</tr>
<td><input type='submit' name='btnSubmit' value='Submit'></td>
</table>
</FORM>
<%
//Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//Define Connection URL
String connURL = "jdbc:mysql://localhost/test?user=root&password=aap";
//Establish connection to URL
Connection conn = DriverManager.getConnection(connURL);
// Create Connection object conn
//Statement stmt = conn.createStatement();
String getsize = request.getParameter("Size");
PreparedStatement pstmt;
pstmt = conn.prepareStatement("INSERT INTO test_db (size) VALUES (?)");
pstmt.setString(1,getsize);
pstmt.executeUpdate();
%>
</body>