I think there is a problem when loading your
JDBC driver:
1. try to print out the stack trace in init() method:
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql:///test", "root","Varshini@9");
pstmt = con.prepareStatement("INSERT INTO reg VALUES(?,?,?,?)");
} catch (Exception e) {
e.printStackTrace(System.err); //add this line and run again
}
2. if you want to insert records into your database,
you need to invoke the executeUpdate() method of
the PreparedStatement object, so...
pstmt.setInt(1, regid);
pstmt.setString(2, name);
pstmt.setString(3, email);
pstmt.setString(4, mobile);
pstmt.executeUpdate(); //add this line
Please add the line number when you post stack trace again.