資料怎麼插不進去(資料庫)?

angelia發表於2006-08-04
程式碼:
<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.sql.*"%>
<%!
public String CodeToString(String str)
{
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}
%>

<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@210.43.2.209:1521:oemrep","system","admin");

PreparedStatement pstmt = conn.prepareStatement("insert into faculty values(?,?,?,?,?)");
int FacultyID=Integer.parseInt((String)request.getParameter("FacultyID")) ;
String Name = (String)request.getParameter("Name") ;
int RoomID=Integer.parseInt((String)request.getParameter("RoomID")) ;
String Phone = (String)request.getParameter("Phone") ;
int DepID=Integer.parseInt((String)request.getParameter("DepID")) ;
pstmt.setInt(1,FacultyID);
pstmt.setString(2,"Name");
pstmt.setInt(3,RoomID);
pstmt.setString(4,"Phone");
pstmt.setInt(5,DepID);
pstmt.executeUpdate();
pstmt.close();
conn.close();
}
catch(Exception e)
{
//System.out.println(request.getParameter("RoomID"));
System.out.println(e);
}
%>
<head>
<title>資料插入</title>
</head>
<body>
<center>
<table border="1" width="700">
<tr>
<td height="24"><div align="center">資料插入程式</div></td>
</tr>
<tr>
<td height="24">資料插入成功!</td>
</tr>
</table>
</center>
</html>

出現的錯誤:
在頁面輸入字母出現: java.lang.NumberFormatException: For in put String: ""
輸入數字:java.sql.SQLException: ORA-017222: 無效數字

相關文章