Monday, 12 October 2020

తెలుగు ఆన్‌లైన్ ట్యూషన్ & టీచింగ్

 తెలుగు ఆన్‌లైన్ ట్యూషన్ & టీచింగ్    70366 52816 

Syllabus         :    Preschool and  Class 1 to VII all subjects, VIII to X Physics. Board: SSC.

About Tutor   :   Msc(Physics), 2 years Experience in  teaching in Sri Chaitanya Jr college.  G :Female

Demo url        :   https://www.youtube.com/watch?v=rDNlZyHI_Lw&t=12s

నేను విద్యార్థులకు చాలా మంచి రీతిలో నేర్పుతాను. సహనంతో వివరించడంలో నాకు చాలా మంచి అనుభవం ఉంది.

పిల్లల్లాకు ఆన్‌లైన్ లో ఇంటరాక్టివ్ గా ఈజీగ అర్ధం అయ్యే  విధంగా చెప్పడానికి నేను రీసెర్చ్ చేస్తున్నాను.అవన్నీ ఫ్యూచర్ లో ప్రాక్టీకల్ గ అప్లై చేస్తాను.

Example: డిజిటల్ పాడ్ అండ్ పెండ్, ppt , డైరెక్ట్ స్క్రీన్ షేర్ విత్ MS OneNote మొదలైనవి


Monday, 9 March 2020

6 years exp java interview preparation-DataStructures

Liner search

for(i=0;i<n;i++){
if(a[i])== item)
print (i+1)

Binary Search

mid and -->
  1. import java.util.*;  
  2. public class BinarySearch {  
  3. public static void main(String[] args) {  
  4.     int[] arr = {161920234556789096100};  
  5.     int item, location = -1;  
  6.     System.out.println("Enter the item which you want to search");  
  7.     Scanner sc = new Scanner(System.in);  
  8.     item = sc.nextInt();  
  9.     location = binarySearch(arr,0,9,item);  
  10.     if(location != -1)  
  11.     System.out.println("the location of the item is "+location);  
  12.     else   
  13.         System.out.println("Item not found");  
  14.     }  
  15. public static int binarySearch(int[] a, int beg, int end, int item)  
  16. {  
  17.     int mid;  
  18.     if(end >= beg)   
  19.     {     
  20.         mid = (beg + end)/2;  
  21.         if(a[mid] == item)  
  22.         {  
  23.             return mid+1;  
  24.         }  
  25.         else if(a[mid] < item)   
  26.         {  
  27.             return binarySearch(a,mid+1,end,item);  
  28.         }  
  29.         else   
  30.         {  
  31.             return binarySearch(a,beg,mid-1,item);  
  32.         }  
  33.       
  34.     }  
  35.     return -1;   
  36. }  
  37. }  
===================


Bubble Sort

  1. int[] a = {1097101234412783423};  
  2.     for(int i=0;i<10;i++)  
  3.     {  
  4.         for (int j=0;j<10;j++)  
  5.         {  
  6.             if(a[i]<a[j])  
  7.             {  
  8.                 int temp = a[i];  
  9.                 a[i]=a[j];  
  10.                 a[j] = temp;   
  11.             }  
  12.         }  
  13.     }  
==============

Tuesday, 25 February 2020

6 years exp java interview preparation_Apache Camel and Apache Kafka

Apache Camel:

In an enterprise, a number of systems of different types exist. Some of these may be legacy systems while some may be new. These systems often interact with each other,and need to be integrated. This interaction or integration is not easy as the implementations of the systems, their message formats may differ. One way to achieve this is to implement code which bridges these differences. However this will be point to point integration. If tomorrow again if there is change in a system the other might also have to be changed which is not good. Instead of this point to point integration which causes tight coupling we can implement an additional layer to mediate the differences between the systems. This results in loose coupling and not affect much our existing systems. Apache Camel is a rule-based routing and mediation engine that provides a Java object- based implementation of the Enterprise Integration Patterns using an API (or declarative Java Domain Specific Language) to configure routing and mediation rules.




Apache Camel ™ is a versatile open-source integration framework based on known Enterprise Integration Patterns.

Camel empowers you to define routing and mediation rules in a variety of domain-specific languages, including a Java dsl, spring xml dsl.

Apache Camel uses URIs to work directly with any kind of Transport or messaging model such as HTTPActiveMQJMS,

Apache Camel is a small library with minimal dependencies for easy embedding in any Java application.

jms
Activemq
Wmq
Kafka
Rest
Direct synchronsus with in the contxt
Seda:àasynchronus with in the context.

Direc:vm: synch in another app context
Vm:asyn in another app context

Quartz
Time
Ftps secure ssl

File
Csv
To(http:// so  HTTP component.

From
To
Bean
Beanref
.inonly
.splitter:revierse of aggregator
.multicast
.aggregator
.loop

Errorhandler(Deadlear channel(“mock:error))

ProducerTemplate
ConsuermTemplate

========================


=====================
Kafka connect POC.


6 years exp java interview preparation_SpringRestApi

Rest Full services:
@RestController =@Controller+@ResponseBody

REST is used to build Web services that are lightweight, maintainable, and scalable in nature. A service which is built on the REST architecture is called a RESTful service. The underlying protocol for REST is HTTP, which is the basic web protocol. REST stands for REpresentational State Transfer.

Rest and SOAP
1. SOAP is a protocol where REST is an architectural style.
2.SOAP supports ony xml where as REST suppors both xml and Json.
3.SOAP server and client applications are tightly coupled and bind with the WSDL(web service definition lang)  contract. and need to register with UDDI (Universal Description, Discovery, and Integration) where in RSET no contract.
4.Learning curve is easy in REST when compared with SOAP.
5.REST web services request and response can be xml, json and text etc.. where as SOAP works with xml only.
6. JAX-RS is the java API for REST WEB SERVICES
 JAX-WS is the java api FOR SOAP WEBSERVICES or xml based webservices.


REST API Implementations

There are two major implementations of JAX-RS API.
  1. JerseyJersey is the reference implementation provided by Sun. For using Jersey as our JAX-RS implementation, all we need to configure its servlet in web.xml and add required dependencies. Note that JAX-RS API is part of JDK not Jersey, so we have to add its dependency jars in our application.
  2. RESTEasyRESTEasy is the JBoss project that provides JAX-RS implementation.



  1. POST – This would be used to create a new employee using the RESTful web service
  2. GET - This would be used to get a list of all employee using the RESTful web service
  3. PUT - This would be used to update all employee using the RESTful web service, if not there creates a new one.
  4. DELETE - This would be used to delete all employee using the RESTful web service
PUT actually replace the resource means means full update.

PATCH—do the partially upate the resource.

OPTIONS, -àinformatkon about communication the resoues.

Security:
by using HTTPS: SSL or OAuth.

PUT method is idempotent. So if you send retry a request multiple times, that should be equivalent to single request modification.

POST is NOT idempotent. So if you retry the request N times, you will end up having N resources with N different URIs created on server.

==============
CATEGORY
DESCRIPTION
1xx: Informational
Communicates transfer protocol-level information.
2xx: Success
Indicates that the client’s request was accepted successfully.
3xx: Redirection
Indicates that the client must take some additional action in order to complete their request.
4xx: Client Error
This category of error status codes points the finger at clients.
5xx: Server Error
The server takes responsibility for these error status codes.



200 (OK)




301 (Moved Permanently)


302 (Found)


400 (Bad Request)


401 (Unauthorized)


404 (Not Found)


405 (Method Not Allowed


405 (Method Not Allowed


405 (Method Not Allowed

9.2 OPTIONS

The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.

A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request. Of the request methods defined by this specification, PUT , DELETE , and safe request methods are idempotent

The HyperText Transfer Protocol (HTTP) 202 Accepted response status code indicates that the request has been received but not yet acted upon. It is non-committal, meaning that there is no way for the HTTP to later send an asynchronous response indicating the outcome of processing the request

The 504 Gateway Timeout error is an HTTP status code that means that one server did not receive a timely response from another server that it was accessing while attempting to load the web page or fill another request by the browser.
=================°


Difference between @RequestParam and @PathVariable


@RequestParam:
It uses query string like below
Http://localhost/getData?name=Prabhu&no=12

and in code

method(@RequestParam(value=name, required=true/false) String name),
@RequestParam(value=no, required=true) String no)

@PathVariable:
It uses query string like below

Http://localhost/getData/Prabhu/12

and in code

@RequestParam("/test/{name,no})

method@PathVariable(value=name)String name),
@RequestParam(value=no) Strino)




6 years exp java interview preparation_DataBase_Hibernate_jpa_SpringJpa

DataBase:


Connection pool:
Establishig a connection to the database before executing the sql quereis
instead of opening a connection every time and then connect to db and executing sql stmts and then closing it, We can use connection pooling which improves perpormance. Connection pooling  is a feature or service provieded by most of the applicaiton servers and webcontainers where in they create a set of or pool of connections and then our program (client) one of those connections can use of them.
for exmpll one servlet or one part is using one connection. 
other part or servlet can resuse the same thing once first part is done and put it back in pool.

to configure.
1) Copy the driver jar to tomcat/lib folder

2)Add the resource element to context.xml fle under tomcat/conf folder
<Resource name ="jdbc/mydb"
type= "javax.sql.DataSource"
username=""
password=""
driverClassName=""
url=""/>

So that JNDI (Java Naming and Directory Interface)

DataSoruce creates factory of connnections will put into the JNDI SERVER Using the name jdbc/mydb 

we can retryive data source in our program using JNDI  API by passing the "jdbc/mydb" 
If we give the name we  will get the JNDI  value object of datasource then we can say  ds.getconnection then it will get you one connection from the pool. datasourc e is a factory of connections. in this way we can improve performacne.






select Nth highest salary of an employee.


select name,salry from Employee e1
where N-1=(select count(disctinct salary) from Employee e2
where e2.salary>e1.salary)

SpringDataJPA:

sample example


Persistnace context

Sesssion s = sessionFactory.getSession();
tx=s.beginTransaction();
User u = s.get(User.class, 1L);

u.setName("updteName");.

User u2 =session.get(User.class, 1L)
updteName-->will be updated in DB





Hibernate Criteria Projections and restricitons
https://www.youtube.com/watch?v=DeBR9__zgRs



First Level Cache:

1 user 1 session hit s applicaiotn select query hits db and returns records and stores in First level cahce by default in Hibernate.

1 user or same session hits the same query again then, it will fetch from first level cache instead of hittign db.

2 user or 2 session hits the same query but it will again hit the db because it is different session.

Secondlevel Cache:
if we enable 2nd level cache in Hibernate , all sessions can use the second levle cache and fetch the data if the same query with out hitting the db. first time hits the db.

3 configs: 1. pom.xml hibenate-ehcache(os,swarm) 
                2. hib.conf.xml  need to enable 2nd level cache and say use ehcache
                3.  In Entiry we need to mention
                   @Cachable
                   @Cache (read or write stratagies)

ACID properties
A:Atomicity: Either to all stpes in transaction means complete transation or roll back if any problem in between.

C: Consistancy:  Before starting the operations in transation and After the all operations Total of those transation should be same.

I: Isolation: Transactions should know each other so that no insufficent balance error.

Durability: done all steps in Transaction and before saving it to disk power gone, we should maintain a durablity to store all transation detailsin in DISK, even this situation as well.




The dialect specifies the type of database used in hibernate so that hibernate generate appropriate type of SQL statements


Sr. No.Keysave()persist()
1
Basic 
 It stores object in database
It also stores object in database
2
Return Type 
It return generated id and return type is serializable 
It does not return anything. Its void return type. 
3
Transaction Boundaries 
It can save object within boundaries and outside boundaries 
It can only save object within the transaction boundaries 
4.
Detached Object 
It will create a new row in the table for detached object  
It will throw persistence exception for detached object 
5.
Supported by 
It is only supported by Hibernate 
It is also supported by JPA


All JPA-specific cascade operations are represented by the javax.persistence.CascadeType enum containing entries:
  • ALL
  • PERSIST
  • MERGE
  • REMOVE
  • REFRESH
  • DETACH
Cascading is about persistence actions involving one object propagating to other objects via an association. Cascading can apply to a variety of Hibernate actions, and it is typically transitive. The "cascade=..." attribute of the annotation that defines the association says what actions should cascade for that association.
Cascade = "all" means to apply all primary cascade types. As of Hibernate 5.3, these types are:
  • "delete" / "remove",
  • "detach" / "evict",
  • "merge",
  • "lock",
  • "persist",
  • "refresh",
  • "replicate",
  • "save_update" / "update"

@Transactional means
means


@Transactional
public void businessLogic() {
... use entity manager inside a transaction ...
}

UserTransaction utx = entityManager.getTransaction(); 

try { 
    utx.begin(); 
    businessLogic();
    utx.commit(); 
} catch(Exception ex) { 
    utx.rollback(); 
    throw ex; 
} 

@EnableTransactionManagement does exactly what it says: Enables Spring's annotation-driven transaction management capability, similar to the support found in Spring's XML namespace. Yes, you should still use @Transactional annotation on methods that you want to wrap in a transaction.