#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Unhappy Ip pinging programm output results to tables


    Hello im stuck with my programm, I'm newbie at programming, but I have to finish this programm for my school project. I only use youtube tutorials, but in the end there is not enought info so im asking here for help.

    Basicaly what this programm does is take ip addreses from Database and pings them, if it fails to ping it displays ip address in one table if pingable it dispalys in other.I hope you understand what im trying to do here, and please don't say that my question is not clear, cause I dont think I can explain it better,its pretty hard cause I hardly understand programming language.

    Code:
    private void browseActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); File F = new File ("c:/"); File NameDir, NamePath; int Checker; chooser.setCurrentDirectory(F); chooser.setDialogTitle ("Choose db"); Checker = chooser.showOpenDialog(null);  if (Checker == JFileChooser.APPROVE_OPTION){ NameDir = chooser.getCurrentDirectory(); NamePath = chooser.getSelectedFile();  try {  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  String filename = NamePath.getAbsolutePath(); String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; database+= filename.trim() + ";DriverID=22;READONLY=true}"; Connection con = DriverManager.getConnection( database ,"","");  //I am using Access Database thats why all this connection code ^^  Statement s = con.createStatement(); s.execute("SELECT AgIP FROM Agents "); ResultSet rs = s.getResultSet(); if (rs != null) while ( rs.next()){ String sampleString = rs.getString(1); boolean reachable = false; reachable=(InetAddress.getByName(sampleString).isR eachable(1000));  if (reachable==true){ for (int i = 0;i <jTable1.getRowCount();i++){ //This place is not right for sure jTable1.getModel().setValueAt(sampleString, i, 0);  } } else{   for (int e = 0;e <jTable2.getRowCount();e++){ jTable2.getModel().setValueAt(sampleString, e , 0);  } } } } catch (Exception err) { System.out.println("ERROR: " + err); } } }
    Hope it is enough info.In picture I added there is explained deeper what im trying to achieve.Code would be realy appreaciated but any tips or help will bee good too.


    cant see img..
    http://img18.imageshack.us/img18/3705/programmk.jpg
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    realy need this


    Anyone?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    4
    Rep Power
    0
    pastebin (DOT) com/RgChtrkA

    URL to code that you can acually read.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by Gamerulf
    pastebin (DOT) com/RgChtrkA

    URL to code that you can acually read.
    thanks

IMN logo majestic logo threadwatch logo seochat tools logo