I’m working out of Murach’s Java servlets and JSP, chapter 14 on connecting to MySQL, which I am not able to do. I’m using Netbeans and Tomcat. If I try to run the code with the following context.xml file then the code won’t run. It says
[Fatal Error] :3:2: The markup in the document following the root element must
be well-formed.
/Users/user/NetBeansProjects/LearnYou/nbproject/build-impl.xml:724:3
Deployment error: Tomcat configuration file /Users/user/NetBeansProjects/LearnYou/web/META-INF/context.xml seems to be broken. Please make sure it is parseable and valid.
If I comment out all but the first line then the code runs but never connects to MySQL.
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/projectname"/>
<Resource
name="jdbc/ULearniversity" auth="Container"
maxActive="100" maxIdle="50" maxWait="60000"
username="uName" password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/MyDataBase?autoReconnect=true"
logAbandoned="true" removeAbandoned="true"
removeAbandonedTimeout="60" type="javax.sql.DataSource"
/>
</Context>
You’re closing the Context tag immediately. Remove the / before the >.