Erreur code java

Résolu
futur ingenieure Messages postés 185 Statut Membre -  
 beber005 -
Bonjour,

SVP je suis entrain de coder une classe nommée SimpleTableDemo

je ne sais pas de quoi s'agit il cette erreur?
Pouvez vous m'aider?

11 mai 2011 00:07:55 javaapplication1.SimpleTableDemo createAndShowGUI
GRAVE: null
java.sql.SQLFeatureNotSupportedException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.mysql.jdbc.SQLError.notImplemented(SQLError.java:1274)
at com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1154)
at javaapplication1.SimpleTableDemo.<init>(SimpleTableDemo.java:62)
at javaapplication1.SimpleTableDemo.createAndShowGUI(SimpleTableDemo.java:127)
at javaapplication1.SimpleTableDemo.access$100(SimpleTableDemo.java:28)
at javaapplication1.SimpleTableDemo$2.run(SimpleTableDemo.java:150)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 2 seconds)



Merci énormément d'avance

4 réponses

  1. sakoba2010 Messages postés 165 Statut Membre 15
     
    L'erreur c'est à ce niveau:
    Object[][] data =null; 
    .

    Essayez ça:
    Object[][] data =new Object[rowCount/*Le nombre de ligne dans votre table*/][columnNames.length]
    .
    1
  2. beber005
     
    Salut,

    Peux tu nous montrer ton code stp
    0
  3. futur ingenieure Messages postés 185 Statut Membre 1
     
    Bonjour berber005

    oui avec plaisir
    merci énormément

    import com.mysql.jdbc.*;
    import java.sql.SQLException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.sql.DriverManager;
    import java.sql.ResultSet;

    public class SimpleTableDemo extends JPanel {
    // private boolean DEBUG = false;

    public SimpleTableDemo() throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
    super(new GridLayout(1,0));

    String[] columnNames = {"Videos","Information"};
    String username = "root";
    String password = "0000";
    Statement stmt;
    ResultSet rs;
    Class.forName("com.mysql.jdbc.Driver").newInstance();

    String url = "jdbc:mysql://localhost:3306/iptv";
    Connection conn = (Connection) DriverManager.getConnection(url, username, password);
    // System.out.println("OK connexion réussie...");

    String Vid ="forgiveMe"/* jTextField1.getText()*/;
    stmt = (Statement) conn.createStatement();
    rs = stmt.executeQuery("select * from videos where nomVideo='"+Vid+"'");
    // String name=rs.getString("nomVideo");
    ResultSetMetaData md = (ResultSetMetaData) rs.getMetaData();

    int columns = md.getColumnCount();
    int k=0;
    Object[][] data =null;
    System.out.println("testtt");
    while (rs.next()) {
    // ou ici int k=0;
    String inf="";
    for (int i=1; i<=columns;i++){
    System.out.println("testtttttttttttt");
    inf=inf+rs.getArray(i);

    }
    data[k][1]="image";
    data[k][2]=inf;
    System.out.println(data.toString());
    System.out.println("testttttt");
    k++;

    }

    // rs.close();
    // stmt.close();

    JTable table = new JTable(data, columnNames);//enlever final
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    /* if (DEBUG) {
    table.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
    printDebugData(table);
    }
    });
    }*/

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
    }

    /* private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();

    System.out.println("Value of data: ");
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + model.getValueAt(i, j));
    }
    System.out.println();
    }
    System.out.println("--------------------------");
    }*/

    /**
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    */
    private static void createAndShowGUI() {
    try {
    //Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    SimpleTableDemo newContentPane = new SimpleTableDemo();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(SimpleTableDemo.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    Logger.getLogger(SimpleTableDemo.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    Logger.getLogger(SimpleTableDemo.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
    Logger.getLogger(SimpleTableDemo.class.getName()).log(Level.SEVERE, null, ex);
    }
    }

    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {

    createAndShowGUI();

    }
    });
    }
    }
    0
  4. futur ingenieure Messages postés 185 Statut Membre 1
     
    c bon j'ai trouvé l'erreur
    c'était au niveau de l'instanciation de tableau data

    merci quand même
    0
    1. beber005
       
      Effectivement bien trouvé ;)
      0