我正在创建一个框,其中我发布job title
以及job description
,它将上传到数据库,但我不知道我哪里出错了.....
正如我提交的那样说:
HTTP Status 500 - An exception occurred processing JSP page /submit_job_forum.jsp at line 11
这是我的forum.jsp
<div id="forum2">
<h1 style="text-align: center;">Want to post on going walking,<br>Post your job description here.</h1>
<form id="forum2_form" method="post" action="submit_job_forum.jsp">
<p>
<label>Job title:</label>
<input type="text" class="" placeholder="e.g XXX Referral program for freshers." name="job_title"/>
</p>
<p>
<label>Description:</label>
<textarea class="question_ask_style" rows="3" cols="40" placeholder="Type description here.." name="job_description"></textarea>
</p>
<div id="submit_btn">
<input type="submit" value="Submit Question" />
</div>
</form>
</div>
这是我的submit_job_forum.jsp
<%@ page import="java.sql.*" %>
<%
String job_title=request.getParameter("job_title");
String job_description=request.getParameter("job_description");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:8888/login", "root", "1234");
Statement st=con.createStatement();
ResultSet rs;
rs=st.executeQuery("insert into job_post('id', 'job_title', 'job_description') VALUES (' ', '"+job_title+"', '"+job_description+"')");
response.sendRedirect("forum.jsp");
%>
这里我创建了这个表到数据库:
create table `job_post`(
`id` int(100) unsigned NOT NULL auto_increment,
`job_title` varchar(100) NOT NULL,
`job_description` varchar(1000) NOT NULL,
PRIMARY KEY(`id`)
)ENGINE= InnoDB default charset=latin1;
请帮助:(
答案 0 :(得分:1)
注意列名称周围的撇号,你应该使用这个字符(`)或者只是省略它(只要你避免使用保留字)。 虽然对于价值观而言,它很好。
rs=st.executeQuery("insert into job_post(`id`, `job_title`, `job_description`)
VALUES (' ', '"+job_title+"', '"+job_description+"')");