How to configure p6spy for mssql server with hibernate? - sql-server

In our web application we are using spring, hibernate & sql server 2016 as db. We are using jndi to connect to the database. To record all the queries executed by hibernate I am trying to implement the p6spy.
Here are the changes I have made.
Changed the resource information from
<Resource name="jdbc/eportalcore" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databaseName=eportal-core;"
username="eportaldbadmin"
password="P#ssw0rd"
maxTotal="100"
maxIdle="20"
minIdle="5"
maxWaitMillis="10000" />
to
<Resource name="jdbc/eportalcore" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.p6spy.engine.spy.P6SpyDriver"
url="jdbc:p6spy:sqlserver://localhost:1433/eportal-core"
username="eportaldbadmin"
password="P#ssw0rd"
maxTotal="100"
maxIdle="20"
minIdle="5"
maxWaitMillis="10000" />
and added the spy.properties file under lib folder of tomcat directory. Also I have placed the p6spy-3.0.0.jar too inside the lib folder.
But after this my application is not getting connected to the DB. What mistake I am doing here? If I remove this changes then it is working fine.
Any suggestions?

I had the same question and here is what I did to make it work. Note my Database connection properties are in a property file (shouldn't be an issue) and that I use tomcat as an Application Server. You can also add P6Spy as a Maven dependency in your project.
Before :
db.properties
db.driver=net.sourceforge.jtds.jdbc.Driver
db.url=jdbc:jtds:sqlserver://${db.server}/${db.name};useNTLMv2=true;domain=XX
After :
Download(latest version when writing this response) the project. Put the p6spy-3.7.0.jar and spy.properties in the tomcat/lib folder. Change the spy.properties and application properties as noted under. Restart application and you should find a spy.log where your logs are printed normally.
db.properties
db.driver=com.p6spy.engine.spy.P6SpyDriver
db.url=jdbc:p6spy:jtds:sqlserver://${db.server}/${db.name};useNTLMv2=true;domain=XX
spy.properties
driverlist=net.sourceforge.jtds.jdbc.Driver

Related

Windows 10 Kiosk Mode (MultiAppAssignedAccess Provisioning package) won't install

For my Project at work i want to install a provisioning Package, that contains a xml configuration for Kiosk Mode (Assigned Access).
I used the exact code from the xml reference page and inserted my Apps, as an account i used a local account that i created for testing.
<?xml version="1.0" encoding="utf-8" ?>
<AssignedAccessConfiguration
xmlns="http://schemas.microsoft.com/AssignedAccess/2017/config"
xmlns:rs5="http://schemas.microsoft.com/AssignedAccess/201810/config"
>
<Profiles>
<Profile Id="{786df454-09d0-492f-9ef0-c07731d1606f}">
<AllAppsList>
<AllowedApps>
<App DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe"/>
</AllowedApps>
</AllAppsList>
<StartLayout>
<![CDATA[<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="Group1">
<start:Tile Size="4x4" Column="0" Row="0" DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe" />
</start:Group>
</defaultlayout:StartLayout>
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
]]>
</StartLayout>
<Taskbar ShowTaskbar="true"/>
<Taskbar/>
</Profile>
</Profiles>
<Configs>
<Config>
<Account>.\Kiosk-test</Account>
<DefaultProfile Id="{786df454-09d0-492f-9ef0-c07731d1606f}"/>
</Config>
</Configs>
</AssignedAccessConfiguration>
When i try to install it, it either wont install at all with Error code 0x8007000b on one computer or on my private computer the installation will fail.
The Settings say that i has to Lock the user interface and make changes to the device.
then the EventLogs say that it failed due to follwing error: "Error during verification because the document does not contain exactly one root node. (0xC00CE223)" (translated with deepl, so might be a bit different in reality)
I could not find a matching solution on the internet.
I also tried using the configuration Wizard for single app Kiosk, and there the same error occured.
Does anyone of you know a solution to that or can tell me what the problem is at all?
I tried to change every part of the code, so that every aspect (App, User, e.g.) is tested seperately.
I moved my computer out the group policies, so that there are no GPOs that vreate an error.
The error messages didn't change at all
Thanks and best Regards!

can data-import-handler use HikariCP?

I'm using solr4.5.1 in work.
The trouble is that a lot of getConnection occurred, when I execute data-import(full-import). So I thought if HikariCP could be used in data-import, but I haven't found similar problem.
Is it possible? If so please advice.
Solr 4.5.1 with Tomcat
data-config.xml
<dataSource driver="oracle.jdbc.driver.OracleDriver"
name="jdbc"
url="jdbc:oracle:thin:#address/mydb"
user="user" password="pass"/>
Heavily borrowed from David H Nebinger's post: Tomcat and HikariCP.
Install HikariCP
To make use of JNDI, you need to declare the JNDI datasource with all its' settings, password and cache options within the JNDI declaration. This has nothing to do with Solr at this point. This is a Tomcat mechanism. How you do this is described in this tutorial that also makes use of HikariCP.
First is to download the .zip or .tar.gz file from http://brettwooldridge.github.io/HikariCP/. This is actually a source release that you'll need to build yourself.
Second option is to download the built jar from a source like Maven Central, https://mvnrepository.com/artifact/com.zaxxer/HikariCP
Once you have the jar, copy to the Tomcat lib/ext directory. Note that Hikari CP does have a dependency on SLF4J, so you'll need to put that jar into lib/ext too.
Do not forget to place your datasource's JDBC driver in the lib/ext folder.
Configure the JNDI datasource
Location of your JNDI datasource <Resource /> definitions depends upon the scope for the connections. You can define them globally by specifying them in Tomcat's conf/server.xml and conf/context.xml, or you can scope them to individual applications by defining them in conf/Catalina/localhost/WebAppContext.xml (where WebAppContext is the web application context for the app, basically the directory name from Tomcat's webapps directory).
Create the file conf/Catalina/localhost/ROOT.xml if it doesn't already exist. Use the table from https://github.com/brettwooldridge/HikariCP#popular-datasource-class-names to find your data source class name, we'll need it when we define the element.
<Resource name="jdbc/SolrPool" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
minimumIdle="5"
maximumPoolSize="10"
connectionTimeout="300000"
dataSourceClassName="oracle.jdbc.pool.OracleDataSource"
dataSource.url="jdbc:oracle:thin:#address/mydb"
dataSource.implicitCachingEnabled="true"
dataSource.user="user"
dataSource.password="pass" />
Make use of the JNDI datasource in Solr
After you have followed this tutorial, you will need to use the declared JNDI datasource, this would be like described in the Solr Wiki:
<dataSource
jndiName="java:jdbc/SolrPool"
type="JdbcDataSource"
user="" password=""/> <!-- leave out user/password here -->

GuideWire BC configuration with SQL Server database

Currently working on PC-BC integration. I need to configure my studios with SQL Server database, For PC its working fine, but for BC I'm getting error. If anyone knows please help me to sort this out.
<database name="BillingCenterDatabase" dbtype="sqlserver" autoupgrade="true">
<dbcp-connection-pool jdbc-url="jdbc:sqlserver://localhost:1433;DatabaseName=BillingCenterDatabase;User=username;Password=pass#1121"/>
<upgrade defer-create-nonessential-indexes="false">
<versiontriggers dbmsperfinfothreshold="600" />
</upgrade>
</database>
my username is "username" and password is "pass#1121"
database name : BillingCenterDatabase
The error which I'm getting is
gw.pl.exception.GWLifecycleException: No appropriate database found in configuration: env = 'null'
try adding environment attribute in your database tag like shown below,
<database name="BillingCenterDatabase" dbtype="sqlserver" env="dev" autoupgrade="true">
<dbcp-connection-pool jdbc-url="jdbc:sqlserver://localhost:1433;DatabaseName=BillingCenterDatabase;User=username;Password=pass#1121"/>
<upgrade defer-create-nonessential-indexes="false">
<versiontriggers dbmsperfinfothreshold="600" />
</upgrade>
You should have to mention environment name in tomcat.conf in tomcat config file if you are deploying your application on tomcat.
JAVA_OPTS="-Dgw.server.mode=dev -Dgw.bc.env=st"
above line for st environment. you need to enter ut/st/st2 for different environment.

How do I force MSDeploy API to keep an existing Connectionstring?

We are deploying an ASP.Net application to IIS via MSDeploy API. We only want to update existing websites. In our ...pubxml we have defined following:
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringA-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)ConnectionstringB-Web.config Connection String">
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>
By default, the setParameters.xml created on publish, looks like this:
<setParameter name="ConnectionstringA-Web.config Connection String" value="metadata=res://*/itrDTO.csdl|res://*/itrDTO.ssdl|res://*/itrDTO.msl;provider=System.Data.SqlClient;provider connection string="data source=devServer;initial catalog=devDB;User Id=devUser;Password=devPW;MultipleActiveResultSets=True;App=EntityFramework"" />
<setParameter name="ConnectionstringB-Web.config Connection String" value="data source=devServer;initial catalog=devDB;integrated security=True" />
I also tried to create a "Projectname.wpp.targets" with this configuration inside my project:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<AutoParameterizationWebConfigConnectionStrings>false</AutoParameterizationWebConfigConnectionStrings>
</PropertyGroup>
</Project>
The result is that the connectionstrings are not created inside setparameters.xml.
However, all combinations of configurations here are changing the connectionstrings inside the web.config on the destinationserver. This happens if we import the package by the IIS-ManagementUI AND when we deploy the package by MSDeploy API.
All examples I've found for the "parameterization" - topic are for the IIS-Management process. As I understand parameterization, this is only usefull for manually installing updates, so that the admin has a UI to configure stuff. But we have no UI when we update the systems of our customers.
Update:
When I Publish with Visual Studio, here is the funny result:
I think this means "Hey WebDeploy, keep your hands off the connection strings!"
When I preview the changes, this is the result:
Parameterization is useful both through the IIS install UI and via the commandline. We use WebDeploy/Parameterization for the deployment of all our 40+ applications.
I just ran a test with a new blank ASP.NET application and found that by default the ConnectionString is parameterized but after setting the AutoParameterizationWebConfigConnectionStrings MSBUILD property to false it did not parameterize the ConnectionString. The parameter entry was removed from both the parameters.xml and SetParameters files.
I suggest you clear out your target website folder and republish with this property set.
Also double check that you don't have config transforms or something else that might be changing the config.

Jdeveloper war deployment to tomcat

I am a newbie.
I am trying to publish procedures which return refcursor as webservice.
As webservices do not support ref cursor return type so I chnaged the return type to pl/sql table.
I created the jax rpc in Jdeveloper studio 11.1.2.4.0 and tested it. This runs ok. I need to deploy it on tomcat server and am failing completely.
I copied the war file generated by Jdeveloper to the webapps directory in Tomcat and started Tomcat but this didn't work, as the following exception was thrown:
java.lang.ClassCastException: omsdevconn.MyWebServicetomcatUser cannot be cast to javax.servlet.Servlet
If someone has done it then can I get the steps for the process to deploy it on Tomcat 6.0.37?
Thanks in advance
Download jaxws-rt-2.0-SNAPSHOT.jar and jaxws-2_0.jar
Copy into $CATALINA_HOME/lib folder
Add the following in web.xml under web-app
<web-app>
**<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>**
............<!--your other servlet definations-->
</web-app>
create sun-jaxws.xml under your applications web-inf folder and configure endpoints.You can have a look at jdeveloper generated xml file to get all the information
sample sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"version="2.0">
<endpoint name="fromwsdl"
interface="com.foo.yourserviceInterface"
implementation="com.foo.yourserviceClass"
wsdl="WEB-INF/wsdl/youservice.wsdl"
service="YourService"
port="YourServicePort"
url-pattern="/serviceAccessUrl" />
</endpoints>
create war for your application and deploy you application under tomcat/webapps
start tomcat
After starting tomcat you can access the service as
http:/host:port/yourservicename/methodInService
As you are calling oracle plsql code and IF you are using any oracle specific calls like OracleCallabelStatement then on run time you will get class cast exceptions from tomcat datasource when trying to cast callabelstatement to oraclecallabelstatement for that you need to configure oracledatasource in tomcat
http://www.oracle.com/technetwork/articles/oem/ucp-jdbc-tomcat-355431.html
More information on Java API for XML Web Services (JAX-WS)
https://jax-ws.java.net/nonav/2.2.1/docs/UsersGuide.html#1.0_Introduction
Another way to deploy service generated by Jdeveloper when exposing a plsql procedure as webservice
I am not allowed to post more that 2 links so please add and extra "/" after http: to correct the links
This solution uses Apache Axis which allows you to call your web service(which is not exposed as restful) directly from browser by creating a SOAP request behind the scenes and involke the service method giving it soap message.
1)Generate a webservice in Jdeveloper .It will create java files and corresponding ".class" file , "wsdl file" in web-inf and some other xml files. Make a note of LOCATION of .class file and wsdl file.
2)Download eclipse and extract it on your hard drive (It needs java to run So you must have java installed on system .You can download eclipse from
http:/www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junosr1
3)Download Axis plugin for eclipse from here :
http:/www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-service-plugin-1.6.2.zip
and install it in eclipse. Installation Instructions :
http:/axis.apache.org/axis2/java/core/tools/eclipse/plugin-installation.html
4)Generate the aar file via eclipse axis plugin. Instructions :
http:/axis.apache.org/axis2/java/core/tools/eclipse/servicearchiver-plugin.html#Operation
5)Make following changes in tomcat-user.xml file
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-jmx"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-jmx"/>
6)IF YOU ARE USING ORACLE SPECIFIC CLASSES IN CODE (Which most probably Jdeveloper will produce) : Configure a oracle data source in tomcat (server.xml or context.xml). Instructions :
http:/www.oracle.com/technetwork/articles/oem/ucp-jdbc-tomcat-355431.html
Make sure you have ojdbc6.jar and ucp.jar in Tomcat/lib folder.
7)Download axis war file to deploy in tomcat from here :
http:/www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.6.2/axis2-eclipse-service-plugin-1.6.2.zip
Unzip the zip , it will have a axis2.war file in it. Put this war file under “\Tomcat\webapps” directory
8)Start tomcat. On tomcat console see if there are any errors in deploying axis. If everything is fine you should be able to see axis page on http:/yourhost:yourport/axis2/
9)Click on Administration link . Enter user id “admin” and password “Axis2” and login
10)Click upload and browse to the location of aar file you generate in step 4 and upload. After it shows you success click on Available service. It takes a bit of time but you should be able to see you service.Click on service to see wsdl to verify
11)Call your service method from browser and cross your fingers and toes.
Note that the link to hit will be something Like
http:/yourhost:yourport/axis2/services/YourServiceName/serviceMethod?arg1=blah&
Make sure your got the arg names right.you should be able to see the correct names from wsdl

Resources