Create Cordova mobile App using IBM MobileFirst Foundation 8.0 + Eclipse Mars + Android v 5.1.1 + Node.js + Java 8

Create Cordova mobile App using IBM MobileFirst Foundation 8.0 + Eclipse Mars + Android v 5.1.1 + Node.js + jdk 8.

1.) Prerequisite.

1.1) MobileFirst Foundation Development Kit : Download
1.2) A Mars 2 Java EE version of Eclipse, or later. : Download
1.3)  Jdk version 8 : Download
1.4) Node.js version 4.x, or later. : Download
1.5) The Cordova command-line interface, version 6.1.1, or later.
1.6)  The IBM MFP Command Line Interface (CLI).
1.7) Android Version 5.1.1. (Just Download using eclipse Mars)

2) After Download MobileFirst Foundation Development Kit – take version 8.0, Installed.

  • To test the server MobileFirst Foundation 8.0, $ sh run.sh.

1.jpg

2.1.) Check the http://localhost:9080/mfpconsole/index.html#/dashboard

2.jpg

3) Install Eclipse Mars or later.

4) After Installed Eclipse Mars, get the IBM Mobilefist Plugin 8.0, Help > Eclipse MarketPlace..

3.jpg

5.) get Thym 2.0 Plugin, for developing Hybrid Mobile Application.

4.jpg

6.) After node.js installed, run the cordova  command-line on Windows:

  • checking node version
node -v
  • Installing cordova.

   npm install -g cordova

7.)  Add the plugin Android Development Tools.

5.jpg

7.1.) after added the ADT, make sure to installed Android 5.1.1 SDK.

6.jpg

8.) Add the The IBM MFP Command Line Interface (CLI) into node.js.

  • Command-line window, run the command: npm install -g mfpdev-cli.

9.) (Next tutorial) – Start creating a Cordova mobileFirst Project in Eclipse Mars 2.

 

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

 

 

Setting mysql jdbc in IBM Websphere v7.0 – web Appl. Server.

Setting mysql jdbc in IBM Websphere v7.0 – web Appl. Server.

1.png

1.) Right Click Resources > JDBC > JDBC providers, Choose your scope > Click New Button.

2.png

– Fill all the basic configuration.

  • Database Type : choose – User-defined
  • Implementation class name : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource 
  • Name : mysql provider

1.1.) Next > (please download  mysql-connector-java-5.1.7-bin.jar ) , and add in database classpath information

3.png

1.2.) Next > Finish.

4.png

1.3.) Create JDBC Datasource, Select Data sources, then choose your Cell scope and click New.

5.png

1.4.) Next > select an existing JDBC provider “myslq jdbc provider

6.png

  • Next >

 7.png

  • Next > Finish.

9.png

1.5.) Click “JAAS -j2c authentication data

10.png

1.6.) Click New – set the mysql connection.

11.png

1.7.) Create our database name in mysql command.

  • mysql command : create database fndong_work_db;

1.7.1.) add the database name in New – Custom Properties

12.png

1.8) Restart Your WebSphere Server.

1.9.) Test the mysql connection

 – Click JDBC > Data Source > Click- ” MYSQL_DataSource” and click Button Test Connection.

13.png

 

… Good Luck..

 

 

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.)

 

 

 

Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

1.) After you done doing my example on JAX-WS Server Part 1, you can create new Dynamic web project “jaxwsClientFirst” – for client part.

1.1.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client

9ws1.png

1.2.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client.

10ws1.png

Click on Browse Button of Service Definition and select the WSDL file of jaxwsServerFirst , Press Ok. Then set the target Location “com.fndong.client” > Next > Finish.

1.3.) Then it will generated java class automatically :

11ws1.png

1.4.) Open class SalaryImplService.java , inside the codes, change the URL to  :

url = com.fndong.client.SalaryImplService.class.getResource(“/WEB-INF/wsdl/SalaryImplService.wsdl”);

to

url = com.fndong.client.SalaryImplService.class.getResource(“http://localhost:9080/jaxwsServerFirst/SalaryImplService/SalaryImplService.wsdl”);

1.5.) This client jax-ws used WebSphere thin client jar for WebService Client. Right Click on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->

12ws1.png

Click on WebSphere Application Server v7.0. Click On Remove, and Press OK.

1.6.) Then add thin client jar , Right Click again on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->  Add External JARs > add three jars below.

  • com.ibm.jaxws.thinclient_7.0.0.jar
  • com.ibm.ws.admin.client_7.0.0.jar
  • com.ibm.ws.webservices.thinclient_7.0.0.jar

– click OK Button.

1.7.) Create a client program that invokes the server jaxwsServerFirst, by Creating new Client java class in the package com.fndong.client – “CalculateClient.java“.

 package com.fndong.client;

/**
 * @author fndong
 *
 */
public class CalculateClient {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         SalaryImplService service = new  SalaryImplService();
         SalaryService salaryService = service.getSalaryImplPort();
         double var1 = 2000;
         double var2 = 5000;
         double mysalary = salaryService.calculateSalaryAllowance(var1, var2);
         System.out.println("my salary : " + mysalary);       
    }

}

 

Create Simple Web Service JAX-WS – Server Part – RAD IBM – Websphere 7.0 + java 6

1). Create Simple Web Service JAX-WS – RAD IBM – Websphere 7.0 + java 6

1.1) Create your ear File first – Select New > Enterprise Application Project – “jaxwsServerEar” – Server Web Service  Part  1

1.2.) Create New Java Project – Select New > Dynamic Web Project– “jaxwsServerFirst

1ws1.png

1.3) create your Interface class with package. Create Package – com.fndong.service  / create your Class web Service “SalaryService” ( The interface will list calculate the salary and allowance)

package com.fndong.service;

import javax.jws.WebMethod;
import javax.jws.WebService;

/**
 * @author fndong
 *
 */
@WebService
public interface SalaryService {
     @WebMethod
     public int calculateSalaryAllowance(double salary, double allowance);
}
  • The @WebService annotation marks the WebServiceFirst class as implementing a web service, which results in a deployable web service being produced.
  • The @WebMethod

1.4.) Create implementation class to calculate Salary and Allowance – “SalaryImpl

package com.fndong.Impl;

import com.fndong.service.SalaryService;

/**
 * @author fndong
 *
 */
@WebService(endpointInterface="com.fndong.service.SalaryService")
public class SalaryImpl implements SalaryService {
     
    public double calculateSalaryAllowance(double salary, double allowance) {
         return salary + allowance;
}


}

1.5.) Create Web Service for the Implementation Class “SalaryImp” by right SalaryImp > Web Services> create WebServices

2ws1.png

  • Next > check the box – Generate WSDL file into the project.

3ws1.png

 

 

 

 

 

 

 

 

 

 

 

Next > Next > Finish

1.6.) The Class “SalaryImplDelegate.java” will generated automatically and also WSDL files. ( Check inside WebContent Folder)

4ws1.png

1.7.) The server started and test the result and also validate the WSDL.

5ws1.png

1.7.1.) check the WSDL document in the browser.

http://localhost:9080/jaxws/SalaryImplService?wsdl

6ws1.png

1.8.) Test with WebServices Explorer, just right click wsdl->WebServices->Test with WebServices Explorer

7ws1.png

1.9.) It will load the page in your RAD . You test the result of calculation between Salary and Allowance, for arg0 = 3000 and arg1 = 50 , Click Go Button, so the result at the Status – Body:

8ws1.png

Selamat Mencuba (malay languange)

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

 

JAX-WS/Axis2/CXF – WebService Notes:

  1. SOAP WebServices

2. What are difference between technology web Service JAX-WS, Axis2 and CXF ?

  • 2.1). JAX-WS
  • JAX-WS stands for Java API for XML Web Services.
  • JAX-WS is a technology for building web services and clients that communicate using XML.
  • JAX-WS allows developers to write message-oriented as well as RPC-oriented web services.
  • Java API for XML Web Services (JAX-WS), is a set of APIs for creating web services in XML format (SOAP).
  • In JAX-WS, a web service operation invocation is represented by an XML-based protocol such as SOAP.
  • The  SOAP specification defines the envelope structure, encoding rules, and conventions for representing web service invocations and responses. 
  • These calls and responses are transmitted as SOAP messages (XML files) over HTTP.

site: http://docs.oracle.com/javaee/5/tutorial/doc/bnayl.html

2.2). Axis2

  • Apache Axis2™ is a Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack.
  • There are two implementations of the Apache Axis2 Web services engine – Apache Axis2/Java and Apache Axis2/C
  • Apache Axis 2 is also a framework that now supports JAX-WS (up to JAX-WS 2). It’s an improvement from Apache Axis. CXF supports up to JAX-WS 1.2.

2.3). CXF

  • CXF has better integration with Spring, and Camel(camel-cxf). 
  • CXF is its implementation by Apache.
  • Apache CXF is a framework that implements JAX-WS to generate Web Services Definitions and Java Proxy (from a Web Service Definitions).

3.) Types of  JAX-WS

 

 

 

Hibernate Query Language – HQL

Hibernate Query Language – HQL  :

Description about HQL :-

  • HQL is the Object Oriented query language for Hibernate Framework.
  • HQL is a case-sensitive.
  • HQL with a simple and easy-to-use language.
    • While SQL use “SELECT * FROM USERS” to fetch all records in USERS table, But
    • for HQL we use “FROM USERS” .

1.) HQL Insert Query Language.

  • HQL also support INSERT INTO – example:
  • In HQL, only the INSERT INTO … SELECT … is supported; there is no INSERT INTO … VALUES. HQL only support insert from another table.
    • Query query = session.createQuery(“INSERT into USERS(userId, username)” + “SELECT bk.userId,bk.username FROM  BK_USERS bk“);

2.) HQL Update Query Language.

  • Example of HQL update query
 Transaction trans =session.beginTransaction();  
    Query query=session.createQuery("update Patient set PatientName=:pname where id=:pid");  
    query.setParameter("pname","franko Nando");  
    query.setParameter("pid",01);  
      
    int status=query.executeUpdate();  
    System.out.println(status);  
    trans.commit();