Rss Feed Like Us on facebook Google Plus

May 31, 2024

Exploring Microservices Architecture with individual databases




- Each microservice embodies a specific business capability or functionality, ensuring a focused approach.

- Microservices operate independently, allowing for flexible and autonomous deployment.

- Examples of microservices include User Service, Order Service, and Inventory Service, among others.


Database Per Microservice:


- Each microservice is paired with its own dedicated database to promote data isolation, scalability, and autonomy.

- For instance, the User Service interacts with its User Database, while the Order Service manages its Order Database.


Interactions Between Microservices and Databases:


Read Operations:


- Microservices access data from their designated databases to perform operations effectively.

- When requiring user information, the User Service directly queries its User Database.


Write Operations:


- Microservices update data within their respective databases seamlessly.

- For instance, when a new user registers, the User Service efficiently inserts the user details into its User Database.


Database Connection Pooling:


- Maintaining connection pools ensures efficient management of database connections.

- Each microservice maintains a connection pool to minimize connection overhead and enhance performance.


Service-to-Service Communication:


- Microservices communicate using protocols such as HTTP/HTTPS for RESTful APIs and Message Queues for publish-subscribe.

- For example, the Order Service requests user information from the User Service API via an HTTP request, facilitating seamless data exchange.




Read More

June 10, 2017

Introduction of Asp.net WEB API

Introduction of WEB API

ASP.NET Web API is a framework for building http based services using .Net Framework. these services reach a broad range of clients, including browsers , mobile devices and desktop applications. 

Asp.net web-api is widely used to create Rest full Services but asp.net web api is not depend upon any constraint , we can create any type of services using asp.net web-api.

Restful Services 

REST (Representational State Transfer) is an architectural pattern of creating services , it specifies set of constraints
and these constraints should be followed by restful services 

REST Constraints

  1. Client Server
  2. Stateless
  3. Cacheable
  4. Uniform Interface
    HATEOS (Hypermedia as the engine of application state)
  5. Layered System
  6. Code on Demand (optional)



Read More

June 28, 2016

Convert UTC Time to specific Time-Zone on SQL

Convert UTC Time to specific Time-Zone on SQL


CREATE FUNCTION [dbo].[ConvertDatewithZoneOffset]
(
 @DateTimeStamp DATETIME,
 @TimeZoneOffset VARCHAR(20)
)
RETURNS DATETIME
AS
BEGIN
 RETURN CONVERT(DATETIME, 
               SWITCHOFFSET(CONVERT(DATETIMEOFFSET, 
                                    DATEADD(hh, DATEDIFF(hh, GETDATE(), GETUTCDATE()), @DateTimeStamp)),@TimeZoneOffset)) 
END
Read More

Why is null not allowed for DateTime in C#?

DateTime is a value-type (struct), where-as string is a reference-type (class etc). That is the key difference. 

A reference can always be null; a value can't (unless it uses Nullable<T> - i.e. DateTime?), although it can be zero'd (DateTime.MinValue), which is often interpreted as the same thing as null 


C# that causes null DateTime error

using System;

class Program
{
    static void Main()
    {
 DateTime current = null;
    }
}

Results

error CS0037: Cannot convert null to 'DateTime'
because it is a non-nullable value type

Read More

Find dependency of a particular object with all procedures/Objects of a database

There are various methods to finds the dependent objects , there is a system defined procedures sp_depends but it does not give perfect result always as it give results on the basis of creation order, more accurate ways are below

If we need to find paymentdetail table dependency on procedures/objects ,then  query

will be

FIND Dependency 

SELECT DISTINCT so.name
FROM sys.syscomments sc
INNER JOIN sys.sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%paymentdetail%'

OR

SELECT referencing_schema_name, referencing_entity_name,
referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('dbo.First', 'OBJECT');



FIND Text in Procedures

select name  from sys.procedures
where OBJECT_DEFINITION(OBJECT_ID) like '%paymentdetail%'



Read More

January 22, 2015

Different types of SQL Keys : Key Constraints

Basically only Primary keys and foreign keys are two types of constraints that can be used to
enforce data integrity in SQL Server tables. These are important database objects. Others are the Database Concepts, these are also used to create relationship among different database tables or views.

Types of SQL Keys

We have following types of keys in SQL which are used to fetch records from tables and to make relationship among tables or views.

Super Key

Super key is a set of one or more than one keys that can be used to identify a record uniquely in a table.Example :Primary key, Unique key, Alternate key are subset of Super Keys.

Candidate Key(Surrogate Key)

A Candidate Key is a set of one or more fields/columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as Primary Key.

Primary Key

Primary key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It can not accept null, duplicate values. Only one Candidate Key can be Primary Key.

Alternate key

A Alternate key is a key that can be work as a primary key. Basically it is a candidate key that currently is not primary key.


Composite/Compound Key

Composite Key is a combination of more than one fields/columns of a table. It can be a Candidate key, Primary key.

Unique Key

Unique key is a set of one or more fields/columns of a table that uniquely identify a record in database table. It is like Primary key but it can accept only one null value and it can not have duplicate values. 

Foreign Key

Foreign Key is a field in database table that is Primary key in another table. It can accept multiple null, duplicate values. 

Check also:

Read More

November 5, 2014

Bypass the runonce web page to save Internet Explorer settings

IE7 changes my home page to http://go.microsoft.com/fwlink/?LinkId=74005


Solution 1 :
If Below Registry Exists then Change Values for these Registries to 1

KeyName: RunOnceHasShown
KeyType: REG_DWORD
KeyValue: 1


KeyName: RunOnceComplete
KeyType: REG_DWORD
KeyValue: 1


Solution 2 :
If Registry not Exists then Create these registries with same above configuration.

Problem Summary :
After installing Internet Explorer 7 all users are supposed to save their settings, the IE automatically redirects the page to "http://go.microsoft.com/fwlink/?LinkId=74005" which redirects to "http://runonce.msn.com/runonce2.aspx" till the user saves the settings to set their preferences such as the default search engine, whether turn on automatic Phishing Filter, language settings and so on.

If the customer does not want to be auto-directed to this web page, then they need to follow the below steps. Two values should be added/modified in the registry, so that IE 7 will go to the home page instead of the external link above:

1. Goto Run and Type regedit and press Enter.
2. Go to registry key:
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
3. Right-click this key and select New -> DWORD Value.
4. On the right pane, create the new value to RunOnceComplete.
5. Right-click RunOnceComplete and click “Modify” and set the value data to 1.
6. Repeat Step 3 to Step 5 to create/modify the value name RunOnceHasShown and set the value data to 1.
7. Restart the IE 7 to see if it still visits the Save settings web site.

If you are familiar with using .REG files, then you can use what’s below to create one and use:

Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"RunOnceComplete"=dword:00000001
"RunOnceHasShown"=dword:00000001

Note: IE7 will query the two values RunOnceComplete and RunOnceHasShown every time it starts. If these values have been set as depicted above, IE will visit the home page set in the IE control panel.
Read More

November 3, 2014

How to change password of wi-fi Router

  • Open Internet Explorer and type the 192.168.2.1 (Router Default IP)  and press enter.
  • You will be prompted to login panel, use admin as username and password:
 

After Login Router DashBoard will open
  •  Go to Wireless Tab and then wireless security under wireless.
     

  • After changing password click on Save Settings and after that it will prompt Settings Saved Successfully and then close the browser. your password has been changed
Read More

October 8, 2014

Outlook attachment is not open. Error: Permission not defined

Solution


Outlook 2003
If you are using Outlook 2003, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Outlook 2007
If you are using Outlook 2003, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ (Directory Which is created) and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Outlook 2010 
If you are using Outlook 2010, follow these steps:
  1. Click My Computer, and then double-click drive C.
  2. On the File menu, click New, and then click Folder.
  3. Name the folder temp0.
  4. Click Start, click Run, type regedit, and then click OK.
  5. Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security\
  1. In the right pane, double-click OutlookSecureTempFolder.
  2. In the Value Data field, type C:\temp0\ and then click OK.
  3. Exit Registry Editor.
  4. Restart the computer.
Read More

September 16, 2014

Get Mobile Number of Sim Card on Android Device

You can use the TelephonyManager to do this:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String number = tm.getLine1Number();
The documentation for getLine1Number() says this method will return null if the number is "unavailable", but it does not say when the number might be unavailable.
You'll need to give your application permission to make this query by adding the following to your Manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
(You shouldn't use TelephonyManager.getDefault() to get the TelephonyManager as that is a private undocumented API call and may change in future.)





Example

Activity Class Look Like This

Class
GetMyPhoneNoActivity 
package com.kns;
 
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
 
public class GetMyPhoneNoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
    
        String number =getMyPhoneNO();
        Toast.makeText(getApplicationContext(), "My Phone No is: "
        +number, Toast.LENGTH_SHORT).show();
        Log.v("Debug", number);        
    }
    
    private String getMyPhoneNO(){
     TelephonyManager mTelephonyMgr;  
     mTelephonyMgr = (TelephonyManager) getSystemService
       (Context.TELEPHONY_SERVICE);   
 
     String yourNumber = mTelephonyMgr.getLine1Number();
  return yourNumber; 
    }     
}

Permission in Manifest File
<uses-permission android:name="android.permission.READ_PHONE_STATE">
</uses-permission>


Read More

August 1, 2014

Recover SQL Server Database from Suspect Mode

If your Database goes to Suspected Mode you can try below queries to retrieve the database in normal mode.

Reason for database to go into suspect mode:
1.    Data files or log files are corrupt.
2.    Database server was shut down improperly
3.    Lack of Disk Space
4.    SQL cannot complete a rollback or roll forward operation.

  1. Open SQL Server Management Studio 
  2. Open new query window and execute some queries:

    • use master
    • Alter Database TestDataBase Set Emergency
    • ALTER DATABASE TestDataBase  SET SINGLE_USER
    • DBCC CHECKDB (TestDataBase , REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
    • ALTER DATABASE TestDataBase SET MULTI_USER
    • ALTER DATABASE TestDataBase SET ONLINE
    • SELECT STATE_DESC FROM SYS.DATABASES WHERE NAME='TestDataBase'
  3. If all queries executed successfully, then database is recovered from suspected mode (some data may be loss after completion of this process. Ask the store to do PI after this process.).
Refresh your database server and verify the connectivity of your database. Now users should be able to connect to the database properly.

Read More

© 2011-2016 Techimpulsion All Rights Reserved.


The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.