Exception Bubbling in Java

Exception Bubbling in Java

In java and modern OOPS language, an Exception moving from one method to other method is what we call as Exception Bubbling. In java, a method can call other method. The Called method can call one more method. These kinds of calling sequence continue and we can see all the methods in a call stack for a given point in time.

Read More

Method Level CAS (Code Access Security)

Example - CAS Method Level Security

The Method Level Security comes with different Security Actions and those are below:
1. Demand Action
2. Link Demand Action
3. Inheritance Demand Action
4. Deny Action
5. PermitOnly Action
6. Assert Action

The text boxes (Markers 1 & 2) will display the value of the environment variables UserName and SecTest. The two read buttons (Markers 3 & 4) try to read those environment variables and sets the retrieved values in the corresponding text boxes 1 and 2.

The Radio button options (Marker 5) invoke the methods which had applied with the corresponding security attributes. We are going to debug the methods by picking an option here (marker 5) and hitting the Read buttons.

The check box (Marker 6) is used to explain how the security actions like Deny and Demand are invoked through imperative method. One can use the same imperative style for other security actions as well.

Read More

SQL-CLR Function – Creating & Using it

Configure SQL CLR and Create Assembly using T-SQL - Refer Code Listing 2

First, database developers write the functions in Dotnet framework and then expose that via a DLL. The SQL server, then loads the DLL into DB engine and starts picking up functions exposed by it. In native SQL language, one can write functions, stored procedures, and triggers. In Dotnet framework, besides these, one can write custom Aggregate Functions and can even define own User-defined Types.

Using the Surface Area Configuration tool, one can ask SQL server to allow the injection of Dotnet Framework code in its core engine. This tool ships with the SQL Server installer. The below given steps show enabling the SQL-CLR integration via this tool.

Read More

Java Exception Multiple Catch Blocks

Try Block Raising Multiple Exceptions

We know that a try block in Java will have a matching catch block. Now, we see how to use multiple catch blocks. Have a look at the picture.

The picture shows there are three code snippets within the try block. Let us assume code snippet 2 depends on code snippet 1 and code snippet 3 depends on code snippet 2. We will also assume each code snippet has the possibility of one exception type. From the picture, we can assume the exception types are A, B and C.

Read More

Executing SQL Stored Procedure in ADO.Net

About-this-Ado.Net-Stored-Procedure-Example

In this example, we placed a multi-line text box control in the top portion of the sample application (Marked as 1) and this control shows the data returned by executing the stored procedure. The clear button (Marked as 2) will clear the current content in the multi-line text box. The button marked as 3 in the example executes the stored procedure listed in listing 1.1. Button marked as 4 is used to execute the stored procedure which accepts parameters (Listing 1.2).

Two text box items (Marked as 4 and 5) supply the parameters for the stored procedures in listing 1.2 and 1.3. The button marked as 7 in our example executes the stored procedure that has a return statement and accepts output parameters (Listing 1.3). The value received is shown in the labels marked as 8 and 9. That is all about this example application and you can see the video at the end of this article to see how it works.

Read More