Translate

Installing multiple instances of apache tomcat server in single server

Create a new directory in “ C:\Program Files\Apache Software Foundation\Tomcat 6.0\ ” and rename it to master. This will be our master.

Copy conf, logs, temp, webapps and work directories from “ C:\Program Files\Apache Software Foundation\Tomcat 6.0 ” to master directories that we created above.

Modify the conf/server.xml files in “master” directory and change the ports so that all three ports are different on.

Go into the \bin directory of “master” directory and rename the files tomcat6w and tomcat6 to tomcat6masterw and tomcat6master

Open up a command prompt and go to the \bin directory of your new tomcat (master) and run following command. (Make sure to change the directories to match your environment)

“tomcat6Master //IS//Tomcat6Master -DisplayName = "Apache Tomcat 6 Master" -Install = "C:\Program Files\Apache Software Foundation\Tomcat 6.0\Master\bin\tomcat6Master.exe" -Jvm = auto -StartMode = jvm -StopMode = jvm -StartClass = org.apache.catalina.startup.Bootstrap -StartParams = start -StopClass = org.apache.catalina.startup.Bootstrap -StopParam = stop”

To control the new Tomcat server you can use the tomcat6masterw.exe program located in tomcat\bin we also see new services have created.

Run tomcat6masterw.exe and set the value for all tabs as existing Apache tomcat 6 Property. But file path will be newly created directory like “ C:\Program Files\Apache Software Foundation\Tomcat 6.0 ” will be “ C:\Program Files\Apache Software Foundation\Tomcat 6.0\master ”. Copy following setting and paste in Java option in java tab see below screenshot.

-Dcatalina.home = C:\Program Files\Apache Software Foundation\Tomcat 6.0

-Dcatalina.base = C:\Program Files\Apache Software Foundation\Tomcat 6.0\Master

-Djava.endorsed.dirs = C:\Program Files\Apache Software Foundation\Tomcat 6.0\Master\endorsed

-Djava.io.tmpdir = C:\Program Files\Apache Software Foundation\Tomcat 6.0\Master\temp

-Djava.util.logging.manager = org.apache.juli.ClassLoaderLogManager

-Djava.util.logging.config.file = C:\Program Files\Apache Software Foundation\Tomcat 6.0\Master\conf\logging.properties

Restart both tomcat service and Verify localhost: 8085. Mention port number that you have changed.

 

Function to get comma separated string as table in SQL Server


Following function will return comma separated string as a table:

CREATE FUNCTION [dbo].[util_fnc_comma_delim_to_table] (@vc_item_list varchar(MAX))
RETURNS
@tbl_parsed_list table (vc_text varchar(MAX))
AS
BEGIN
    DECLARE @vc_text varchar(100), @in_position int
   
    SET @vc_item_list = LTRIM(RTRIM(@vc_item_list))+ ','
    SET @in_position = CHARINDEX(',', @vc_item_list, 1)
   
    IF REPLACE(@vc_item_list, ',', '') <> ''
    BEGIN
        WHILE @in_position > 0
        BEGIN
            SET @vc_text = LTRIM(RTRIM(LEFT(@vc_item_list, @in_position - 1)))
            IF @vc_text <> ''
            BEGIN
                INSERT INTO @tbl_parsed_list (vc_text)
                VALUES (CAST(@vc_text AS varchar)) --Use Appropriate conversion
            END
            SET @vc_item_list = RIGHT(@vc_item_List, LEN(@vc_item_list) - @in_position)
            SET @in_position = CHARINDEX(',', @vc_item_list, 1)
        END
    END   
    RETURN
END

Use Following statement to check result:

SELECT * FROM dbo.util_fnc_comma_delim_to_table('1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15')

Example to get records from a table by using this function:

SELECT * FROM dbo.employee WHERE in_employee_id IN (SELECT * FROM dbo.util_fnc_comma_delim_to_table('1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15'))



Delete records from a table using JOIN in SQL Server

CREATE TABLE employees (in_employee_id int, dt_updated datetime, bt_active bit)
CREATE TABLE employees_salary (in_employee_id int, in_salary_id int, dt_updated datetime, bt_active bit)

INSERT INTO dbo.employees (in_employee_id, dt_updated, bt_active) VALUES (1, GETDATE(), 1)
INSERT INTO dbo.employees (in_employee_id, dt_updated, bt_active) VALUES (2, GETDATE(), 1)
INSERT INTO dbo.employees (in_employee_id, dt_updated, bt_active) VALUES (3, GETDATE(), 1)
INSERT INTO dbo.employees (in_employee_id, dt_updated, bt_active) VALUES (4, GETDATE(), 1)
INSERT INTO dbo.employees (in_employee_id, dt_updated, bt_active) VALUES (5, GETDATE(), 1)


INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (1, 1, GETDATE(), 1)
INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (1, 2, GETDATE(), 1)
INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (2, 3, GETDATE(), 1)
INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (3, 4, GETDATE(), 1)
INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (4, 5, GETDATE(), 1)
INSERT INTO dbo.employees_salary (in_employee_id, in_salary_id, dt_updated, bt_active) VALUES (5, 6, GETDATE(), 1)

SELECT * FROM dbo.Employees_salary

DELETE FROM a
FROM dbo.employees_salary a
INNER JOIN dbo.employees b ON a.in_employee_id = b.in_employee_id
WHERE a.in_employee_id = 1

[Note: above query will delete 2 records from employees_salary table having employee id 2]

SELECT * FROM dbo.Employees_salary