Olá Gujers.
To tentando conectar minha tabela Swing com o Mysql, ja consegui conectar o BD ao Netbeans, tranquilo.
So que na hora de conectar a tabela com o BD, ele da erro
Segue o código abaixo
import com.mysql.jdbc.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TrabBancoEJTable extends javax.swing.JFrame {
/** Creates new form TrabBancoEJTable */
public TrabBancoEJTable() {
Conexao=new Conexao();
Connection conn=conexao.getConexao();
stmt=conn.createStatement();
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Código Gerado ">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
ResultSet rs = getResults();
jTable1.setModel(new TabelaModel(rs));
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(15, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(39, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TrabBancoEJTable().setVisible(true);
}
});
}
private ResultSet getResults() {
ResultSet rs=null;
try{
rs=stmt.executeQuery("Select * from livros");
}
catch(SQLException e){}
return rs;
}
// Declaração de variáveis - não modifique
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// Fim da declaração de variáveis
private Statement stmt;
private Conexao Conexao;
}
O ERRO TA AQUI :
cannot find symbol
location class TrabBancoEJTable
erro na linha
Connection conn=conexao.getConexao();
Valeu a força.