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.


JEE : Login Form HTML - JS - MySQL



=======MYSQL=======
--Login---
C:\Program Files (x86)\MySQL\MySQL Server 5.6>mysql -u root -p
Enter password: ****     //root

mysql> CREATE DATABASE db;
Query OK, 1 row affected (0.00 sec)

mysql> USE db;
Database changed
mysql> CREATE TABLE user_table(username varchar(25),password varchar(25),secureno int);


//check table ----------
--Login---
C:\Program Files (x86)\MySQL\MySQL Server 5.6>mysql -u root -p
Enter password: ****     //root


//pointing db
mysql> USE db;

desc user_table;
///---Result-------
 +----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(25) | YES  |     | NULL    |       |
| password | varchar(25) | YES  |     | NULL    |       |
| secureno | int(11)     | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

//to know prot no


mysql> show variables;   //3306



//---------Imp--------- not used this resource to new forum site ,collected from
http://bigknol.com/open-blog/2013/07/eclipse-jee-development-tutorial/
,add mysql env variable screen shot also--------------------imp-------//


  • Prerequisite for JSP/MySQL Application with Eclipse JEE Kepler.

    JSP MySQL Eclipse JEE Development Kepler Tutorial

    Creating a database and Table using MySQL : Open cmd prompt (Windows+R and Type ‘cmd’) or use MySQL 5.5 Command line client. Change directory to MySQL Server 5.5 installed Path. (In this example path looks like : C:\mysql\MySQL Server 5.5\bin>)
    Create a new user in MYSQL Sever
    You can use root if you have super user privilege, or create a new user in MySQL, to create a new user:
     Login as a new user
    mysql –u nikisurf -p
    Create a new Database db and Selecting Database
     Create a new Table in MySQL called ‘info’
    eclipse jee development tutorial




    Open Eclipse
    Click eclipse.exe file from unzipped folder and set a workspace(location of projects)
    Create a new Dynamic Web Project
    File => New => Dynamic Web Project, and give Project name as ‘Info’ click Next
    again Next Finish.
    create kepler jee application








    Connect MySQL to JSP with Eclipse Kepler
    Add Library : MySQL Connector/j
    Unzip mysql-connector-java-5.1 and select mysql-connector-java-5.1.23-bin.jar file and drag and drop into the Project explorer of the Eclipse(info => WebContent => WEB-INF => lib).
    add mysql connection jee eclipse







    Start Coding
    Right Click on Info from Project Explorer => New => HTML File (Give Name as index.html)
    index.html
    Create a new JSP file : Right Click on Info from Project Explorer => New => JSP File (Give Name as add.jsp) Insert the codes between body tag of the document
    add.jsp
     Create delete.html
    delete.jsp
    show.html
    show.jsp
    Run JEE Eclipse Info Project
    To run tomcat server with Eclipse : Right Click on Info from Project Explorer =>Run as => Run on Server