Log to an Microsoft SQL Database

From Perfmon4j Wiki
Jump to: navigation, search

Step 1 - Create the database

  • Login to SQL Server Management studio as SA.
  • In Management Studio right click in the Object Explorer on Databases.
  • From popup menu select "New Database".
  • Name the database "perfmon4j".
  • (Optional) If desired change the default locations for the data and log files.
  • Click "options" page and change the recovery model to "Simple" and press OK.

Step 2 - Create the tables

Step 3 - Create the perfmon4j user

  • In object explore right click on "Security" | "Logins".
  • Select "New Login..." from the popup menu.
  • For "Login Name" enter "perfmon4j".
  • Select the "SQL Server Authentication" radio button and enter a new password for the user.
  • (Optional) depending on your policies you might want to turn off "Enforce password policy" and/or "Enforce password expiration".
  • For "Default database" select "perfmon4j".
  • Select the "User Mapping" page.
  • Map the user to the "perfmon4j" database and provision the roles "db datawriter" and "db datareader".
  • Press OK.

Step 4 - Create a JDBC appender

To define a JDBC Appender you will need to know the following:

  1. The name of your JDBC driver class
  2. The location of your JDBC driver file
  3. The jdbc url for your SQL server database (Important: the SQL Server instance must be configured to accept JDBC connections)
  4. The username and password (Created in step 2)
  • Add the jdbc appender to your perfmonconfig.xml file. Below is an example:
        <appender name='jdbc' className='org.perfmon4j.JDBCSQLAppender' interval='1 minute'>
		<attribute name='driverClass'>net.sourceforge.jtds.jdbc.Driver</attribute>
		<attribute name='driverPath'>c:/drivers/jtds.jar</attribute>
		<attribute name='jdbcURL'>jdbc:jtds:sqlserver:/localhost/perfmon4j</attribute>
		<attribute name='dbSchema'>dbo</attribute>
		<attribute name='userName'>perfmon4j</attribute>
		<attribute name='password'>p4jpassword</attribute>
		<attribute name='medianCalculator'>factor=10</attribute>
		<attribute name='thresholdCalculator'>2 seconds, 5 seconds, 10 seconds</attribute>
	</appender>