SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 HOWTOS » Using Windows Authentication with Spring » 23-08-2023 10:42:58

LaurenD
Replies: 0

When using the 'com.microsoft.sqlserver.jdbc.SQLServerDriver' Microsoft driver with Spring to connect to a MSSQL database using WINDOWS AUTHENTICATION, the following URL should be used:

spring.datasource.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=TestDB;integratedSecurity=true;encrypt=false;authenticationScheme=NTLM;user=xxx;password=xxx

#2 HOWTOS » MSSQL's 'FOR XML' to easily structure data pulled from the database » 25-07-2019 12:40:43

LaurenD
Replies: 0

When you want to pull multiple rows of data from one table and would like to process them all at once, MSSQL has a 'FOR XML' clause that you can use in the query that allows you to structure your data into XML elements.

Let's say you have a table with witness data, and you want all witnesses for one incident.
This is the data you would get from the database for accident id 34:

id	accidentid	name	        contact_number
18	34	        Paul Rosenburg	0792356671 
19	34	        Sandra Pages	0823198871

X-ServiceBroker will process all preceding mapping twice with the result returned above.
This is not what is required, we want to get both witnesses and not only one at a time.

To do this the following SQL query can be used:

SELECT(SELECT [id]
      ,[accidentid]
      ,[name]
      ,[contact_number]
  FROM witnessdetails where accidentid = 40 FOR XML PATH , root ('TopLevelElement') ) AS DATA

With this result being returned:

DATA 
<TopLevelElement>
    <row>
        <id>18</id>
        <headerid>40</headerid>
        <name>Paul Rosenburg</name>
        <contact_number>0798526541</contact_number>
    </row>
    <row>
        <id>19</id>
        <headerid>40</headerid>
        <name>Sean Pages</name>
        <contact_number>0114330469</contact_number>
    </row>
</TopLevelElement>

The 'PATH' mode allows us to specify that we want each column value in the resulting rowset to be wrapped in an element.
While the 'root (TopLevelElement)' option allows us to add a single top-level element called TopLevelElement to the data.

In X-ServiceBroker the DataDefinition to collect such a result would look as follows:

<sxi:DataDefinition name="CollectWitnessData">
      <sxi:Fields>
        <sxi:Field name="Data">
          <sxi:Rules>
            <sxi:XmlStringToMemory/>
          </sxi:Rules>
          <sxi:OutputField>witnessoutput</sxi:OutputField>
        </sxi:Field>
      </sxi:Fields>
    </sxi:DataDefinition>

There are plenty of option with this FOR XML clause.

Here is the link to the official docs:
https://docs.microsoft.com/en-us/sql/re … erver-2017

#3 HOWTOS » Adding a certificate file to XLayer's jre/security/cacerts file » 18-01-2019 11:02:47

LaurenD
Replies: 0

Some of our customers have a certificate on their mail server that expires every few years.
When this happens, we need to make the Java runtime environment trusts the certificate. To do this we need to import it into the JRE certificate store (which is XLayer’s jre/security/cacerts file).

Step 1 - Get the certificate file from the customer (A xxx.crt file)
Step 2 - Import the certificate into Xlayer’s jre/security/cacerts file.
       
        i.    Make sure you are in the C:\Program Files\Southern X Integrators\jre\bin directory as you need to use the keytool utility to import it.
       
        ii.    Command Line Query: Keytool -import -alias alias -keystore path-to-jre/lib/security/cacerts -file path-to-certificate-file
               Actual Query Used: keytool -import -alias gcasarray -keystore "C:\Program Files\Southern X Integrators\jre\lib\security\cacerts" -file "C:\Program Files\Southern X Integrators\jre\lib\security\gcasarray_datacentrix_co_za.crt"
       
        iii.    The gcasarray_datacentrix_co_za.crt file was moved into the same directory as the cacerts file (C:\Program Files\Southern X Integrators\jre\lib\security) for convenience, it does not have to be there for the above command to work.
       
        iv.    Just remember to add the double quotes (" ") to your file path if there are files with spaces in the names. For example, "C:\Program Files\Southern X Integrators".

You will be prompted for the keystore password, which is by default changeit.

This URL is where the above information was found: https://www.grim.se/guide/jre-cert

Board footer

Powered by FluxBB