/*
 * This sample shows how to list all the names from the Persone table
 */

// You need to import the java.sql package to use JDBC
import java.sql.*;
import java.awt.*;
import java.applet.*;

public class PersoneApplet extends Applet {

TextArea ta = new TextArea("In attesa di connessione...",30,70);

public void init()
 {
setLayout(new BorderLayout());
    add("Center",ta);

  try {
    // Load the Mysql JDBC driver
    try {
      Class.forName("org.gjt.mm.mysql.Driver");
    } catch (ClassNotFoundException e) {
      System.out.println ("Mysql device driver does not exist");
      System.exit(1);
    }

    // Connect to the database
    // You can put a database name after the @ sign in the connection URL.
    Connection conn =
    DriverManager.getConnection ("jdbc:mysql://alboot.ba.infn.it/Persone?user=Persone&password=");

    // Create a Statement
    Statement stmt = conn.createStatement ();

    // Select the ENAME column from the EMP table
    ResultSet rset = stmt.executeQuery (" select ID, Cognome, Nome, Tel , Email,Homepage  from Persone");

    StringBuffer buf = new StringBuffer();

    // Iterate through the result and print the employee names
    while (rset.next ())  {
      buf.append   (rset.getString (1)+" "+rset.getString(2)+" "+
rset.getString(3)+" "+rset.getString(4)+" "+rset.getString(5)+"\n");
    }
    ta.setText(buf.toString()); 

    // Close the RseultSet
    rset.close();

    // Close the Statement
    stmt.close();

    // Close the connection
    conn.close();   
   } catch (SQLException e) {
      System.out.println("Error accessing DB ");
      System.out.println("  Error code is : "+e.getErrorCode());
      System.out.println("  Error message is :"+e.getMessage());
   }
  }
}
