pessoal tenho as seguintes classes:
public class Conexao{
static String status="";
public static Connection getConnection(){
Connection conn=null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://localhost/exec10?user=root&password=123456";
conn = DriverManager.getConnection(url);
status = "Conexao Realizada";
}catch (SQLException e){
status = e.getMessage();
}catch (ClassNotFoundException e){
status = e.getMessage();
}catch (Exception e){
status = e.getMessage();
}return conn;
}
public class TelaCadastroDepartamentos extends JFrame implements ActionListener{
public JLabel lblNome;
public JTextField jtNome;
public JTable jtCadastro;
public JButton btnInserir, btnRemover, btnAlterar;
public TelaCadastroDepartamentos() {
// painel com os dados
lblNome = new JLabel(" Nome :");
jtNome = new JTextField();
JPanel pGrid = new JPanel(new GridLayout(3, 2));
pGrid.add(lblNome);
pGrid.add(jtNome);
// painel com o cadastro
jtCadastro = new JTable();
JScrollPane pCadastro = new JScrollPane(jtCadastro);
// painel com os comandos
btnInserir = new JButton("Inserir");
btnRemover = new JButton("Remover");
btnAlterar = new JButton("Alterar");
JPanel pBotoes = new JPanel(new GridLayout(1, 3));
pBotoes.add(btnInserir);
pBotoes.add(btnRemover);
pBotoes.add(btnAlterar);
// painel do JFrame
this.setLayout(new BorderLayout());
this.getContentPane().add(pGrid, BorderLayout.NORTH);
this.getContentPane().add(pCadastro, BorderLayout.CENTER);
this.getContentPane().add(pBotoes, BorderLayout.SOUTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Cadastro de Departamentos");
this.setSize(640,480);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
}
}
como faço pra gravar dados no banco?
]