Bonjour à tous,

j'ai essayé plusieurs fois mais je n'y arrives.

J'arrive à accéder à ma base de données Access en Java, j'arrive à créer une table etc.

par contre je n'arrives pas à afficher un string venant de mon fichier LogInfo qui est dans un JTextArea.

Pouvez vous m'aider, il m'affiche toujours la même erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 
public void LogInfo(String txt) {
parent.txtLog.setText(parent.txtLog.getText() + "\n" + txt);
System.out.println(txt);
 
 
try {
writeLogDB(txt);
System.out.println("je passe dessus");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
 
 
public void writeLogDB(String txt) throws SQLException, ClassNotFoundException{
 
//Configuration SQL
Connection con;
Statement stm;
 
//Configuration Tables
String tableName = "logMyself";
String table0 = "logDate";
String table1 = "logHour";
String table2 = "logInfo";
 
//Configuration Colonnes
String loginfo_is = txt;
 
//Configuration DATE ET HEURE
SimpleDateFormat heures = null;
SimpleDateFormat dates = null;
Date aujourdhui = new Date();
Date aujourdhui1 = new Date();
heures = new SimpleDateFormat("k:mm:ss ");
dates = new SimpleDateFormat("MM/dd/yyyy ");
 
//LAncement Driver et FIchier
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\MSAccessProject/logMyself.mdb;DriverID=22; READONLY=false");
stm = con.createStatement();
 
// Création d'une table
if (con.equals(tableName) ){
String addTable = " CREATE TABLE " + tableName + " (" + table0 + " Date" + "," + table1 + " Time" + "," + table2 + " MEMO[3000] )";
stm.execute(addTable);
}
 
// Entrer de valeur
String addRow = "INSERT INTO " + tableName + " VALUES ( #" + dates.format(aujourdhui1) + "#,#" + heures.format(aujourdhui) + "# , + loginfo_is )";
stm.execute(addRow);
System.out.println("Info" + " "+ txt);
 
if (con != null) { con.close(); }
if (stm != null) { stm.close(); }
 
}