Hey, I've come across an error in my school project. I'm creating a college registration web app. The jsp displays a list of available classes with checkboxes to check the ones you would like to register for. I've been running it in debug mode and it throws an exception at the executeUpdate() method. I'm not sure what could be wrong. Its getting the proper values as far as the StudentID, ClassID, and Payment variables. I'm not sure what I should put up as far as my go goes but here is where the error is occuring.
package data;
import java.sql.*;
import business.Schedule;
public class RegisterClasses
{
public static Schedule register(String id, String[] regClasses)
{
Schedule schedule = RetrieveClassesDAO.getClasses(regClasses);
Connection connection = ConnectionManager.getConnection();
PreparedStatement statement = null;
String query = "INSERT INTO registeredcourses(ClassID, StudentID, Payment) VALUES(?, ?, ?)";
try
{
statement = connection.prepareStatement(query);
for(int i = 0; i < regClasses.length; i++)
{
statement.setString(1, regClasses[i]);
statement.setString(2, id);
statement.setString(3, "0");
int e = statement.executeUpdate();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
return schedule;
}
}