Ai está tudo, vou tirar o print do bd e postar aqui para vocês analizarem,
[code]package projetobiblioteca;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import javax.swing.*;
public class Principal extends javax.swing.JFrame {
String texto;
public Principal() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu3 = new javax.swing.JMenu();
jMenu5 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu6 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem7 = new javax.swing.JMenuItem();
jMenu7 = new javax.swing.JMenu();
jMenuItem8 = new javax.swing.JMenuItem();
jSeparator3 = new javax.swing.JPopupMenu.Separator();
jMenuItem9 = new javax.swing.JMenuItem();
jMenu8 = new javax.swing.JMenu();
jMenuItem10 = new javax.swing.JMenuItem();
jSeparator4 = new javax.swing.JPopupMenu.Separator();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem12 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem16 = new javax.swing.JMenuItem();
jMenuItem17 = new javax.swing.JMenuItem();
jMenuItem25 = new javax.swing.JMenuItem();
jMenuItem26 = new javax.swing.JMenuItem();
jMenuItem27 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenu9 = new javax.swing.JMenu();
jMenuItem18 = new javax.swing.JMenuItem();
jMenuItem19 = new javax.swing.JMenuItem();
jMenuItem20 = new javax.swing.JMenuItem();
jMenu10 = new javax.swing.JMenu();
jMenu11 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Observacoes", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
jButton1.setText("Lembrar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jLabel1.setText("ID");
jButton2.setText("Remover");
jButton3.setText("Atualizar");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
.addComponent(jButton3)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2)
.addComponent(jButton3))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jMenu1.setText("Arquivo");
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
});
jMenu3.setText("Cadastrar");
jMenu5.setText("Livro");
jMenuItem4.setText("Livro");
jMenu5.add(jMenuItem4);
jMenu5.add(jSeparator1);
jMenuItem5.setText("Autor");
jMenu5.add(jMenuItem5);
jMenuItem1.setText("Editora");
jMenu5.add(jMenuItem1);
jMenuItem2.setText("Estante");
jMenu5.add(jMenuItem2);
jMenu6.setText("Classe");
jMenuItem6.setText("Classe");
jMenu6.add(jMenuItem6);
jMenu6.add(jSeparator2);
jMenuItem7.setText("Gênero");
jMenu6.add(jMenuItem7);
jMenu5.add(jMenu6);
jMenu3.add(jMenu5);
jMenu7.setText("Aluno");
jMenuItem8.setText("Aluno");
jMenu7.add(jMenuItem8);
jMenu7.add(jSeparator3);
jMenuItem9.setText("Turma");
jMenu7.add(jMenuItem9);
jMenu3.add(jMenu7);
jMenu8.setText("Professor");
jMenuItem10.setText("Professor");
jMenu8.add(jMenuItem10);
jMenu8.add(jSeparator4);
jMenuItem11.setText("Disciplina");
jMenu8.add(jMenuItem11);
jMenu3.add(jMenu8);
jMenuItem12.setText("Instrumento");
jMenu3.add(jMenuItem12);
jMenuItem13.setText("Notebook");
jMenu3.add(jMenuItem13);
jMenuItem14.setText("Mídia");
jMenu3.add(jMenuItem14);
jMenu1.add(jMenu3);
jMenu4.setText("Alterar");
jMenuItem15.setText("Livro");
jMenu4.add(jMenuItem15);
jMenuItem16.setText("Aluno");
jMenu4.add(jMenuItem16);
jMenuItem17.setText("Professor");
jMenu4.add(jMenuItem17);
jMenuItem25.setText("Instrumento");
jMenu4.add(jMenuItem25);
jMenuItem26.setText("Notebook");
jMenu4.add(jMenuItem26);
jMenuItem27.setText("Mídia");
jMenu4.add(jMenuItem27);
jMenu1.add(jMenu4);
jMenuItem3.setText("Sair");
jMenu1.add(jMenuItem3);
jMenuBar1.add(jMenu1);
jMenu2.setText("Relatórios");
jMenu9.setText("Empréstimos");
jMenuItem18.setText("Atrasados");
jMenu9.add(jMenuItem18);
jMenuItem19.setText("Andamento");
jMenu9.add(jMenuItem19);
jMenuItem20.setText("Finalizados");
jMenu9.add(jMenuItem20);
jMenu2.add(jMenu9);
jMenuBar1.add(jMenu2);
jMenu10.setText("Sobre");
jMenuBar1.add(jMenu10);
jMenu11.setText("Ajuda");
jMenuBar1.add(jMenu11);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(314, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(177, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
texto = jTextField1.getText();
jTextArea1.setText(null);
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection dioney = (Connection) DriverManager.getConnection(“jdbc:mysql://localhost:3306/yago?user=root&passowrd=yago”);
Statement yago = (Statement) dioney.createStatement();
yago.executeUpdate(“insert into teste (teste) values (’”+texto+"’)");
JOptionPane.showMessageDialog(null, “OK”);
}
catch(Exception e){
System.out.println(“erro”);
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection dioney = (Connection) DriverManager.getConnection(“jdbc:mysql://localhost:3306/yago?user=root&password=yago”);
Statement yago = (Statement) dioney.createStatement();
ResultSet rst = yago.executeQuery(“select * from teste”);
while(rst.next()){
jTextArea1.setText("\r\n"+rst.getString(“idteste”)+" “+rst.getString(“teste”)+”");
}
}
catch(Exception a){
System.out.println(“Erro”);
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Principal().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu10;
private javax.swing.JMenu jMenu11;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;
private javax.swing.JMenu jMenu7;
private javax.swing.JMenu jMenu8;
private javax.swing.JMenu jMenu9;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem16;
private javax.swing.JMenuItem jMenuItem17;
private javax.swing.JMenuItem jMenuItem18;
private javax.swing.JMenuItem jMenuItem19;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem20;
private javax.swing.JMenuItem jMenuItem25;
private javax.swing.JMenuItem jMenuItem26;
private javax.swing.JMenuItem jMenuItem27;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JPopupMenu.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JPopupMenu.Separator jSeparator3;
private javax.swing.JPopupMenu.Separator jSeparator4;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}[/code]