when i try to insert a null value in the database.. the
jsp page gives an error that javax.servlet.ServletException: For input
string: ""
even though i have put option as null in sql server for the values 'number' and 'vol_no'. here is the code iam using:
<%@ page language="java" import="java.sql.*,java.io.*" %>
<%
Connection con=null;
java.sql.Statement stmt=null;
String paper_title="";
String authors="";
int type=0;(type is the name of the radio button)
String name="";
int vol_no=0;
int number=0;
int year=0;
String xy=(String)session.getAttribute("y");
if(xy==null)
xy="jyotsana";
paper_title=request.getParameter("paper_title");
authors=request.getParameter("authors");
type=Integer.parseInt(request.getParameter("type"));
name=request.getParameter("name");
vol_no=Integer.parseInt(request.getParameter("vol_no"));
number=Integer.parseInt(request.getParameter("number"));
year=Integer.parseInt(request.getParameter("year"));
System.out.println("the value of paper_title is:"+paper_title);
System.out.println("the value of authors is:"+authors);
System.out.println("the value of type is:"+type);
System.out.println("the value of name is:"+name);
System.out.println("the value of vol_no is:"+vol_no);
System.out.println("the value of number is:"+number);
System.out.println("the value of year is:"+year);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc
dbc:mech_iit");
stmt=con.createStatement();
int i=stmt.executeUpdate("insert into publications(user_login,paper_title,authors,type,name,number,vol_no,year) values('"+xy+"','"+paper_title+"','"+authors+"',"+type+",'"+name+"',"+number+","+vol_no+","+year+")");
stmt.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
where could be the error..
thanks