Hi all,
I'm trying to insert data from index.xhtml into database derby using Facade pattern... My code can run but the data can not to import the database... I don't know what to do and how to do it?

Please help....

Here's my code:

index.xhtml:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>This is the program to add data of devices into Database</title>
</h:head>
<h:body>
<h2>This is the program to add data of devices into Database</h2>

<h:form>
<h:panelGrid columns="2">
Computer name:
<h:inputText id="#{id.COMPUTER_NAME}" value="#{indexBean.computerName}"/>

Department:
<h:inputText id="#{id.DEPARTMENT}" value="#{indexBean.department}"/>

CPU:
<h:inputText id="#{id.CPU}" value="#{indexBean.cpu}"/>

RAM:
<h:inputText id="#{id.RAM}" value="#{indexBean.ram}"/>

HDD:
<h:inputText id="#{id.HDD}" value="#{indexBean.hdd}"/>

CD Rom:
<h:inputText id="#{id.CD_ROM}" value="#{indexBean.cdRom}"/>

<h:commandButton action="#{indexBean.add()}" value="Add"/>
<h:commandButton action="#{indexBean.clear()}" value="Clear"/>

</h:panelGrid>
</h:form>
.........

IndexBean.java:
package web;

import data.service.DataDevicesFacade;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;

@Named(value = "indexBean")
@RequestScoped
public class IndexBean {

@EJB DataDevicesFacade dataDevicesFacade;
private String computerName;
private String department;
private String cpu;
private String ram;
private String hdd;
private String cdRom;

public void add() {
dataDevicesFacade.insertData(); -------> This is my problem!
}

public void clear() {
computerName = department = cpu = ram = hdd = cdRom = null;
}

//--------------------------------------------------------
public String getComputerName() {
return computerName;
}

public void setComputerName(String computerName) {
this.computerName = computerName;
}

public String getDepartment() {
return department;
}

public void setDepartment(String department) {
this.department = department;
}

public String getCpu() {
return cpu;
}

public void setCpu(String cpu) {
this.cpu = cpu;
}

public String getRam() {
return ram;
}

public void setRam(String ram) {
this.ram = ram;
}

public String getHdd() {
return hdd;
}

public void setHdd(String hdd) {
this.hdd = hdd;
}

public String getCdRom() {
return cdRom;
}

public void setCdRom(String cdRom) {
this.cdRom = cdRom;
}

DataDevicesFacade:
package data.service;

import data.entity.DataDevices;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class DataDevicesFacade extends AbstractFacade<DataDevices> {
@PersistenceContext(unitName = "Q8_AddDataDevicesToDatabasePU")
private EntityManager em;

@Override
protected EntityManager getEntityManager() {
return em;
}

public DataDevicesFacade() {
super(DataDevices.class);
}

public void insertData() { ======> I think maybe I'm wrong with this method??
em.createNativeQuery("INSERT INTO Q8_AddDataDevicesToDatabase(computerName, department, cpu, ram, hdd, cdRom) "
+ "VALUES(computerName,department,cpu,ram,hdd,cdRom) ");
}
}

DataDevices.java:
package data;

import data.entity.DataDevices;
import data.service.DataDevicesFacade;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.sql.DataSourceDefinition;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;

@DataSourceDefinition(
serverName = "localhost",
portNumber = 1527,
databaseName = "Q8_AddDataDevicesToDatabase",
user = "Q8_AddDataDevicesToDatabase",
password = "Q8_AddDataDevicesToDatabase",
name = "java:global/jdbc/Q8_AddDataDevicesToDatabaseDS",
className = "org.apache.derby.jdbc.ClientDataSource",
properties = { "createDatabase=create" })
@Singleton
@Startup
public class DbPopulator {

@EJB private DataDevicesFacade dataDevicesFacade;
private DataDevices dataDevices = new DataDevices();

@PostConstruct public void init() {
dataDevicesFacade.create(dataDevices);
}

@PreDestroy public void clear() {
dataDevicesFacade.remove(dataDevices);
}
}

DbPopulator.java:
package data;

import data.entity.DataDevices;
import data.service.DataDevicesFacade;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.sql.DataSourceDefinition;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;

@DataSourceDefinition(
serverName = "localhost",
portNumber = 1527,
databaseName = "Q8_AddDataDevicesToDatabase",
user = "Q8_AddDataDevicesToDatabase",
password = "Q8_AddDataDevicesToDatabase",
name = "java:global/jdbc/Q8_AddDataDevicesToDatabaseDS",
className = "org.apache.derby.jdbc.ClientDataSource",
properties = { "createDatabase=create" })
@Singleton
@Startup
public class DbPopulator {

@EJB private DataDevicesFacade dataDevicesFacade;
private DataDevices dataDevices = new DataDevices();

@PostConstruct public void init() {
dataDevicesFacade.create(dataDevices);
}

@PreDestroy public void clear() {
dataDevicesFacade.remove(dataDevices);
}
}

Please help...
Thank you all....