import java.sql.*; import java.io.*; import java.awt.image.*; import java.awt.*; import java.applet.*; import java.awt.geom.*; public class Diagramm extends Applet{ public void paint(Graphics g){ try{ Class.forName("org.gjt.mm.mysql.Driver"); Connection cn=DriverManager.getConnection( "jdbc:mysql:/localhost/info", "", ""); Statement st=cn.createStatement(); String lause="SELECT mark, count(*) as kogus FROM autod group by mark;"; ResultSet rs=st.executeQuery(lause); int i=20; while(rs.next()){ i=i+75; g.setColor(new Color((int)(100+(155*Math.random())),(int)(100+(155*Math.random())), (int)(100+(155*Math.random())))); g.drawString(rs.getString("mark"), i, 40); g.fillRect(i, 50, 40, (rs.getInt("kogus")*20)); System.out.println("Baasis on "+rs.getString("mark")+"!"); System.out.println("Neid on baasis "+rs.getInt("kogus")+"!"); } }catch(Exception e){System.out.println("Jama");}; } public static void main(String argumendid[]){ Frame f=new Frame("Autoandmebaasi diagramm"); f.add(new Diagramm()); f.setSize(450, 250); f.setVisible(true); } }