将数据库表中的数据显示为2个jframes netbeans

时间:2018-01-05 18:55:01

标签: java netbeans jframe

我想将数据库表中的数据显示为2个jframe。我尝试做类似的事情,但它不起作用:

        String statut = introducereOrasPlecare.getText();

        String url = "jdbc:mysql://localhost:3306/aeroport";
        String user = "root";
        String password = "elev1Aa.";

        PreparedStatement myStmt = null;
        ResultSet rs = null;

        try{
            Connection myConn = DriverManager.getConnection(url, user, password);
            myStmt = myConn.prepareStatement("SELECT COUNT(z.nrzbor),  SUM(b.valoare)\n" +
"FROM Zboruri z INNER JOIN CUPOANE c ON(z.nrzbor=c.nrzbor) INNER JOIN Bilete b ON(c.nrbilet=b.nrbilet)\n" +
"WHERE z.de_la = ?;");
            myStmt.setString(1, statut);
            rs = myStmt.executeQuery();            
            String d = rs.getString("COUNT(z.nrzbor)");
            jTextField1.setText(d);
            String e = rs.getString("SUM(b.valoare)");
            jTextField2.setText(e);
        }
        catch(Exception e){
            System.err.println("Got an exception!");
            System.err.println(e.getMessage());
        }
    }

有人能帮帮我吗?

0 个答案:

没有答案