P6Spy 使用指南 .
P6Spy Installation
This installation documentation contains instructions for installing P6Spy with various application servers. In addition, it contains general installation instructions for application servers not listed and applications that do not use application servers. Keep in mind that the Unspecified Application Server instructions do not contain details specific to your application server. Use them only as a guideline. If you create instructions for other application servers, send us a copy for possible publication in the documentation.
The installed P6Spy software offers many configuration options. See Common Property File Settings for additional information.
The following instructions were tested with various JBoss versions ranging from JBoss 2.2.2-2.4.4 with Jakarta Tomcat 3.2.2-4.0.1 integration. To install P6Spy on JBoss 2.x, complete the following steps:
Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.- Move the p6spy.jar file to the ext directory. An example of the path to your ext directory is C:/JBoss-2.2.2_Tomcat-3.2.2/jboss/lib/ext.
Move the spy.properties file to the db directory, which is part of the JBoss classpath. An example of the path to your db directory is C:/JBoss-2.2.2_Tomcat-3.2.2/jboss/db.- Modify the jboss.jcml file in the Tomcat conf directory to use the P6Spy driver, by removing your existing driver from the Drivers attribute and replacing it with the P6Spy driver. An example of an edited jboss.jcml file follows:
<mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
<attribute name="Drivers">com.p6spy.engine.spy.P6SpyDriver</attribute>
</mbean>
-
Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line follows:
realdriver = oracle.jdbc.driver.OracleDriver
Installation is complete. When you run your application, a spy.log file is generated in the bin directory of the JBoss server. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by Alan Arvesen, IronGrid)
The following instructions were tested with JBoss 3.0.4 with Jetty integration. For these instructions, P6Spy assumes that you are using the default server residing in JBOSS_DIST/server/default, where JBOSS_DIST is the directory in which JBoss is installed. These instructions are intended for wrapping driver services, not XADataSource services. To install P6Spy on JBoss 3.x, complete the following steps:
Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties. Move the p6spy.jar file to the lib directory. An example of the path to your lib directory is C:/java/jboss-3.0.4/server/default/lib. Add spy.properties to your JBoss classpath. By default, the JBoss classpath set up by run.bat only points to tools.jar and run.jar. You may need to add a directory, via JBOSS_CLASSPATH, to this path. An example of an edited JBoss classpath follows:
C:/> set JBOSS_CLASSPATH=C:/java/jboss-3.0.4/server/default/db
C:/> copy C:/java/p6spy/spy.* C:/java/jboss-3.0.4/server/default/db
- Create a p6spy-service.xml file in JBOSS_DIST/server/deploy. Set the config-property element named DriverClass to P6SpyDriver in p6spy-service.xml, by basing a new XML file on one of the examples in the JBOSS_DIST/docs/examples/jca directory. You can also configure JndiName and ConnectionURL for your specific implementation. An example of the pertinent portions (not the complete XML file) of a p6spy-service.xml file follows:
-
Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line follows:
<attribute name="JndiName">MySqlDS</attribute>
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://localhost/localdb</config-property>
<config-property name="DriverClass"type="java.lang.String">com.p6spy.engine.spy.P6SpyDriver</config-property>Note: Make sure there is not a service that explicitly loads the wrapped driver. A service of this type will load the specified driver before P6SpyDriver, resulting in unwrapped connections.
realdriver=org.gjt.mm.mysql.Driver
Installation is complete. When you run your application, a log file (spy.log) is generated in the bin directory of the JBoss server. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
The following instructions were tested with Orion. To install P6Spy on Orion, complete the following steps:
- Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.
- Move p6spy.jar and spy.properties to the orion-home/lib directory, where orion-home is the directory in which Orion is installed. An example of the path to your orion-home/lib directory is C:/orion/lib.
- Modify the connection-driver line in data-sources.xml to use P6SpyDriver. data-sources.xml resides in orion-home/config. An example of an edited data-sources.xml file follows:
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="Hypersonic"
location="jdbc/HypersonicCoreDS"
xa-location="jdbc/xa/HypersonicXADS"
ejb-location="jdbc/HypersonicDS"
connection-driver="com.p6spy.engine.spy.P6SpyDriver"
username="sa"
password=""
url="jdbc:HypersonicSQL:./database/defaultdb"
inactivity-timeout="30"
/>
-
In the example installation outlined above, Orion cannot locate spy.properties because of the classpath that Orion uses. Use the -D option to tell Orion where the property file resides by running Orion using the following command:
java -Dp6.home=c:/orion/orion/lib -jar orion.jar
- Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. (This is the original value specified in connection-driver.) For example, if Hypersonic (the default database) was the original connection-driver value, the realdriver value is set to org.hsql.jdbcDriver.
Installation is complete. When you run your application, a log file (spy.log) is generated in the orion-home directory of the Orion server. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
The following instructions were tested with Jakarta Tomcat 3.x. Note that since you typically write or otherwise obtain your own Connection Pool when using Tomcat, these instructions will differ by application. To install P6Spy on Jakarta Tomcat, complete the following steps:
- Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.
- Move the p6spy.jar and spy.properties files to the lib directory. An example of the path to your lib directory is C:/jakarta-tomcat-3.2.1/webapps/p6/WEB-INF/lib.
-
Modify Tomcat to use P6SpyDriver. Tomcat applications obtain their JDBC connection in a variety of ways. Most applications have the database driver name externalized as a configuration parameter. For example, in your web.xml file (which resides in C:/jakarta-tomcat-3.2.1/webapps/p6/WEB-INF) you may have something similar to the following:
<init-param><param-name>databaseDriver</param-name><param-value>org.gjt.mm.mysql.Driver</param-value></init-param>
In this above case, the databaseDriver parameter has a value of org.gjt.mm.mysql.Driver, which is the MySQL™ driver. Wherever this configuration information is stored, change the driver name (org.gjt.mm.mysql.Driver, in our example) to com.p6spy.engine.spy.P6SpyDriver, as in the following example:
<init-param><param-name>databaseDriver</param-name><param-value>com.p6spy.engine.spy.P6SpyDriver</param-value></init-param>
-
Enable Tomcat to locate spy.properties. While all of the JAR files in your lib directory are, by default, included in Tomcat's classpath, the lib directory itself is not. This means Tomcat will not be able to find your spy.properties file, which will result in an error. So, you must include spy.properties in the Tomcat classpath. Use the TOMCAT_OPTS environment variable to specify the location of the spy.properties file. An example of the edited TOMCAT_OPTS environment variable follows:
SET TOMCAT_OPTS=-Dp6.home=C:/jakarta-tomcat-3.2.1/webapps/p6/WEB-INF/lib
- Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line (using MySQL as the driver) follows:
realdriver = org.gjt.mm.mysql.Driver
Installation is complete. When you run your application, a log file (spy.log) is generated in the directory from which you launched the application. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by François Exertier, JOnAS Opensource EJB Server team)
The following instructions were tested with JOnAS 2.3.x. To install P6Spy on JOnAS EJB, complete the following steps:
- Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.
- Put the p6spy.jar file in the classpath of the JOnAS EJB server. For example, if p6spy.jar is in the /opt/Provider6 directory, add /opt/Provider6/p6psy.jar to the XTRA_CLASSPATH environment variable or directly edit the config_env script.
- Move spy.properties to a directory which is part of your classpath. It is recommended that you move it to the directory where your jndi.properties file resides.
- Modify the datasource.properties file (where datasource is the name of the data source) by replacing the database driver classname with the P6Psy database driver classname in the datasource.classname property. For example, the Oracle1.properties file delivered with JOnAS should be updated by replacing oracle.jdbc.driver.OracleDriver with com.p6spy.engine.spy.P6SpyDriver. An example follows:
datasource.name jdbc_1
datasource.description "Standard jdbc driver for Oracle"
datasource.url jdbc:oracle:thin:scott/tiger@maltes:1521:ORA1
datasource.classname com.p6spy.engine.spy.P6SpyDriver
...
Note: Database access configuration within JOnAS is described in a DataSource property file, such as Oracle1.properties. Refer to the JOnAS Bean Programmer's Guide for more details.
- Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line follows:
realdriver = oracle.jdbc.driver.OracleDriver
The following sections contain specific information on installing P6Spy on BEA WebLogic Portal 4.0, BEA WebLogic Server 6.1, and BEA WebLogic 5.1.
Note: IBM™ Cloudscape does not work with P6Spy and BEA WebLogic. However, Cloudscape does work with P6Spy when using the J2EE reference implementation server. The following suggestion was submitted by Adrian Fletcher: "I may be wrong but I suspect the problem with Cloudscape and WebLogic is that both drivers end up registered against the same URL. I seem to remember that the best trick for avoiding this is mangling the URL. If you instruct users to prepend "p6spy:" to their URL and then remove it in your wrapped file, it should work in more cases." You can do this with the useprefix option. If anyone has an opportunity to validate this, please drop us a line with updated information.
(Contributed by Philip Ogren, BEA)
The following instructions were tested with WebLogic Server 6.1 Service Pack 2 with WebLogic Portal 4.0 Service Pack 1 running on Microsoft® Windows® using the following:
WebLogic jDriver for Oracle® Oracle Thin driver for 8.1.7 WebLogic jDriver for Microsoft SQL Server™ Sybase™ jConnect-5_2 driverThe default Stockportal (Avitek) application is used in this example. To install P6Spy on BEA WebLogic Portal, complete the following steps:
Extract the p6spy-install.jar file to a temporary directory. The p6spy-install.jar file contains the files p6spy.jar and spy.properties. Move p6spy.jar to bea-home/wlportal4.0/lib/ext, where bea-home is the directory in which BEA WebLogic is installed.- Add ;%P13N_DIR%/lib/ext/p6spy.jar to EXT_CLASSPATH in the set-environment.bat file. set-environment.bat resides in bea-home/wlportal4.0/bin/win32. Do not include any trailing spaces after the new line.
- Move spy.properties to bea-home/wlportal4.0/config/portalDomain or to the application's domain directory.
- Modify the realdriver line in the spy.properties file to reflect your wrapped database driver. An example of a modified realdriver line follows:
realdriver=weblogic.jdbc.oci.Driver
- Add ;%P13N_DIR%/config/portalDomain to the classpath in the startPortal.bat file. The path to startPortal.bat is bea-home/wlportal4.0/config/portalDomain. Do not include any trailing spaces after the new line.
- Modify WebLogic Portal to use the P6Spy driver. Either modify config.xml (which resides in bea-home/wlportal4.0/config/portalDomain) directly or complete the following steps:
- Start WebLogic Portal by running startPortal.bat.
- Start the Administration Console tool by navigating to http://your-host:7501/console, where your-host is the machine on which BEA WebLogic is installed.
- Navigate to the your-domain (where your-domain is the domain name specified during the BEA WebLogic install) -> Services -> JDBC -> Connection Pools node and set the Driver Classname for each Connection Pool to com.p6spy.engine.spy.P6SpyDriver.
- If using RDBMS Security Realm, configure P6Spy to monitor your realms (in this example, commercePool, dataSyncPool, and wlcsRealm) by completing the following steps:
- Using the Administration Console, navigate to the your-domain -> Security -> Realms node.
- Select the security realm.
- Click the Database tab.
- Set the Driver parameter to com.p6spy.engine.spy.P6SpyDriver.
- Using the Administration Console, shut down WebLogic Portal. Right-click on the your-domain->Servers->your-server node and select Stop this Server from the pop-up menu.
- Restart WebLogic Portal by running startPortal.bat.
Installation is complete. When you run your application, a log file (spy.log) is generated in bea-home/wlportal4.0. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by Philip Ogren, BEA)
The following instructions were tested with WebLogic Server 6.1 Service Pack 2 with WebLogic Portal 4.0 Service Pack 1 running on Microsoft Windows using the following:
WebLogic jDriver for Oracle Oracle Thin driver for 8.1.7 WebLogic jDriver for Microsoft SQL Server Sybase jConnect-5_2 driveTo install P6Spy on BEA WebLogic Server, complete the following steps:
Extract the p6spy-install.jar file to a temporary directory. The p6spy-install.jar file contains the files p6spy.jar and spy.properties. Move p6spy.jar to bea-home/wlserver6.1/lib/ext, where bea-home is the directory in which BEA WebLogic is installed.- Move spy.properties to bea-home/wlserver6.1/config/your-domain, where your-domain is the domain name specified during the BEA WebLogic install.
- Modify the realdriver line in the spy.properties file to reflect your wrapped database driver. An example of a modified realdriver line follows:
realdriver=weblogic.jdbc.oci.Driver
- Add ;./lib/ext/p6spy.jar;./config/your-domain to the classpath in the startWebLogic.cmd file. startWebLogic.cmd resides in bea-home/wlserver6.1/config/your-domain. Do not include any trailing spaces after the new line. This adds p6spy.jar and spy.properties to the classpath.
- Modify WebLogic Server to use the P6Spy driver. Either modify config.xml (which resides in bea-home/wlserver6.1/config/your-domain) directly or complete the following steps:
- Start WebLogic Server by running startWebLogic.cmd.
- Start the Administration Console tool by navigating to http://<your-host>:7501/console.
- Navigate to the your-domain -> Services -> JDBC -> Connection Pools node and set the Driver Classname for each Connection Pool to com.p6spy.engine.spy.P6SpyDriver.
- If using RDBMS Security Realm, configure P6Spy to to monitor your realms (in this example, commercePool, dataSyncPool, and wlcsRealm) by completing the following steps:
- Using the Administration Console, navigate to the your-domain -> Security -> Realms node.
- Select the security realm.
- Click the Database tab.
- Set the Driver parameter to com.p6spy.engine.spy.P6SpyDriver.
- Using the Administration Console, shut down WebLogic Server. Right-click on the your-domain -> Servers -> your-server node and select Stop this Server from the pop-up menu.
- Restart WebLogic Portal by running startWebLogic.cmd.
Installation is complete. When you run your application, a log file (spy.log) is generated in bea-home/wlserver6.1. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by Richard Delbert)
The following instructions were tested with WebLogic 5.1. To install P6Spy on BEA WebLogic, complete the following steps:
Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties. Edit startWeblogic.sh, by putting p6spy.jar in the JAVA_CLASSPATH. Edit startWeblogic.sh, by putting spy.properties in the JAVA_CLASSPATH. Edit weblogic.properties (Connection Pool), by replacing the JDBC class driver with com.p6spy.engine.spy.P6SpyDriver. Modify the realdriver line in the spy.properties file to reflect your wrapped database driver. An example of a modified realdriver line follows:
realdriver = oracle.jdbc.driver.OracleDriverInstallation is complete. When you run your application, a log file (spy.log) is generated in the WebLogic home directory. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
The following instructions were tested with ATG Dynamo 5.1. To install P6Spy on ATG Dynamo, complete the following steps:
- Extract the p6spy-install.jar file into a directory (C:/p6spy, in our example). The p6spy-install.jar contains p6spy.jar and spy.properties.
- Start the ATG Dynamo application server and your database.
- Modify the ATG Dynamo server to include p6spy.jar and spy.properties in its classpath by completing the following steps:
- Run the Admin Tool by logging in to http://localhost:8830, assuming you are. (This URL is an example which assumes you are running ATG Dynamo on your local machine).
Note: The default user/pass is admin/admin.
- Select Configuration Manager -> Default Configuration -> System Paths.
- Enter the full path of the p6spy.jar file under Extend Dynamo's Classpath. An example of the path is C:/p6spy/p6spy.jar.
- Enter the full path of the spy.properties file under Extend Dynamo's Classpath. An example of the path is C:/p6spy.
- Click Append to Classpath.
- Confirm the new classpath value is correct under Extend Dynamo's Classpath.
- Restart ATG Dynamo by navigating to http://localhost:8830 and clicking Restart Dynamo.
- Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. The realdriver property is, by default, set to Oracle, as in:
realdriver = oracle.jdbc.driver.OracleDriver
Change this to reflect your database. An example of a modified realdriver line for ATG demo follows:
realdriver = solid.jdbc.SolidDriver
- Modify ATG to use the P6Spy driver by completing the following steps:
- Run the Admin Tool by logging in to http://localhost:8830.
- Select Configuration Manager -> Default Configuration -> Connection Pools -> JTDataSource -> JDBC 1.x/2.x driver -> Custom JDBC Information.
- Enter the information exactly as you would for connecting to your database, except for the driver box. Set the driver box to com.p6spy.engine.spy.P6SpyDriver.
An example setup follows:
URL: jdbc:solid://localhost:1313
driver: com.p6spy.engine.spy.P6SpyDriver
database:
server: localhost:1313
server name:
user name: admin
password: admin
confirm password: admin- Click Try to Connect. Confirm that the ATG connection is successful.
- Click Apply Changes, if the connection is successful.
- Restart ATG Dynamo by navigating to to http://localhost:8830 and clicking Restart Dynamo.
Installation is complete. When you run your application, a log file (spy.log) is generated in the C:/ATG/Dynamo5.1/home directory. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by Michael Sgroi)
The following instructions were tested with Sun iPlanet 6.0 Service Pack 3 and should work for any release of iPlanet 6.0. To install P6Spy on iPlanet, complete the following steps:
- Extract the p6spy-install.jar file into a directory named spy-home, where spy-home is the name of the P6Spy directory. The p6spy-install.jar file contains p6spy.jar and spy.properties.
- Add p6spy.jar to your classpath by running the command line executable kregedit. Under Software/iPlanet -> 6.0 -> Java -> ClassPath, modify the entry adding spy-home to the end of the classpath.
- Modify your application server to use the P6Spy database driver by running the command line executable jdbcsetup. Add a new 3rd Party JDBC Configuration as shown in the following example:
Driver Identifier: spy
Driver Classname: com.p6spy.engine.spy.P6SpyDriver
Driver Classpath: spy-home/p6spy.jar
- To tell P6Spy about the wrapped database driver, register your DataSource by running the following command line executable:
iasdeploy regdatasource -user iPlanet_admin_username -password iPlanet_admin_password -host localhost -port iPlanet_admin _port config_filename
where iPlanet_admin_username is your iPlanet admin username, iPlanet_admin_password is your iPlanet admin password, iPlanet_admin_port is the iPlanet admin port number, and config_filename is the full path to the file containing your DataSource configuration. An example follows:
<ias-resource>
<resource>
<jndi-name>jdbc/yourapp/ora-type4-spy</jndi-name>
<jdbc>
<driver-type>spy</driver-type>
<database-url>jdbc:oracle:thin:@localhost:1521:orcl</database-url>
<username>user</username>
<password>password</password>
</jdbc>
</resource>
</ias-resource>
(For more details on parameters passed to iasdeploy and the format of config_filename, refer to the iPlanet documentation.)
Installation is complete. When you run your application, a spy.log file is generated. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
The following instructions were tested with IBM WebSphere 4.0.
Note: Before installing, make sure your JDBC driver is configured in your target application server as a DataSource.
To install P6Spy on IBM WebSphere, complete the following steps:
-
Extract the p6spy-install.jar file. The installation file contains p6spy.jar and spy.properties.
-
Run the WebSphere Administration tool by logging in to http://localhost/9090/admin.
-
Under the WebSphere Administration Domain, open the Resources tree.
-
Open the JDBC Drivers tree.
-
Open the JDBC Driver you want to replace. The list of DataSources defined for this driver displays.
-
Click on the name of the DataSource that you want to trace with P6Spy. The configuration page for that DataSource displays.
-
Before making any changes, make a note of the values for the following fields:DatabaseName
Default User
Default Password -
Click Properties to view the Driver Specific properties. Each of the items displayed in the table is a setting that the driver needs in order to connect to the database. Make a note of the name and value of each item. In our MySQL example, these properties are as follows:
port 3306
serverName myhost
-
Navigate to the previous page (the configuration page for the driver), and change the JNDI Name for the DataSource. For example, if the DataSource JNDI name is MySqlDS, change it to RealMySqlDS.
-
Click JDBC Drivers (in the left panel), to open the list of Drivers.
-
Click New to open a configuration page for a new driver.
-
Accept the User-defined JDBC Driver selection.
-
Click Next.
-
Fill in the table with the following values:
Server Class Path = path_to_p6spy.jar
Name = P6SpyDriver
Description = P6Spy JDBC tracing driver
Implementation Classname = com.p6spy.engine.spy.P6ConnectionPoolDataSource
-
Click OK. The list of drivers, which contains your new driver specifications, displays.
- Open the new JDBC Drivers tree, which contains P6SpyDriver, in the left panel.
-
Open the Data Sources folder.
-
Click New to create a new DataSource for P6SpyDriver.
-
Set this DataSource up like the original configuration for your target driver (the one that you earlier recorded in your notes), except for two things: the DataSource name and the Driver Specific properties. Use something different for the DataSource name, and do not set any Driver Specific properties.
-
Save the configuration.
-
Configure the spy.properties file. Assuming that your names match the ones used above, and that you are using the MySQL driver from mysql.com, your DataSource related entries should look like the following examples:
realdatasource=RealMySqlDS
prealdatasourceclass=com.mysql.jdbc.jdbc2.optional.MysqlDataSourcerealdatasourceproperties=port;3306,serverName;myhost
Note: The items in realdatasourceproperties are the items that you recorded from the Driver Specific properties in your original DataSource configuration.
-
Modify the realdriver line in the spy.properties file to reflect the wrapped database driver (com.mysql.Driver, in our example). An example of a modified realdriver line follows:
realdriver=com.mysql.Driver
-
- Restart WebSphere, by using either the FirstSteps control panel or the scripts in the WebSphere bin directory.
Installation is complete. When you run your application, a spy.log file is generated. The log file contains a list of all of the database statements executed. You can change both the destination of spy.log and what it logs by editing the spy.properties file (see Common Property File Settings).
(Contributed by Hadi Nahari, RadonSoft)
The following instructions were tested with Resin 2.1.x. Note that since you typically write or otherwise obtain your own Connection Pool when using Resin, these instructions will differ by application. To install P6Spy on Resin, complete the following steps:
-
Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.
-
Move the p6spy.jar and spy.properties files to the lib directory. An example of the path to your lib directory is C:/resin-2.1.6/webapps/your_app_name/WEB-INF/lib, where your_app_name is the name of your application.
-
Modify Resin to use P6SpyDriver. Resin applications obtain their JDBC connection in a variety of ways. Most applications have the database driver name externalized as a configuration parameter. For example, in your web.xml file (which may reside in C:/resin-2.1.6/webapps/your_app_name/WEB-INF) you may have something similar to the following:
<init-param>
<param-name>db.driver</param-name>
<!-- mysql (mm driver) -->
<param-value>org.gjt.mm.mysql.Driver</param-value>
</init-param>
In the above case, the db.driver parameter has a value of org.gjt.mm.mysql.Driver, which is the MySQL driver. Wherever this configuration information is stored, change the driver name (org.gjt.mm.mysql.Driver, in our example) to com.p6spy.engine.spy.P6SpyDriver, as in the following example:
<init-param>
<param-name>db.driver</param-name>
<!-- mysql (mm driver) -->
<param-value>com.p6spy.engine.spy.P6SpyDriver</param-value>
</init-param>
-
Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line (using MySQL as the driver) follows:
realdriver = org.gjt.mm.mysql.Driver
- In your start-up script (for Unix), or startup command-line (for Windows), enable Resin to locate spy.properties. While all of the JAR files in your lib directory are, by default, included in Resin's classpath, the lib directory itself is not. This means Resin will not be able to find your spy.properties file, which will result in an error. So, you must include spy.properties in the Resin classpath. Use Resin's command-line argument to specify the location of the spy.properties file. An example of passing p6.home environment variable as a command-line argument to Resin's httpd on Windows follows:
C:/resin-2.1.6/bin/httpd
- -Dp6.home=C:/resin-2.1.6/webapps/your_app_name/WEB-INF/lib
The following installation instructions are intended for use with application servers not listed above and applications that do not use application servers. To install P6Spy, complete the following steps:
- Extract the p6spy-install.jar file. The p6spy-install.jar file contains p6spy.jar and spy.properties.
-
Put the p6spy.jar file in your classpath by copying the p6spy.jar file into your ext directory. If you are using an EJB server it probably has its own ext directory. If you are not using an EJB server, then use the JDK ext directory, which is JDK_HOME/jre/lib/ext, or add p6spy.jar to your classpath. Remember that if you are adding p6spy.jar to your classpath, you must reference the JAR filename directly. An example of the path in Microsoft Windows follows:
CLASSPATH=c:/p6spy/p6spy.jar
Note: If you are using an EJB server, adding the p6spy.jar file to your classpath may not work. Some EJB servers ignore the classpath, setting their own on startup.
-
Move spy.properties into a directory listed in your classpath. For example, if your classpath is C:/p6spy/p6spy.jar;c:/java, copy it to the java directory. Unlike JAR files, you do not directly reference your property file in the classpath.
-
Modify your application server or application to use the P6Spy database driver.
-
Modify the realdriver line in the spy.properties file to reflect the wrapped database driver. An example of a modified realdriver line follows:
realdriver = oracle.jdbc.driver.OracleDriver