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

How to update table using INNER JOIN in SQL Server 2008

CREATE TABLE [order] (in_order_id int, dt_updated datetime, bt_active bit)
CREATE TABLE [order_item] (in_order_id int, in_item_id int, dt_updated datetime, bt_active bit)

INSERT INTO dbo.[order] (in_order_id, dt_updated, bt_active) VALUES (101, GETDATE(), 1)
INSERT INTO dbo.[order] (in_order_id, dt_updated, bt_active) VALUES (102, GETDATE(), 1)
INSERT INTO dbo.[order] (in_order_id, dt_updated, bt_active) VALUES (103, GETDATE(), 1)
INSERT INTO dbo.[order] (in_order_id, dt_updated, bt_active) VALUES (104, GETDATE(), 1)
INSERT INTO dbo.[order] (in_order_id, dt_updated, bt_active) VALUES (105, GETDATE(), 1)

INSERT INTO dbo.[order_item] (in_order_id, in_item_id, dt_updated, bt_active) VALUES (101, 201, GETDATE(), 1)
INSERT INTO dbo.[order_item] (in_order_id, in_item_id, dt_updated, bt_active) VALUES (101, 202, GETDATE(), 1)
INSERT INTO dbo.[order_item] (in_order_id, in_item_id, dt_updated, bt_active) VALUES (102, 203, GETDATE(), 1)
INSERT INTO dbo.[order_item] (in_order_id, in_item_id, dt_updated, bt_active) VALUES (103, 204, GETDATE(), 1)
INSERT INTO dbo.[order_item] (in_order_id, in_item_id, dt_updated, bt_active) VALUES (104, 205, GETDATE(), 1)

SELECT * FROM dbo.[order]

UPDATE a SET a.bt_active = 0
FROM dbo.[order] a
INNER JOIN dbo.[order_item] b ON a.in_order_id = b.in_order_id
WHERE b.in_item_id = 204

[Above query will update [order] table where in_order_id is 103 as this order id has 204 item id in order_item table]

SELECT * FROM dbo.[order]

Complete database concept part-1

1. SQL Server 2008 Architecture
2. Physical Data base Files and Filegroups
3. Data Recovery Model
4. SQL Transaction Log Architecture
5. Truncating the Transaction Log
6. Log truncation occurs at these points
7. The size of a transaction log is therefore controlled in one of these ways
8. Shrinking the Transaction Log
9. Example Truncating / Shrinking the Transaction Log
10. Data base is in FULL Recovery Mode
11. Data base is in SIMPLE Recovery Mode
12. Micro Soft SQL Server 2008 Overview
13. System and User Data bases ( = Oracle Schema )
14. Micro Soft SQL Server 2008 Services
15. Referring Objects
16. Metadata ( Data Dictionary )
17. Micro Soft SQL Server 2008 Logon and Data base Access
18. Micro Soft SQL Server 2008 Query Designer
19. Micro Soft SQL Server 2008 Batch Utility ( osql )
20. SQL Server 2008 Programming Overview
21. Local Variables
22. Distributed Queries
23. Formatting Dates
24. CASE function ( similar to Oracle DECODE )
25. Dynamically constructing SQL statement's
26. Transactions
27. TOP SQL Queries
28. User Tables for specific Data base
29. Primary- and Foreign Key of Tables
30. Create and Manage Database
31. Database Property
32. Change a properties
33. How to create a Database
34. Information about Databases
35. SQL Data Structure
36. Database Recovery Model
37. Check Extents, Pages
38. Trace flags
39. How to take backup of a Database
40. How to restore a Database
41. How to create Table
42. SQL user defined data types
43. SQL BLOBS
44. Computed Column
45. How to generate column value with identity property of SQL
46. How to generate column value with NEWID function of SQL
47. How to create table in specified file group
48. How to generate transact-SQL script
49. Logged and Non-logged bulk copy script
50. About data integrity
51. SQL DEFAULT constraints
52. SQL CHECK constraints
53. SQL PRIMARY KEY constraints
54. SQL FOREIGN KEY constraints
55. What is DEFAULT object
56. What is RULE object
57. How to enable and disable constraints
58. SQL Table structure
59. SQL pages and extents
60. Heap and index allocation Map ( IAM )
61. SQL index structure
62. Non-SQL clustered indexes
63. SQL clustered indexes
64. Sysindex tables
65. How to verify the sysindex tables
66. Full table scan
67. SQL clustered index  with non-SQL clustered index
68. Page split in an index
69. Page splits do not occur in a heap
70. Determining of selectivity
71. Determining of table structure
72. Optimizer statistics
73. Manually creating statistics
74. How to create statistics for whole Database
75. View index statistics and evaluating index selectivity
76. SQL Views: creating views, Encrypt / Decrypt Views, Up-datable Views, Indexed Views
77. Stored procedures: Populate table with a stored procedure
78. Check Stored Procedure Property
79. How to Recompile all stored procedure, Trigger that reference to a table
80. How to use input parameters
81. How to return value using output parameter
82. How to process OUTPUT value and RETURN parameter
83. How to use last insert @@identity for Foreign Key columns
84. SQL custom message from stored procedure added into event log
85. SQL email interface
86. SQL extended stored procedure
87. SQL user defined functions
88. SQL scalar value user defined functions
89. SQL multi-statement table valued function
90. Trigger: INSERT Trigger, DELETE Trigger, UPDATE Trigger
91. Transact SQL Server example
92. Shrinking a Logfile
93. How to handle NULLs
94. Difference between COUNT( * ) and COUNT( 1 )
95. Is NULL values accepted in Foreign Key?

Some common questions to crack interview as fresher

1. Can we pass the values to reference types and vice-versa?

2. What is the difference between abstract class and interface?

3. 3-tier Architecture of any of your project.

4. What are value types and reference types?

5. Tell me something about yourself.

6. Example of value type and reference type?

7. What are datasets? Have you worked on that?

8. What is garbage collector?

9. What does acceptchanges() do in dataset?

10. MethodA with int I, value of i=10, print I, another method inherits MethodA, value of x changed in another function to 20, what will be value of i.

11. How gc works? Is there any algorithm or what?

12. What is shadowing?

13. There is a dataset? It has 6 rows like dr(1), dr(2), dr(3), dr(4), dr(5), dr(6). We have modified one row? Deleted another row? And Updated another row? How do we get to know these through code?

Some important questions to crack dot net interviews


******************** SET 1 ********************

1. What are indexes?

2. What is response.redirect and server.transfer?

3. Composite Key and Alternate Key?

4. Primary Key and Unique Key?

5. What are the limitations of indexes?

6. In datagrid how can we bind value of 1 column of combobox to another dataset?

7. What are transactions?

8. How many events are there in datagrid?

9. Difference between procedure and function?

10. What are user defined controls and custom controls?

******************** SET 2 ********************

1. What are exceptions?

2. What is constructor overloading?

3. What are events? Why we use them?

4. How we call exceptions?

5. Are interfaces classes or structures or what?

6. Can we override a constructor of a class?

7. What are interfaces?

8. Can we have abstract classes without abstract method?

9. How we can use interfaces?

10. What are abstract classes?

11. How we use events in .net?

12. Can we use public method of a static class?

13. How can we use static classes?

14. What are static classes? Why we use static classes?

15. What are generics?

16. When we use dispose and finalize? Are they called by default or by us?

17. What is difference between dispose and finalize?

18. What is garbage collector? How it works? On which algorithm it works?

19. What are threads? Have you used threads in your code?

20. What is .net framework? Architecture of .net framework?

21. What are generations in garbage collector?

22. How threads work?

******************** SET 3 ********************

1. What is memory management? How .net handles memory management?

2. OOPS. Encapsulation, abstraction, inheritance, interfaces?

3. Something about your projects?

4. What are the components of the .net framework?

6. What is .net framework?

7. Employee – manager query?5. What are indexes?

8. What is use of datareader?

9. Application architecture?

10. Why initial catalog is used in connection string?

11. What are CLR and CLS?

12. ASP.Net page life cycle?

******************** SET 4 ********************

1. How to create XML document from command prompt?

2. What does immutable means?

3. Are private variables inheritable?

4. What are delegates and multicast delegates?

5. Difference b/w system.string and system.text.stringbuilder?

6. What is assert() method? What it do?

7. What is garbage collector? When we call garbage collector?

8. What is difference b/w debug and trace?9. Text Trace listener. Where its output will go?

10. What is DLL Hell in .net?

11. What is an abstract class and interface? What is the difference b/w abstract class and interface?

12. What is Array.CopyTo() and Array.Clone()?

13. Does C# supports multiple inheritance?

14. What happens when value type is converted to reference type?

15. Different ways of method overloading?

16. How to deploy an assembly?

17. What is method overloading and method overriding?

******************** SET 5 ********************

1. Can validations be server side or only client side?

2. How ca we do the validations in ASP.Net?

3. How many languages .net support?

4. Difference b/w ASP and ASP.Net?

5. What is pagination? How can we do pagination?

6. What is smart navigation?

7. What are inetinfo.exe, aspnet_isapi.exe and aspnet_wp.exe?

8. How .net allows us to write code in any language it supports?

9. What is view state?

10. Difference b/w ADO and ADO.Net?

Software / Web developers quiz

Quiz 1: How to remove extra spaces (keep one space between two words) from string in C#?

Answer:

        string sString = "we are      software   developers who do not         compromise with quality";
        sString = sString.Replace(" ", "{}");
        sString = sString.Replace("}{", string.Empty);
        sString = sString.Replace("{}", " ");

Output: we are software developers who do not compromise with quality



Quiz 2: How to remove extra spaces (keep one space between two words) from string in SQL Server?

Answer:

DECLARE @vc_content varchar(100)

SET @vc_content = 'My    passion        is software development   in     asp.net'

SET @vc_content = REPLACE(@vc_content, ' ', '[]')
SET @vc_content = REPLACE(@vc_content, '][', '')
SET @vc_content = REPLACE(@vc_content, '[]', ' ')

SELECT @vc_content AS vc_content


Output: My passion is software development in asp.net


Quiz 3: How to check all constraints of a table using command in SQL Server??

Answer:

To check all constraints of a table use following command:

SP_HELPCONSTRAINT <Table Name>

EX: SP_HELPCONSTRAINT Employee