Etapas já criadas:
[Code] Tela de Cadastro
<?xml version='1.0' encoding='UTF-8' ?> Cadastro <script type="text/javascript" src="js/script.js"></script>
</h:head>
<h:body id="Home">
<h:form id="f">
<h:panelGrid columns="2">
<f:facet name="header">
Dados Pessoais
</f:facet>
<h:outputLabel for="nome" value="Nome completo"/>
<h:panelGroup>
<h:inputText id="nome" value="" />
<h:message for="nome" style="font-size: 16px" />
</h:panelGroup>
<h:outputLabel value="Sexo"/>
<h:selectOneRadio value="">
<f:selectItem itemValue="M" itemLabel="Masc"/>
<f:selectItem itemValue="F" itemLabel="Fem"/>
</h:selectOneRadio>
<h:outputLabel for="rg" value="RG" />
<h:inputText id="rg" value="" />
<h:outputLabel for="cpf" value="CPF/CNPJ"/>
<h:panelGroup>
<h:inputText id="cpf" value=""/>
<h:message for="cpf" style="font-size: 16px"/>
</h:panelGroup>
</h:panelGrid>
<h:outputLabel value=""/>
<h:commandButton class="botao" value="Cadastrar" action="#{pessoaBean}"/>
</h:form>
</h:body>
[Code] Tela conexão com banco de dados
package src.mybook.model.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
-
@author tecnologia
*/
/Classe Singleton/
public abstract class DaoUtil {private Connection connect = null;
public Connection getConnection() throws SQLException, ClassNotFoundException{
if(connect == null){
String password = “MYBOOK”;
String user = “PI”;
String url = “jdbc:oracle:thin:@localhost:1521:XE”;
/Driver do banco de dados./
Class.forName(“oracle.jdbc.OracleDriver”);connect = DriverManager.getConnection(url,user, password); } return connect;
}
public void getFechaConnection() throws SQLException{
if(connect != null){
this.connect.close();
this.connect = null ;
}
}/DDL E DML/
public Statement getStatement() throws SQLException, ClassNotFoundException{
return this.getConnection().createStatement();
}/DML/
public PreparedStatement getPreparedStatement(String sql) throws SQLException, ClassNotFoundException{
return this.getConnection().prepareStatement(sql);
}
}
[Code] Tela de comando da inserção
package src.mybook.model.dao.entitydao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import src.mybook.model.dao.DaoUtil;
import src.mybook.model.entity.Pessoa;
import src.mybook.model.factory.ConexaoFactory;
/**
*
-
@author SRCF
*/
public class PessoaDAO extends DaoUtil{public PessoaDAO() {
super();
}public boolean inserir(Pessoa pessoa)throws ClassNotFoundException, SQLException{
String sql = “INSERT INTO PESSOA(IDPESSOA, NOME, SEXO, RG, CPFCNPJ)”
+ “VALUES(SQ_PESSOA.NEXTVAL, ?, ?, ?, ?)”;PreparedStatement comando = super.getPreparedStatement(sql); comando.setString(1, pessoa.getNome()); comando.setString(2, pessoa.getSexo()); comando.setString(3, pessoa.getRg()); comando.setString(4, pessoa.getCpfCnpj()); int ret = comando.executeUpdate(); return ret > 0;
}
}
[Code] Tela da classe
package src.mybook.model.entity;
import javax.annotation.ManagedBean;
public abstract class Pessoa {
private Integer idpessoa;
private String nome;
private String sexo;
private String rg;
private String cpfCnpj;
private Usuario ususario;
public Pessoa(Integer idpessoa, String nome, String sexo, String rg, String cpfCnpj, Usuario ususario) {
this.idpessoa = idpessoa;
this.nome = nome;
this.sexo = sexo;
this.rg = rg;
this.cpfCnpj = cpfCnpj;
this.ususario = ususario;
}
public Pessoa() {
}
public Integer getIdpessoa() {
return idpessoa;
}
public void setIdpessoa(Integer idpessoa) {
this.idpessoa = idpessoa;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public String getRg() {
return rg;
}
public void setRg(String rg) {
this.rg = rg;
}
public String getCpfCnpj() {
return cpfCnpj;
}
public void setCpfCnpj(String cpfCnpj) {
this.cpfCnpj = cpfCnpj;
}
public Usuario getUsusario() {
return ususario;
}
public void setUsusario(Usuario ususario) {
this.ususario = ususario;
}
}
sou iniciante.