%@ page language="java" session="true" info=""%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%!
static {
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception e) {
//n = n + "Unable to load the driver
" + e.toString() + "
";
System.err.println("Unable to load the driver.");
e.printStackTrace();
}
}
String delete(ServletRequest req) {
String msg = "wrong parameters - could not delete!";
String id = req.getParameter("regId");
if (id == null ) return msg;
id = id.trim();
if (id.length() < 2) return msg;
try {
Connection conn = DriverManager.getConnection("jdbc:mysql://oberon.ssw.uni-linz.ac.at/test?user=ssw");
String query = "DELETE FROM registration WHERE regid = " + id ;
Statement stat = conn.createStatement();
ResultSet res = stat.executeQuery(query);
conn.close();
msg = "Entry with regid " + id + " deleted";
}
catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
msg = "SQLException: " + e.getMessage() + "
SQLState: " + e.getSQLState() + "
VendorError: " + e.getErrorCode() + "
";
}
catch (Exception e) {
}
return msg;
}
%>
Access denied
<% } %> <%@ include file="footer.jsp" %>