Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //a class for connectivity with de DB
  2.  
  3. /*
  4. * To change this template, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. package hellonetcom;
  8.  
  9. import java.sql.Connection;
  10. import java.sql.DriverManager;
  11. import java.sql.SQLException;
  12.  
  13.  
  14. public class conecter {
  15. static Connection c;
  16. static Connection con(){
  17.  
  18. try{
  19. Class.forName("com.mysql.jdbc.Driver");
  20. c=DriverManager.getConnection("jdbc:mysql://localhost:3306/qcm", "root", "");
  21.  
  22. }
  23. catch(SQLException e){}
  24. catch(ClassNotFoundException e){}
  25.  
  26. return c;
  27. }
  28.  
  29. }
  30.  
  31.  
  32.  
  33. //form
  34.  
  35. public remplissage1() {
  36. initComponents();
  37. // System.out.println(req);
  38. }
  39. void rempli(String enon,String choix,String auter,String dif,String tehm) {
  40. Connection c =conecter.con();
  41.  
  42.  
  43. try{
  44. Statement st = c.createStatement();
  45. req="INSERT INTO `quizz` VALUES ('"+ enon+"','"+choix+"','"+auter+"','"+dif+"','"+tehm+"')'";
  46. st.executeUpdate(req);
  47.  
  48. }
  49. catch(SQLException e){
  50. System.err.println(e);
  51.  
  52. }
  53.  
  54.  
  55. //when abutton clicked Data is getted from every textField
  56.  
  57. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  58.  
  59. String en= enoncé.getText();
  60. String ch=choix.getText();
  61. String au=auteur.getText();
  62. String dif=dif_niv.getText();
  63. String c=theme.getText();
  64. // rempli(en, ch, au, dif, ch);
  65.  
  66. JOptionPane.showMessageDialog(rootPane, "ramplissage efectuer");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement