Bonjour,
J'ai utilisé ce code pour trier une lise by time
package com.csv;
import java.sql.*;
import java.util.Properties;
import org.relique.jdbc.csv.CsvDriver;
public class ConCsv
{
public static void main(String[] args) throws Exception
{
Class.forName("org.relique.jdbc.csv.CsvDriver");
String id=null,time=null,origin=null,destination=null,load=null;
Properties props = new Properties();
props.put("fileExtension", ".txt");
Connection conn = DriverManager.getConnection("jdbc:relique:csv:C:\\csv", props);
Statement stmt = conn.createStatement();
ResultSet results = stmt.executeQuery("select * from requests order by time asc");
while(results.next()){
id=results.getString(1);
time=results.getString(2);
origin=results.getString(3);
destination=results.getString(4);
load=results.getString(5);
System.out.println("id "+id+" time "+time+" origin "+origin+" destination "+destination+" load "+load);
}
/* boolean append = true;
CsvDriver.writeToCsv(results, System.out, append);*/
conn.close();
}
}
et je travaille avec la plateforme jade de systeme multi agent lorsque je met ce code dans le comportement d'agent il s'a marche pas .
package com.csv;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import java.sql.*;
import java.util.Properties;
import org.relique.jdbc.csv.CsvDriver;
@SuppressWarnings("serial")
public class Coordinateur extends Agent {
protected void setup() {
{ addBehaviour(new CyclicBehaviour(this)
{
public void action() {
Class.forName("org.relique.jdbc.csv.CsvDriver");
String id=null,time=null,origin=null,destination=null,load=null;
Properties props = new Properties();
props.put("fileExtension", ".txt");
Connection conn = DriverManager.getConnection("jdbc:relique:csv:C:\\csv", props);
Statement stmt = conn.createStatement();
ResultSet results = stmt.executeQuery("select * from requests order by time asc");
while(results.next()){
id=results.getString(1);
time=results.getString(2);
origin=results.getString(3);
destination=results.getString(4);
load=results.getString(5);
System.out.println("id "+id+" time "+time+" origin "+origin+" destination "+destination+" load "+load); }
conn.close();}
}); }} }
si quelqu’un peux m'aider