troubleshooting Question

jsp error

Avatar of gudii9
gudii9Flag for United States of America asked on
JSPJava EEJava
6 Comments2 Solutions341 ViewsLast Modified:
Hi,

My jso application giving below error


username:admin123
username:admin1
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','01091999','tt','t@t.com','AAA')' at line 1
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)


How to resolve this.
my account.jsp is
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Account Creation Screen</title>
</head>
<body>
	<%@include file="header.jsp" %>
	<div style="width: 300px; margin-left:auto;margin-right:auto;">
		
		<h1>Account Creation Screen</h1>
		<form action="accountCreate.jsp">
			<table>
				<tr>
					<td>			
					Name
					</td>
					<td>
					<input type="text" name="name"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					DOB
					</td>
					<td>
					<input type="text" name="dob" placeholder="Sample Format 1989-01-31"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					Address
					</td>
					<td>
					<textarea type="textarea" name="address" rows=10 style="width:200px; height:100px;"></textarea><br>
					</td>
				</tr>
				
				<tr>
					<td>
					Email ID
					</td>
					<td>
					<input type="textarea" name="email" placeholder="Sample Format test@awesome.com"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					Type of account
					</td>
					<td>
					<select name="accounttype">
					   <option  value="AAA">AAA</option>
					   <option value="BBB">BBB</option>
					   <option value="CCC">CCC</option>
					   <option value="DDD">DDD</option>
					</select> <br>		
					<td>
				</tr>
				<tr>
					<td>
					<input type="submit" value="Create Account">
					</td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>
my accountCreate.jsp is
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="java.sql.DriverManager" %>
<%@page import="java.sql.Connection" %>
<%@page import="java.sql.Statement" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String named = request.getParameter("name");
String dobd = request.getParameter("dob");
String addressd = request.getParameter("address");
String emaild = request.getParameter("email");
String toa = (String)request.getParameter("accounttype");
//out.print(named+dobd+addressd+emaild+toa);
	try{
		Class.forName("com.mysql.jdbc.Driver");
		String username = "root";
		String password = "admin";
		Connection con = DriverManager.getConnection("jdbc:mysql://localhost/banking6",username,password);
		Statement st = con.createStatement();
		int i = st.executeUpdate("insert into account_details (name,ac_holder,dob,address,email,type"+named+"','"+dobd+"','"+addressd+"','"+emaild+"','"+toa+"')");
		out.print("Account Created Succesfully"+"<a href='dashboard.jsp'><button>Homepage</button></a>");

	}
	catch(Exception e){
		out.print("User Account is not created <br>Account failed to create please check formatting date is formatted 1989-01-13"+"<br><a href='account'><button>Go Back</button></a>");
		e.printStackTrace();
	}
%>
</body>
</html>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros