Guys i got file enroll.jsp while executing that i got java.lang.NullPointerException. So please solve this,
my code as follows
Code:
//enroll.jsp//
<%@ page import="INCLUDES.DBConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<
jsp:useBean id="DB" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB" property="*"/>
<jsp:useBean id="DB1" scope="page" class="INCLUDES.DBConnection"/>
<jsp:setProperty name="DB1" property="*"/>
<%
int course_id=Integer.parseInt(request.getParameter("course_id"));
int no_of_papers=0;
String statement="";
try
{
statement="select no_of_papers from x_masterListOfCourses where course_id=" + course_id;
DB1.setStatement(statement);
ResultSet objRs=(ResultSet)DB1.result();
if(objRs.next())
{
no_of_papers=objRs.getInt("no_of_papers");
}
}
catch(Exception e)
{
out.print("error occured while executing the query:" + e);
}
try
{
String user_name=(String)session.getAttribute("user_name");
java.util.Date now=new java.util.Date();
java.sql.Date date=new java.sql.Date(now.getYear(),now.getMonth(),now.getDate());
String trainee_id="OL_" + course_id + "_" + user_name;
statement="select * from x_master_trainee_detail_online";
DB.setStatement(statement);
ResultSet objRsInsert=(ResultSet)DB.resultUpdate();
objRsInsert.next();
objRsInsert.updateString("trainee_id",trainee_id);
session.setAttribute("trainee_id",trainee_id);
objRsInsert.updateString("user_name",user_name);
objRsInsert.updateInt("is_registered",1);
objRsInsert.updateInt("is_paper1_tutorial_viewed",0);
objRsInsert.updateInt("is_paper2_tutorial_viewed",0);
objRsInsert.updateInt("is_paper3_tutorial_viewed",0);
objRsInsert.updateInt("is_paper4_tutorial_viewed",0);
objRsInsert.updateInt("is_paper5_tutorial_viewed",0);
objRsInsert.updateInt("is_attended_exam",0);
objRsInsert.updateInt("course_id",course_id);
objRsInsert.updateInt("paper1_no_of_attempts",0);
objRsInsert.updateInt("paper2_no_of_attempts",0);
objRsInsert.updateInt("paper3_no_of_attempts",0);
objRsInsert.updateInt("paper4_no_of_attempts",0);
objRsInsert.updateInt("paper5_no_of_attempts",0);
objRsInsert.updateInt("is_paper1_completed",0);
objRsInsert.updateInt("is_paper2_completed",0);
objRsInsert.updateInt("is_paper3_completed",0);
objRsInsert.updateInt("is_paper4_completed",0);
objRsInsert.updateInt("is_paper5_completed",0);
objRsInsert.updateInt("paper1_marks",0);
objRsInsert.updateInt("paper2_marks",0);
objRsInsert.updateInt("paper3_marks",0);
objRsInsert.updateInt("paper4_marks",0);
objRsInsert.updateInt("paper5_marks",0);
objRsInsert.updateDate("doe",date);
objRsInsert.updateInt("no_of_papers",no_of_papers);
objRsInsert.insertRow();
response.sendRedirect("course_step.jsp?result=Enrolled successfully.&course_id=" + course_id);
}
catch(Exception e)
{
out.print("error occured while inserting: " + e);
}
%>
sql table is as follows
Code:
-- phpMyAdmin SQL Dump
-- version 2.6.0-rc1
--
http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 24, 2010 at 02:30 AM
-- Server version: 4.0.20
-- PHP Version: 5.0.1
--
-- Database: `elearning_datasource`
--
-- --------------------------------------------------------
--
-- Table structure for table `x_master_trainee_detail_online`
--
CREATE TABLE `x_master_trainee_detail_online` (
`trainee_id` varchar(25) NOT NULL default '',
`is_registered` int(10) NOT NULL default '0',
`is_attended_exam` int(10) NOT NULL default '0',
`is_successfully_completed` int(10) NOT NULL default '0',
`course_completed_date` date NOT NULL default '0000-00-00',
`total_marks` int(10) NOT NULL default '0',
`doe` date NOT NULL default '0000-00-00',
`user_name` varchar(25) NOT NULL default '',
`course_id` int(10) NOT NULL default '0',
`paper1_no_of_attempts` int(10) NOT NULL default '0',
`paper2_no_of_attempts` int(10) NOT NULL default '0',
`paper3_no_of_attempts` int(10) NOT NULL default '0',
`paper4_no_of_attempts` int(10) NOT NULL default '0',
`paper5_no_of_attempts` int(10) NOT NULL default '0',
`paper1_marks` int(10) NOT NULL default '0',
`paper2_marks` int(10) NOT NULL default '0',
`paper3_marks` int(10) NOT NULL default '0',
`paper4_marks` int(10) NOT NULL default '0',
`paper5_marks` int(10) NOT NULL default '0',
`paper1_completed_date` date NOT NULL default '0000-00-00',
`paper2_completed_date` date NOT NULL default '0000-00-00',
`paper3_completed_date` date NOT NULL default '0000-00-00',
`paper4_completed_date` date NOT NULL default '0000-00-00',
`paper5_completed_date` date NOT NULL default '0000-00-00',
`paper_id1` int(10) NOT NULL default '0',
`paper_id2` int(10) NOT NULL default '0',
`paper_id3` int(10) NOT NULL default '0',
`paper_id4` int(10) NOT NULL default '0',
`paper_id5` int(10) NOT NULL default '0',
`is_paper1_completed` int(10) NOT NULL default '0',
`is_paper2_completed` int(10) NOT NULL default '0',
`is_paper3_completed` int(10) NOT NULL default '0',
`is_paper4_completed` int(10) NOT NULL default '0',
`is_paper5_completed` int(10) NOT NULL default '0',
`paper1_appeared_on` date NOT NULL default '0000-00-00',
`paper2_appeared_on` date NOT NULL default '0000-00-00',
`paper3_appeared_on` date NOT NULL default '0000-00-00',
`paper4_appeared_on` date NOT NULL default '0000-00-00',
`paper5_appeared_on` date NOT NULL default '0000-00-00',
`is_paper1_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper2_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper3_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper4_tutorial_viewed` int(10) NOT NULL default '0',
`is_paper5_tutorial_viewed` int(10) NOT NULL default '0',
`no_of_papers` int(10) NOT NULL default '0',
PRIMARY KEY (`trainee_id`)
) TYPE=MyISAM;
--
-- Dumping data for table `x_master_trainee_detail_online`
--
Can you tell me what is that error. Any kind of help will be appreciated. thanks