数据怎么插不进去(数据库)?
代码:
<%@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: 无效数字