You need to check the log files of the tomcat server for any exceptions. The logs are usually located under $CATALINA_HOME/logs
Verify that:
- You have the datasource defined in the Tomcat's context.xml:
$CATALINA_HOME/conf/context.xml
Should contain something like:
<Resource name="jdbc/LiveDataSource"
auth="Container"
type="javax.sql.DataSource"
maxTotal="100"
maxIdle="30"
maxWaitMillis="10000"
username="xxx"
password="yyy"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mydb"/>
- If you run the application inside Eclipse, go to "Java EE" perspective, in "Project explorer" view, under "Servers/Tomcat xxxx" resource you should have
context.xml
file. Check if it also contains the "jdbc/LiveDataSource"
- You should have records parent tables before inserting a raw with foreign keys (like
programme
)
- You have a SQL error at DBServlet line 169: seller should be a escaped with single quotes, e.g.
insertStmt2 += "'seller'" + ",";
not `insertStmt2 += "seller" + ",";
In order to avoid SQL injection, I would suggest to use PreparedStatement instead of constructing the SQL commands inside the servlet. Consider using some ORM like Hibernate, EclipseLink, etc.
UPDATE 1
Location of CATALINA_HOME and CATALINA_BASE can be found from the launch configuration

Redirecting a log file to a custom location: Open launch configuration / Apache Tomcat / Tomcat 8 (or 9) / Commons tab / Output file

UPDATE 2
Check that the $CATALINA_BASE/conf/context.xml
(in my case C:\projects\workspaces\delme\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\context.xml
) contains the jdbc/LiveDataSource
.
Also when you cath exception in servlet code log the stack trace otherwise it won't be visible in the log files e.g.:
try {
// ...some code here...
} catch(Exception e) {
out.println("Problem with the database connection");
e.printStackTrace(); // or better use loggers
// private final Logger logger = Logger.getLogger(getClass().getName());
// logger.log(Level.SEVERE, "Problem with the database connection", e);
}