Storing Reports in MSSQL Database
By default Sahi stores its reports in a H2 database which is bundled in Sahi. Sahi reports can now also be logged in MSSQL database. To store in a MSSQL database, do the following:Create a Database
Create a database in MSSQL using any MSSQL client. Let us assume that the name of the database is sahireportsCreating Tables
The tables will be created automatically, once Sahi is restarted after performing the following steps. There is no need to run the db script manually.Add MSSQL Driver Jars to Sahi Classpath
Download the MSSQL Connector, extract and copy mssql-jdbc.jar tosahi/userdata/extlib
folder (create if needed).
infoMSSQL Connector version 6.4.0 and later are supported.
infoChoose a mssql-jdbc.jar that supports your Java runtime. For example, to use MSSQL Connector version 6.4.0 with Java 8, copy mssql-jdbc-6.4.0.jre8.jar to
sahi/userdata/extlib
folder.Point Sahi to use the MSSQL Database
Add the following touserdata.properties
in sahi/userdata/config
folder
# Specifies database type.
# The inbuilt options are "mysql", "h2" and "mssql"
# Change jdbc parameters accordingly
db.type=mssql
#JDBC parameters for mssql database
db.driver_name=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.jdbc_url=jdbc:sqlserver://localhost:1433;databaseName=sahireports
db.user_name=sa
db.password=abcd123
Change the user_name, password and database name as required.
infoSSL handshake exception may occur for MSSQL Connector version 10.2.0 and later. This occurs when your SQL server does not have a trusted SSL/TLS certificate. To fix this, append
trustServerCertificate=true
to the connection URL as in the example below.
db.jdbc_url=jdbc:sqlserver://localhost:1433;databaseName=sahireports;trustServerCertificate=true
Restart and Run
Restart Sahi. This will create the required tables in the database.Run a script and check!