Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

student registration page

  Asked By: Gin    Date: Sep 04    Category: Java    Views: 3323
  

I am now trying to create a student registration page
with servlet. But I could not figure out the
following:

"When adding a course, the system checks whether the
class is in database already. If yes, the system gives
an error message".
I donot know how to make the system check the
database.
any help is greatly appreciated.
the following is my current servlet:


import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Student extends HttpServlet {
public void doPost (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {

String studentid = req.getParameter("ID");
String coursenumber = req.getParameter("COURSENO");

res.setContentType("text/html");
PrintWriter out=res.getWriter();

Connection con=null;

try {
Class.forName
("oracle.jdbc.driver.OracleDriver");

con = DriverManager.getConnection

("jdbc:oracle:thin:@bonsai.ite.gmu.edu:1521:ite",
"****","****");

con.setAutoCommit(true);

Statement stmt = con.createStatement ();

stmt.executeUpdate("insert into registration values
('"+studentid+"','"+coursenumber+"')");


out.println("Course added! Thanks for using this
system!");

}

catch (Exception e) {
try {
con.rollback();
}

catch (SQLException ignored) {}
out.println("Process failed. Please contact technical
support.");
}

finally {
try {
if(con!=null) con.close();
}
catch (SQLException ignored) {}
}
}
}

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Dennis Hayes     Answered On: Sep 04

we have written an Internationlized Student
Registration System in J2EE you can have a copy of or
software with a very very low price if you want.

 
Answer #2    Answered By: Canan Kaya     Answered On: Sep 04

I think the
1. Class.forName("com.cloudscape.core.JDBCDriver");(not COM) (may be it is incorrect driver class  path or it is not added to your application server class path)

is incorrect.

I suggest you that use the connection  DataSource provided by most application Servers including WebLogic.It supporst ConnectionPooling and using connections by means of JNDI.It gives you beter performance!

 
Didn't find what you were looking for? Find more on student registration page Or get search suggestion and latest updates.




Tagged: