1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
package stock;
import javax.swing.*;
import java.sql.*;
import javax.swing.table.*;
class partition extends Thread {
DefaultTableModel mode15,mode16;
int j,i;
public Thread t=new Thread(){
public void run(){
Connection conn = null;
String url = "jdbc:mysql://localhost/facture";
String userName = "root";
String password = "ulysse";
String[] column2 = { "id","nom de famille" };
mode15 = new DefaultTableModel(column2, 0);
JTable jTable2 = new JTable(mode15);
i=0;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection(url, userName, password);
Statement instruction = conn.createStatement();
System.out.println("Connected");
String sql = " SELECT id3,fa from facture.famille ";
ResultSet resultat = instruction.executeQuery(sql);
while (resultat.next()) {
mode15.addRow(new String[] {"", "" });
jTable2.setValueAt(resultat.getString("famille.id3") ,i, 0);
jTable2.setValueAt(resultat.getString("famille.fa") ,i, 1);
i++;
}
}
catch (Exception g) {
System.out.println("ERREUR " + g);
}
}
};
public Thread t1=new Thread(){
public void run(){
Connection conn = null;
String url = "jdbc:mysql://localhost/facture";
String userName = "root";
String password = "ulysse";
String[] column3 = { "id","nom" };
mode16 = new DefaultTableModel(column3, 0);
JTable jTable3 = new JTable(mode16);
j=0;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection(url, userName, password);
Statement instruction = conn.createStatement();
System.out.println("Connected2");
String sql = " SELECT d,nom from facture.stock ";
ResultSet resultat = instruction.executeQuery(sql);
while (resultat.next()) {
mode16.addRow(new String[] {"", "" });
jTable3.setValueAt(resultat.getString("stock.d") ,j, 0);
jTable3.setValueAt(resultat.getString("stock.nom") ,j, 1);
j++;
}
}
catch (Exception g) {
System.out.println("ERREUR3 " + g);
}
}
};
} |
Partager