シンプルな JSP コードを使用して、5 つのフィールドを oracle 10g データベースに挿入しました。フォームを送信すると、「jdbc.odbc.JdbcOdbcDriver」という例外が発生します。何が問題なのか理解できません。私を助けてください。私のコードは次のとおりです。
signup.html
<html>
<head><title>Sign up</title>
<link rel="stylesheet" type="text/css" href="default.css">
<link rel="stylesheet" type="text/css" href="align.css">
<script language="javascript">
function validation(Form_obj)
{
if(Form_obj.fnametxt.value.length==0)
{
alert("Please, fill up the first name!!!");
Form_obj.fnametxt.focus();
return false;
}
if(Form_obj.lnametxt.value.length==0)
{
alert("Please, fill up the last name!!!");
Form_obj.lnametxt.focus();
return false;
}
if(Form_obj.usrnametxt.value.length==0)
{
alert("Please, fill up the user name!!!");
Form_obj.usrnametxt.focus();
return false;
}
if(Form_obj.pswdtxt.value.length==0)
{
alert("Please, fill up the password name!!!");
Form_obj.pswdtxt.focus();
return false;
}
if(Form_obj.phonetxt.value.length==0)
{
alert("Please, fill up the phone number!!!");
Form_obj.phonetxt.focus();
return false;
}
return true;
}
</script>
</head>
<a href="index.html"><h1>Jobs Portal</h1></a>
<div id="sign">Sign up</div>
<center>
<form id="form" action="signup.jsp" method="post" name="signform" onSubmit="return validation(this)">
<table border="3" cellpadding="0" cellspacing="0">
<tr><td>
<table>
<tr><td colspan="2" align="center">Fill your details</td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td>First Name</td><td><input type="text" name="fnametxt"></td></tr>
<tr><td>Last Name</td><td><input type="text" name="lnametxt"></td></tr>
<tr><td>User Name</td><td><input type="text" name="usrnametxt"></td></tr>
<tr><td>Password</td><td><input type="password" name="pswdtxt"></td></tr>
<tr><td>Mobile no.</td><td><input type="text" name="phonetxt"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="signbt" value="Sign up" > </td></tr>
</td></tr>
</table>
</form>
</center>
</html>
signup.jsp
<%@page language="java" import="java.sql.*"%>
<%@page import="java.io.*"%>
<%
try
{
ResultSet rs=null;
Class.forName("jdbc.odbc.JdbcOdbcDriver");
Connection con= DriverManager.getConnection("jdbc:oracle:jobsportal","abdus","jbaat");
Statement stmt=con.createStatement();
String fname=request.getParameter("fnametxt");
String lname=request.getParameter("lnametxt");
String usrname=request.getParameter("usrnametxt");
String pswd=request.getParameter("pswdtxt");
String phone=request.getParameter("phonetxt");
stmt.executeUpdate("insert into jobs(fname,lname,username,password,phone) values('"+fname+"','"+lname+"','"+usrname+"','"+pswd+"','"+phone+"'");
rs=stmt.executeQuery("select * from jobs");
%>
<html>
<head><title>Sign up Successful</title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
Your details</br>
<table border="0">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>Password</th>
<th>Phone number</th>
</tr>
<%
while(rs.next())
{
%>
<tr>
<td><%=rs.getString("fname")%></td>
<td><%=rs.getString("lname")%></td>
<td><%=rs.getString("username")%></td>
<td><%=rs.getString("password")%></td>
<td><%=rs.getString("phone")%></td>
</tr>
<% rs.close();
}}
catch(ClassNotFoundException e)
{
out.println(e.getMessage());
} %>
</table>
</html>