0

I have to pull out data from MySQL database and I have to visualize those data in network format using Jung.

I have connected my program to MySQL database. But I don't know how to extract vertexes from database to Jung. Can anyone help me with this? Can I use Jung to visualize MySQL data?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Steffi Matchado
  • 134
  • 2
  • 10

1 Answers1

0

This is how I have extracted vertex and edges data from database

String query = "select x, y from table1 where column= 'r '";
        PreparedStatement pest = connection.prepareStatement(query);
        ResultSet rs = pest.executeQuery();
        while (rs.next()) {
            name1[i] = rs.getString("x");
            g.addVertex(name1[i]);
                name4[l] = rs.getString("y");
            System.out.println(name2[l]);
            if (name3[k] != null) {
                g.addVertex(name3[k]);

            } else
                g.removeVertex(name3[k]);
            i++;
            k++;
                        }
        for (k = 1; k < 20; k++) {

            if (name3[k] == null) {

                i = 1;                  
                i++;
                k++;
            } else {
                g.addEdge("G", name1[i], name3[k]);
            }
        }
        rs.close();
        pest.close();
Steffi Matchado
  • 134
  • 2
  • 10