我有这两页,在我将数据输入表单并提交后,它写道:
Založení letadla
java.lang.NullPointerException
这个问题我能做些什么......因为可以用谷歌搜索的用户编写的手册对我没有帮助:(
管理员.jsp:
<html>
<head>
</head>
<body>
<form method="post" action="vlozit.jsp">
<p>Založit Letadlo</p><br>
<table>
<tr><td>ID:</td> <td><input type="text" name="id"></td></tr>
<tr><td>Model letadla:</td><td><input type="text" name="model"></td></tr>
<tr><td>Počet sedadel:</td><td><input type="text" name="sedadel"></td></tr>
</table>
<input type="submit" value="Založit letadlo">
</form>
</body>
和 vlozit.php
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<HTML>
<HEAD>
<TITLE>Administrace</TITLE>
</HEAD>
<BODY>
<H1>Založení letadla</H1>
<%
String ID= request.getParameter("id");
String model = request.getParameter("model");
String sedadel = request.getParameter("sedadel");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:ATBS", "CENTOS", "Shaman123");
if(conn != null){
Statement statement = conn.createStatement();
String command = "INSERT INTO letadlo (ID, model, sedadel) VALUES ('"+ID+"', '"+model+"', '"+sedadel+"')";
PreparedStatement ps = conn.prepareStatement(command);
if(ps != null){
ps.execute();}}
conn.close();
}
catch(Exception e)
{
out.println(e);
}
%>
</BODY>