following is the code i wrote for inserting values into the database:
<%@ page language="java" import="java.sql.*,java.io.*" %>
<%
Connection con=null;
java.sql.Statement stmt=null;
String level="";
String project_title="";
String student_names="";
String co_supervisor="";
int year=0;
String xy=(String)session.getAttribute("y");
if(xy==null)
xy="jyotsana";
level=request.getParameter("level");
project_title=request.getParameter("project_title");
student_names=request.getParameter("student_names");
co_supervisor=request.getParameter("co_supervisor");
year=Integer.parseInt(request.getParameter("year"));
System.out.println("the value of level is:"+level);
System.out.println("the value of project_title is:"+project_title);
System.out.println("the value of student_names is:"+student_names);
System.out.println("the value of co_supervisor is:"+co_supervisor);
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();
out.println("insert into project_supervised(user_login,level,project_title,student_names,co_supervisor,year) values('"+xy+"','"+level+"','"+project_title+"',"+student_names+",'"+co_supervisor+"',"+year+")");
int i=stmt.executeUpdate("insert into projects_supervised(user_login,level,project_title,student_names,co_supervisor,year) values('"+xy+"','"+level+"',"+project_title+",'"+student_names+"',"+co_supervisor+","+year+")");
System.out.println("the value of:" +i);
System.out.println("the value of:" +i);
stmt.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
can anyone tell me where does the problem lie
Thanks