No Value Specified for Parameter 1
843842Jan 11 2007 — edited Feb 27 2007Hello All,
I was reading the tutorial " Using Databound Components to Access a Database " on the NetBeans site and made up an example myself to work on.
I have 2 table in PostgreSQL called Student and Courses.
The Student table has 3 fields namely ID, Name, Major
The Courses table has 5 fields namely CousreID, Course1,Course2,Course3, StudentID (Foreign Key from Student table).
The tables just keep record of courses belonging to the students.
I have the following components in Page1.jsp
Dropdown list ( shows the student ID )
Two text boxes to display name and major
Table to display the courses.
The dropdown list is bound to the Student table and the Table is bound to the Courses table with its query modified to
SELECT ALL PUBLIC.courses.cid,
PUBLIC.courses.course1,
PUBLIC.courses.course2,
PUBLIC.courses.course3,
PUBLIC.courses.studentid
FROM PUBLIC.courses
WHERE PUBLIC.courses.studentid = ?
I have the following code in the prerenderer method
public void prerender()
{
if ( cboID.getSelected() == null )
{
try
{
studentDataProvider.cursorFirst();
this.coursesRowSet.setObject (1, studentDataProvider.getValue("ID"));
coursesDataProvider.refresh();
} // end of try block
catch (Exception e)
{
error("Cannot switch to student " +
studentDataProvider.getValue("ID"));
log("Cannot switch to student " +
studentDataProvider.getValue("ID"), e);
} // end of catch block
} // end of if body
} // end of method prerenderer
This block works fine when the page is first accessed. But it throws
" org.postgresql.util.PSQLException: No value specified for parameter 1." in the following method block
public void cboID_processValueChange(ValueChangeEvent event)
{
try
{
this.coursesRowSet.setObject(1, cboID.getSelected());
coursesDataProvider.refresh();
} // end of try block
catch (Exception e)
{
error("Cannot switch to student " + studentDataProvider.getValue("ID"));
log("Cannot switch to person " + studentDataProvider.getValue("ID"), e);
} // end of exception catch block
} // end of processValueChange method
Can any one please help me why the exception is thrown in the above method block.
this.coursesRowSet.setObject(1, cboID.getSelected()); The parameter is specified here.
Waiting for a favorable reply.
Regards.
Hasnain Javed.