/*
 * 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.*;

class Persone
{
 public static void main (String args [])
 {
  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://localhost/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");

    // Iterate through the result and print the employee names
    while (rset.next ())  {
      System.out.println   (rset.getString (1)+" "+rset.getString(2)+" "+
rset.getString(3)+" "+rset.getString(4)+" "+rset.getString(5));
    }
     

    // 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());
   }
  }
}
