Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://www70.zippyshare.com/v/QXk4KBiU/file.html
- Botao adicionar
- try{
- Connection con;
- con = DriverManager.getConnection("jbdc:mysql://127.0.01/Nome_Banco","usuario","senha");
- String sql;//string para receber a script
- sql = "INSERT INTO cad_alunos(campo1,campo2,campo3)VALUES (?,?,?)";
- /*
- */
- PreparedStatement (sql);
- ps = con.prepareStatement(sql);
- ps.setString(1, jTextField2.getText());
- ps.setString(2, jTextField4.getText());
- ps.setString(3, jTextField6.getText());
- int res = ps.executeUpdate();
- if (res>0){
- JOptionPane.showMessageDialog(null, "Cadastro efetuado com sucesso");}
- else{
- JOptionPane.showMessageDialog(null, "falha no cadastro");}
- }
- catch (SQLException ex) //Se ocorrer algum erro uma mesangem e exibida.
- {
- JOptionPane.showMessageDialog(null, "SQLException: ");
- }
- }
- privad void
- try{
- Class.forName("com.mysql.jbdc.Driver");
- Connection con;
- con = DriverManager.getConnection("jbdc:mysql://localhost:3306/projeto_crud_java","root","1234");
- String sql;
- sql = "UPDATE cad_alunos set Nome = ?,Endereco=?,Bairro=?,CEP=?,Cidade=?,Estado=?,Fone=?,CEL=?,estadocivil=?,"
- + "Email=?,Obs=?,login = ? where ID_alunos = ?";
- PreparedStatement ps;
- ps = con.prepareStatement (sql);
- ps.setString(1, jTextFDield1.getText());
- ps.setString(2, jTextFDield2.getText());
- ps.setString(3, jTextFDield3.getText());
- ps.setString(4, jTextFDield4.getText());
- ps.setString(5, jTextFDield5.getText());
- ps.setString(6, jComboBox.getSlectedItem().toString());
- ps.setString(7, jTextFDield7.getText());
- ps.setString(8, jTextFDield8.getText());
- ps.setString(9, jTextFDield9.getText());
- ps.setString(10, jComboBox2.getSelectedItem().toString());
- ps.setString(11, jTextFDield11.getText());
- ps.setString(12, jTextFDield12.getText());
- ps.setString(13, jTextFDield13.getText());
- ps.setString(1, jTextFDield1.getText());
- int res = ps.executeUpdate();
- if (res > 0) {
- JOptionPane.showMessageDialog(null, "Alterado com sucesso");}
- else {
- JOptionPane.showMessageDialog(null, "Nenhum registro alterado");}
- } catch (SQLException ex)
- }
- JOptionPane.showMessageDialog(null, "SQLException: " + ex.getMessage () + "\nSQLState: + ex.getSQLState() + "\nVendorError: + ex.getErrorCode());
- }catch (ClassNotFoundException ex) {
- logger.getLogger(JFRCurso.Class.GetName()).log(Level.SEVERE,null, ex);
- }
- privad void
- try{
- Class.forName("com.mysql.jbdc.Driver");
- Connection con;
- con = DriverManager.getConnection("jbdc:mysql://localhost:3306/projeto_crud_java","root","1234");
- String sql = "Select * from cad_alunos Where ID_alunos =? ";
- PrepareStatement ps = con.prepareStatement (sql);
- ps.setString(1,jTextFDield1.getText());
- Result rs;
- rs = ps.executeQuery();
- if (rs.next()) {
- jTextFDield1.getText(""Nome));
- jTextFDield2.getText("Endereco"));
- jTextFDield3.getText("Cidade"));
- jTextFDield4.getText("Bairro"));
- jTextFDield5.getText(""));
- jComboBox1.setSelectedItem(rs.getString("Estado"));
- jTextFDield7.getText("Cep"));
- jTextFDield8.getText("Fone"));
- jTextFDield9.getText("CEL"));
- jTextFDield11.getText("Email"));
- jTextFDield11.getText("Obs"));
- } else{
- JOptionPane.showMessageDialog(null, "Registro nao encontrado");}
- }
- } catch (SQLException ex)
- {
- JOptionPane.showMessageDialog(null, "SQLException: " + ex.getMessage () + "\nSQLState: + ex.getSQLState()
- + "\nVendorError: + ex.getErrorCode());
- }catch (ClassNotFoundException ex) {
- Logger.getLogger(JFRCurso.Class.getName()).log(Level.SEVERE, null, ex);
- }
- http://www119.zippyshare.com/v/pcJvARiN/file.html
- https://www.youtube.com/watch?v=koDp-bTdVTk
- https://www.youtube.com/watch?v=8D-CEtWAgHk JAVA MOBILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement