Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //a class for connectivity with de DB
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package hellonetcom;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class conecter {
- static Connection c;
- static Connection con(){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- c=DriverManager.getConnection("jdbc:mysql://localhost:3306/qcm", "root", "");
- }
- catch(SQLException e){}
- catch(ClassNotFoundException e){}
- return c;
- }
- }
- //form
- public remplissage1() {
- initComponents();
- // System.out.println(req);
- }
- void rempli(String enon,String choix,String auter,String dif,String tehm) {
- Connection c =conecter.con();
- try{
- Statement st = c.createStatement();
- req="INSERT INTO `quizz` VALUES ('"+ enon+"','"+choix+"','"+auter+"','"+dif+"','"+tehm+"')'";
- st.executeUpdate(req);
- }
- catch(SQLException e){
- System.err.println(e);
- }
- //when abutton clicked Data is getted from every textField
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String en= enoncé.getText();
- String ch=choix.getText();
- String au=auteur.getText();
- String dif=dif_niv.getText();
- String c=theme.getText();
- // rempli(en, ch, au, dif, ch);
- JOptionPane.showMessageDialog(rootPane, "ramplissage efectuer");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement