// Inserting into, updating and searching through a database
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CadastroCliente extends JFrame {
   private ControlPanel controls;
   private ScrollingPanel scrollArea;
   private JTextArea output;
   private String url;
   private String username ;	
   private String password ;
   private Connection connect;
   private JScrollPane textpane;

   public CadastroCliente()
   {
      super( "Aplicacao Banco de Dados - Cadastro de Clientes" );

      Container c = getContentPane();

      // Start screen layout
      scrollArea = new ScrollingPanel();
      output = new JTextArea( 6, 30 );
      c.setLayout( new BorderLayout() );
      c.add( new JScrollPane( scrollArea ),
             BorderLayout.CENTER );
      textpane = new JScrollPane( output );
      c.add( textpane, BorderLayout.SOUTH );

      // Set up database connection
      try {
         url = "jdbc:odbc:Empresa";
		 username = "anonimo";	
		 password = "convidado";

         Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
         connect = DriverManager.getConnection( url, username, password );
         output.append( "Conectado com sucesso\n" );
      }
      catch ( ClassNotFoundException cnfex ) {
         // process ClassNotFoundExceptions here
         cnfex.printStackTrace();
         output.append( "Conexao nao efetivada\n" +
                        cnfex.toString() );
      }
      catch ( SQLException sqlex ) {
         // process SQLExceptions here
         sqlex.printStackTrace();
         output.append( "Conexao nao efetivada\n" +
                        sqlex.toString() );
      }
      catch ( Exception ex ) {
         // process remaining Exceptions here
         ex.printStackTrace();
         output.append( ex.toString() );
      }

      // Complete screen layout
      controls =
         new ControlPanel( connect, scrollArea, output);
      c.add( controls, BorderLayout.NORTH );

      setSize( 700, 500 );
      show();
   }


}

/**************************************************************************
 * (C) Copyright 1999 by Deitel & Associates, Inc. and Prentice Hall.     *
 * All Rights Reserved.                                                   *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/