Translate

Friday, October 15, 2021

Tomcat - Unable to locate persistence units error

I recently was working on updating the libraries for a Java web application and was unable to connect to the database. Stepping through the program in Tomcat I saw that it was giving me the "Unable to locate persistence units" error. This puzzled me for a long time, so I decided to take a closer look as I stepped through the application. The actual error message in the exception was "unrecognized persistence.xml version 2.2"! So I reverted back to version 2.1!

Tomcat - Service will not start, incorrect function error in Windows System Log

The Tomcat service would not start. I checked the Windows System Log and found the following error.
This was caused by Java version on the system not matching the Java version in Tomcat. Check the current Java version in Windows by opening a command prompt and executing "Java - version". Then check the version in Tomcat by executing Tomcat#w.exe, where # is the Tomcat version number, located in the bin folder under your Tomcat install. Check the Java tab and check the entry for Java Virtual Machine. These are my settings with the corrected setting in Tomcat:

Monday, September 20, 2021

TSQL - Simple Recursive Example

I needed to change a field in a table that holds the tree structure for menues in Unit4 ERP. The fields involved were the parent_menu_id, menu_id, and client. So parent_menu_id would be the folder, menu_id would be the folders or menu item, and client is the field to be updated. The paren_menu_id at top of the tree is REP05. This is the update query.

WITH RecQry AS
(
    SELECT aagM.menu_id
      FROM aagmenu aagM where parent_menu_id = 'REP05'
    UNION ALL
    SELECT Child.menu_id
      FROM RecQry PARENT, aagmenu CHILD
        where CHILD.parent_menu_id = PARENT.menu_id
)
update aagmenu
set client = '*'
where menu_id in
(
select menu_id from RecQry
)

Monday, August 23, 2021

TSQL - Assign A Sequential Number To Each Record In A Group

I needed to insert records from one table into another table and add a sequential number, field seq, that was group on an id field, GroupId. This CTE was the eastiest way that I found to add the number.

UPDATE t
SET seq = GROUPSEQ
FROM (SELECT seq, [GroupId], row_number() OVER (PARTITION BY [GroupId] ORDER BY [GroupId]) GROUPSEQ
FROM [TableMemo]) t

Wednesday, August 18, 2021

TSQL - Add a Sequential Number Field

I needed to insert records from one table into another table and add a sequential number that started at a certain value. This was the eastiest way that I found to add the number. Just add an int field to the source table and add the values using an update. So in the following code, id was the int field that I created, and I add numbers begining with 6001.

DECLARE @id INT 
SET @id = 6000
UPDATE Table 
SET @id = id = @id + 1