The middle class work to earn, the rich work to learn

Below Article its really good to improve my credibility and process of career Development. from lifehack.org

When you are young, work to learn, not to earn.
-Robert Kiyosaki

       The middle class are easily persuaded to change jobs when someone offers more money. The rich understand that working isn’t about the money, especially in the early years. It’s about developing the skills and traits you need to develop to become rich. That may mean working a sales job to better understand the world of selling. Or it could mean you work at a bank to better understand accounting. If you want to be rich, you should be working to learn the skills you need to become rich. Most rich people didn’t get there by earning a high salary.

Best info from lifehacks:

  1. 8 Ways to Train Your Brain to Learn Faster and Remember More – by Maria Brilaki – lifehack.org.

 

 

Add mysql connection in Eclipse

Add mysql connection in Eclipse

1.) Go to Window > Show view..>other.. > Data Source Explorer > Ok.

1.jpg

2.) Add new Connection – Data Source Explorer >  New…

2.jpg

 Use “Test Connection” button to make sure every thing is OK, then Finish.

3.) Check the DB tables at Database Connection.

3.jpg

Create your JPA project and entities – from mysql , EJB Project , using RAD IBM 8.5.1

Good Day!,

Create your JPA project and entities – from mysql ,  EJB Project , using RAD IBM 8.5.1 :

1.) First steps, create MySQL tables for Student System, My database name “fndong_work_db“.

use fndong_work_db;

create table STUDENT(
    Stud_ID INT NOT NULL AUTO_INCREMENT,
    Stud_fname VARCHAR(35) NOT NULL,
    Stud_lname VARCHAR(35) NOT NULL,
    Stud_Icnumber CHAR(12),
    Stud_comment VARCHAR (200),
    Stud_email VARCHAR (50),
    Stud_dateCreated DATE,
   PRIMARY KEY (Stud_ID)
) ENGINE=InnoDB;

create table STUDENT_COURSE(
    ID INT NOT NULL AUTO_INCREMENT,
    Stud_ID int not null,
    Stud_CourseID char(4),
    Stud_DateOfContact DATE,
    Stud_EndDate DATE,
    foreign key (Stud_CourseID) references COURSE(Stud_CourseID),
    foreign key (Stud_ID) references STUDENT(Stud_ID),
    PRIMARY KEY (ID,Stud_ID,Stud_CourseID)
)ENGINE=InnoDB;

create table COURSE(
    Stud_CourseID char (4),
    Stud_CourseName VARCHAR(50),
   PRIMARY KEY (Stud_CourseID)
)ENGINE=InnoDB;

create table STUDENT_GRADE(
    Stud_ID INT NOT NULL AUTO_INCREMENT,
    Stud_GradeID Char(4),
    Stud_CourseID char (4),
    Stud_DateOut DATE,
    Stud_GradeComment VARCHAR(200),
    foreign key (Stud_CourseID) references COURSE(Stud_CourseID),
    foreign key (Stud_ID) references STUDENT(Stud_ID),
    PRIMARY KEY (Stud_ID,Stud_GradeID)
)ENGINE=InnoDB;

2.) Insert data in the tables.

insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ROSMAN','ULU YAM','990211052112','','rosman@gmail.com ','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ALI','MOHKTAR','010211062114','','mohktar99@gmail.com','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ERIC','CANTONA','010211042112','','cantonamu_eric@gmail.com','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('AH MENG','LIEW','000211032111','','lewmeng22@gmail.com','2016-02-14');

insert into COURSE  (Stud_CourseID,Stud_CourseName) values ('ITUC','INFORMATION TECHNOLOGY'); 
insert into COURSE  (Stud_CourseID,Stud_CourseName) values ('ACUC','ACCOUNTANT');  
insert into COURSE  (Stud_CourseID,Stud_CourseName)  values ('BUUC','BUSINESS'); 
insert into COURSE  (Stud_CourseID,Stud_CourseName)  values ('ENUC','ENGINERING');

insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (1,'ITUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (2,'ITUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (3,'BUUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (4,'BUUC','2016-02-14','2019-02-14');

3.) Create  EJB project “studentEJB” and EAR file studEJBEAR.

4.jpg

4.) Create JPA Entity.

4.1.) Create package “com.fndong.entities”

4.2.) Right Click Project > Properties > Select “Project Facet” > Enable JPA.

5.jpg

5.) Create Entities from Table , Right Click Project > JPA Tools > Generate Entities from Tables…

6.jpg

6.) Select tables.

7.jpg

Next Button

8.jpg

Key Generator – Identity

9.jpg

7.) Generated automatically entities.

8.) Creating Session Bean and Bean Interface.

8.1.) Right Click ejbModule > New > Session Bean

10.jpg

8.2.) Add the Session Bean (Business Logic ) with Interface.

Session EJBs Implement Business Logic:
– Session beans implement business logic. A session bean instance serves one client at a time. There are two types of session beans: stateful and stateless.

11.jpg

9.) Structure Project EJB with Remote Client.

12.jpg

 

 

Creating example jax-ws Service Provider + ejb 3.1 + mysql + webSphere v7.0 + RAD v 8.0.2- part 2

Creating example jax-ws Service Provider + ejb 3.1 + mysql + webSphere v7.0 – part 2

1.) Create EAR file, at your Rational Application Development – RAD, right click  select New > Enterprise Application Project > Project name : “studEAR” > Finish

1ws2.png

2.) Create new Project EJB. New > Other > Java EE > Utility Project > Next > Project Name “studentEJB” >  Finish

14.png

3.)

 

 

 

RAD v7 IDE IBM – terminates unexpectedly due to out of memory exception…

  1. Issue: RAD OutOfMemory Exception, and terminated the RAD IDE.
  2. cause : The Java Virtual Machine executable listed in the eclipse.ini file that is used to start Rational Application Developer is jvm.dll instead of javaw.exe.

3. Solutions:

3.1. Open the eclipse.ini inside Path Program Files\IBM\SDP:
-vm
<your__RAD_directory>\jdk\jre\bin\j9vm\jvm.dll 

change to:

-vm
jdk\jre\bin\javaw.exe

 

notes – hibernate ORM Q & A part 1

> Notes – hibernate ORM Q & A

  1. Error on HQL – [Ljava.lang.Object; cannot be cast to com.fndong.entities.Users ?
 private static final String HQL_SELECT_USERS ="select u.uid , u.username,
 u.password from Users u";

public void getUsers(){
List<Users> list = null;
Query query = session.createQuery(HQL_SELECT_USERS);
list = (List<Users>)query.list();
 for(Users h: list){
                    System.out.println("username: " + h.getUsername());
                 }
}

Errors: Ljava.lang.Object; cannot be cast to com.fndong.entities.Users

1.1.) Solutions on Question No. 1 :

You are selecting u.username(which looks like a String), but you are trying to cast that String to your Bean class (Users.java). If you execute an HQL query with a single field, the returned list will contain objects of the type of that field, you are getting a list of String objects.

> If you want to select Bean objects, your query should look like this : CORRECT WAY if we want to cast with Bean

 private static final String HQL_SELECT_USERS ="select u from Users u";

How to generate age from date of Birth – (Java 8) – java.time.*

How to generate age from date of Birth – Java 8 – java.time.*

package unit.test.timejava8;

import java.time.LocalDate;
import java.time.Period;
/**
 * @author fndong
 * generate age from date of Birth Java 8 - java.time.*
 */
public class Java8TimeAge {
    public void getAge(){
      String dob = "1989-07-20";
      
      
     LocalDate localDate = LocalDate.parse(dob);
     LocalDate now = LocalDate.now();
     
     Period  period = Period.between(localDate,now);
        System.out.printf("%d years,%d months and %d days  old!\n",p.getYears(), p.getMonths(), p.getDays());
    }
    
    public static void main(String args[]){
        Java8TimeAge java8TimeAge = new Java8TimeAge();
        java8TimeAge.getAge();
    }
}

Output :

32 years,1 months and 2 days  old!

 

Vaadin – How to make Alignment combobox with button.

Good Day!

Title : Vaadin – How to make Alignment combobox with button.

1.The button are not align with combobox , where button are hanging on the top if we using HorizontalLayout , so my solution is using  GridLayout.

  • added with : grid.setComponentAlignment(btnSubmit,Alignment.BOTTOM_LEFT);

2. From Image  A to Image B.

3. Image A

howtosetalignthecomboboxandbutton2.jpg

To 

4. Image B

howtosetalignthecomboboxandbutton.jpg

5. The source Code.

protected void init(VaadinRequest request) {

final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

GridLayout grid = new GridLayout(3,1);
Button btnSubmit = new Button(“Submit“);
combofirst= createFirstComboSelect(); // state combobox
combosecond = createSecondComboSelect(); // district combobox
grid.setSpacing(true);
grid.setSizeFull();
grid.setSizeUndefined();
grid.addComponent(combofirst);
grid.addComponent(combosecond);
grid.addComponent(btnSubmit);
/***java.lang.IllegalArgumentException: Component must be added to layout before using setComponentAlignment() ***/
grid.setComponentAlignment(btnSubmit,Alignment.BOTTOM_LEFT);
layout.addComponent(grid);
}

6. Full source codes project can get from My Github.

 

 

How to starting using Compass.app to compile sass automatically

Good Day , Salam sejahtera( malay), Nama brita nuan (iban), Anih agah amu (bidayuh)!  ( Greeting sentence)

How to starting using Compass.app to compile sass automatically :

  1. Firstly download from this page – compass.app.
  2. After done download,  Run Compass-app.exe. You’ll see the gray icon on your windows bars.
  3. First Create your sass project , by right click on gray icon – compass.app.

compass_1.jpg

4. I have created my project with name – sass_project. Then compass.app will load a report.

compass_2.jpg

5. What the good about this software is , you can set your sass project with its config file.

compass_3.jpg

Selamat Mencuba!!