Spring load .property file and get

test.property [src/main/resource]
------------
#main
kk=directory/kk
main.wide=this/wide

----------spring

import java.io.InputStream;
import java.util.Properties;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;


@Component
@Scope("singleton")
public class PropertiesUtil {
private InputStream input;
private Properties properties ;


public PropertiesUtil() throws Exception{
properties=new Properties();
input = getClass().getClassLoader().getResourceAsStream(
"test.properties");
properties.load(input);
}
public String getProperty(String key){

return properties.getProperty(key);

};

}


SQL TABLE -MAPPING- FOREIGN KEY RELATION

CREATION & DROP




//Table-----------------Application---------
DROP TABLE IF EXISTS `myschema`.`application`;
CREATE TABLE  `myschema`.`application` (
 `APPLICATION_ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `APPLICATION_NAME` varchar(255) NOT NULL,
 `CREATED_AT` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY `APPLICATION_NAME` (`APPLICATION_NAME`),
  PRIMARY KEY (`APPLICATION_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


//Table-----------------service-------------
DROP TABLE IF EXISTS `myschema`.`service`;
CREATE TABLE  `myschema`.`service` (
 `SERVICE_ID` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `SERVICE_NAME` varchar(255) NOT NULL,
 `CREATED_AT` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY `SERVICE_NAME` (`SERVICE_NAME`),
  PRIMARY KEY (`SERVICE_ID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;



//--Mapping Table------------App and Serv---

DROP TABLE IF EXISTS `myschema`.`service`;
CREATE TABLE `myschema`.`app_serv` (
  APPLICATION_ID int(11) unsigned NOT NULL,
  SERVICE_ID int(11) unsigned NOT NULL,
  SERV_ORDER int(11) DEFAULT NULL,
  PRIMARY KEY (APPLICATION_ID,SERVICE_ID),
  KEY FK_APP_ID (APPLICATION_ID),
  KEY FK_SER_ID (SERVICE_ID),
  CONSTRAINT FK_APP_ID FOREIGN KEY (APPLICATION_ID) REFERENCES application (APPLICATION_ID),
  CONSTRAINT FK_SER_ID FOREIGN KEY (SERVICE_ID) REFERENCES service (SERVICE_ID)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT & SELECT



//---insert---
INSERT INTO myschema.application(APPLICATION_NAME) VALUES ("my application");
INSERT INTO myschema.service(SERVICE_NAME) VALUES ("my service");

INSERT INTO myschema.app_serv(APPLICATION_ID,SERVICE_ID,SERV_ORDER) VALUES (1,1,1);

//---select----

SELECT * FROM myschema.application a;
SELECT * FROM myschema.service s;


SELECT * FROM myschema.app_serv ts;

Abstract class



  1. class that is declared using “abstract” keyword; 
  2. may or may not include abstract methods ( has no body)and concrete methods (methods with body) ;
  3. we can  not allowed to create object of Abstract class,
  4. An abstract class has no use until unless it is extended by some other class ,logic behind structuring inheritance property for project[animal-dog,cow].
  5. it provides partial abstraction only,100% abstraction - interface.
See --
Interface , 
abstraction VS interface 

Access Modifiers 2 – Static,Abstract,Final



Static- Variables are calling Class variables. These members belong to the class not to the object,means values of these variables are not part of the object state.creating its while initiating class, not instance .Final- 

Abstract - 

Final - variable is a constant; its value cannot be changed after its initialization.



Access Modifiers – Public, Private, Protected & Default


Public - This is the least restrictive,accessible to entire project;

Default - If no access modifier is specified in the declaration, accessible only within package,not accessible in other packages or sub packages;

Protected - Accessible to all classes in the package and to all sub-classes of its class in any package where this class is visible.

Private -This is the most restrictive accessibility modifiers. These members are accessible only with in the same class.