je veux assigner le resultat d'un sql dans un table, mais je reçoi une erreur!!!
voici mon code
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
public static void comboBox(){
  String[] table = new String[145];
  int i = 0;
  String country = "";
  String data = "jdbc:odbc:WorldEnergy";
      try {
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	Connection conn = DriverManager.getConnection(
	data, "", "");
	Statement st = conn.createStatement();
	ResultSet rec = st.executeQuery(
	"SELECT DISTINCT Country " +
	"FROM Coal " +
	//"WHERE " + 	"(Country='" + arguments[0] + "') " +
	"ORDER BY Country");
 
             While(rec.next()) {
	System.out.println(i + ":" + rec.getString(1));
	//country = rec.getString(1);
	table[i] = rec.getString(1);
	i++;
	}
 
             st.close();
	} catch (SQLException s) {
	   System.out.println("SQL Error: " + s.toString() + " "
	   + s.getErrorCode() + " " + s.getSQLState());
	} catch (Exception e) {
	   System.out.println("Error: " + e.toString()
	   + e.getMessage());
	}
	}



et voici l'erreur que ja sais, elle est sur la ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
table[i] = rec.getString(1);
0:Afghanistan
SQL Error: java.sql.SQLException: No data found 0 null