We provide the XML code that sets the configuration of the PUBS database. You must add the XML to your project.
This opens the empty context.xml file in the file editor.
<?xml version="1.0" encoding="UTF-8"?> <Context> <!-- maxActive: Maximum number of database connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to -1 for no limit. --> <!-- maxIdle: Maximum number of idle database connections to retain in pool. Set to -1 for no limit. See also the DBCP documentation on this and the minEvictableIdleTimeMillis configuration parameter. --> <!-- maxWait: Maximum time to wait for a database connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. --> <!-- username and password: username and password for the connection --> <!-- driverClassName: Class name for the JDBC driver --> <!-- url: The JDBC connection url for connecting to the database --> <Resource name="PUBS" auth="Container" type="javax.sql.DataSource" maxActive="10" maxIdle="10" maxWait="10000" username="SQLServerUserName" password="SQLServerPassword" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost;database=PUBS;" /> </Context>
Replacing SQLServerUserName and SQLServerPassword respectively with the user name and password required for SQL Server authentication
The web.xml file requires modification to accommodate the SQL Server database.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>JSPBookDemo</display-name> <servlet> <servlet-name>BookServlet</servlet-name> <servlet-class>com.microfocus.book.BookServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BookServlet</servlet-name> <url-pattern>/view</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>view</welcome-file> </welcome-file-list> <resource-ref> <description>DB Connection</description> <res-ref-name>PUBS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app>