2012-03-30 7 views
1

私はMurachのJavaサーブレットとJSPの第14章でMySQLに接続する作業を行っています。これはできません。私はNetbeansとTomcatを使っています。次のcontext.xmlファイルでコードを実行しようとすると、コードは実行されません。それはこのXMLはcontext.xmlのためにうまく構成されていますか?

[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. 

私が最初の行以外のすべてをコメントアウトすると、コードは実行されますが、決して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> 

答えて

3

コンテキストタグをすぐに終了します。 >の前に/を削除します。

<?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="root" password="rootpassword" 
driverClassName="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost:3306/MyDataBase?autoReconnect=true" 
logAbandoned="true" removeAbandoned="true" 
removeAbandonedTimeout="60" type="javax.sql.DataSource" 
/> 
</Context> 
+2

あなたは私の一日を作ったばかりです。私はあなたの名誉のために私の家族のすべてのメンバーを抱擁しています。 – cafman