Olá pessoal, não consigo achar o motivo do erro, preciso de uma grande ajuda de vocês, estou tentando executar o código abaixo e está ocasionando o seguinte erro:
public class CadastroEspecie extends JFrame {
private JTextField dtCadJT;
private JTextField descJT;
private JTextField codigoJT;
private JTextArea infoTA;
private static EntityManagerFactory
fabricaDeEntidades = null;
private static EntityManager gerenciador = null;
public CadastroEspecie() {
super();
setTitle("Cadastro de Espécie de Produto");
getContentPane().setLayout(null);
setBounds(100, 100, 497, 407);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final JComponent separator_1 = DefaultComponentFactory.getInstance().createSeparator("");
separator_1.setBounds(0, 100, 491, 9);
getContentPane().add(separator_1);
final JComponent separator_1_1 = DefaultComponentFactory.getInstance().createSeparator("");
separator_1_1.setBounds(0, 103, 491, 9);
getContentPane().add(separator_1_1);
final JButton salvarJB = new JButton();
salvarJB.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) {
Especie esp = new Especie();
Date dt = new Date();
SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
dtCadJT.setText(formato.format(dt));
esp.setDescJT(descJT.getText());
esp.setInfoTA(infoTA.getText());
esp.setDtCadJT(dtCadJT.getText());
gerenciador.getTransaction().begin();
gerenciador.persist(esp);
gerenciador.getTransaction().commit();
}
});
salvarJB.setToolTipText("Salvar");
salvarJB.setIcon(SwingResourceManager.getIcon(CadastroEspecie.class, "/Img/Botões Padrões/Salva.png"));
salvarJB.setContentAreaFilled(false);
salvarJB.setBorderPainted(false);
salvarJB.setBounds(108, 33, 52, 52);
getContentPane().add(salvarJB);
final JButton excluirJB = new JButton();
excluirJB.setToolTipText("Excluir");
excluirJB.setIcon(SwingResourceManager.getIcon(CadastroEspecie.class, "/Img/Botões Padrões/Excluir.png"));
excluirJB.setContentAreaFilled(false);
excluirJB.setBorderPainted(false);
excluirJB.setBounds(201, 33, 52, 52);
getContentPane().add(excluirJB);
final JButton SairJB = new JButton();
SairJB.setToolTipText("Sair");
SairJB.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) {
dispose();
}
});
SairJB.setIcon(SwingResourceManager.getIcon(CadastroEspecie.class, "/Img/Botões Padrões/Sair.png"));
SairJB.setContentAreaFilled(false);
SairJB.setBorderPainted(false);
SairJB.setBounds(374, 33, 52, 52);
getContentPane().add(SairJB);
final JButton pesquisarJB = new JButton();
pesquisarJB.setToolTipText("Pesquisar");
pesquisarJB.setIcon(SwingResourceManager.getIcon(CadastroEspecie.class, "/Img/Botões Padrões/Pesquisar.png"));
pesquisarJB.setContentAreaFilled(false);
pesquisarJB.setBorderPainted(false);
pesquisarJB.setBounds(18, 33, 52, 52);
getContentPane().add(pesquisarJB);
final JLabel codigoJL = new JLabel();
codigoJL.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
codigoJL.setText("Código:");
codigoJL.setBounds(17, 133, 37, 17);
getContentPane().add(codigoJL);
codigoJT = new JTextField();
codigoJT.setEditable(false);
codigoJT.setBounds(80, 133, 79, 20);
getContentPane().add(codigoJT);
descJT = new JTextField();
descJT.setBounds(80, 159, 400, 20);
getContentPane().add(descJT);
final JLabel infoJL = new JLabel();
infoJL.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
infoJL.setText("Informações:");
infoJL.setBounds(19, 185, 228, 17);
getContentPane().add(infoJL);
final JButton limparJB = new JButton();
limparJB.setIcon(SwingResourceManager.getIcon(CadastroEspecie.class, "/Img/Botões Padrões/Limpar.png"));
limparJB.setToolTipText("Limpar");
limparJB.setContentAreaFilled(false);
limparJB.setBorderPainted(false);
limparJB.setBounds(285, 33, 52, 52);
getContentPane().add(limparJB);
final JLabel dtCadJL = new JLabel();
dtCadJL.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
dtCadJL.setText("Data Cadastro:");
dtCadJL.setBounds(312, 354, 76, 17);
getContentPane().add(dtCadJL);
dtCadJT = new JTextField();
dtCadJT.setEditable(false);
dtCadJT.setBounds(394, 354, 87, 20);
getContentPane().add(dtCadJT);
descJT.requestFocus();
final JLabel descJL = new JLabel();
descJL.setFont(new Font("Arial Narrow", Font.PLAIN, 14));
descJL.setText("Descrição:");
descJL.setBounds(18, 161, 54, 17);
getContentPane().add(descJL);
setVisible(true);
setResizable(false);
setLocationRelativeTo(null);
final TextArea infoTA = new TextArea();
infoTA.setBounds(18, 208, 463, 141);
getContentPane().add(infoTA);
}
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
public static void main(String args[]) {
fabricaDeEntidades = Persistence.createEntityManagerFactory("conexao");
gerenciador = fabricaDeEntidades.createEntityManager();
CadastroEspecie frame = new CadastroEspecie();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="conexao">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>Especie</class>
<properties>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="postgres"/>
<property name="hibernate.connection.password" value="postgres"/>
<property name="hibernate.connection.url" value="jdbc:postgresql:TurmaN40"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.jdbc.use_scrollable_resultset" value="true"/>
</properties>
</persistence-unit>
</persistence>