Java AWT Components: Buttons, Lists, Text Fields, and More

Buttons

Buttons can be created with objects using the operator new:

Button button; button = new Button("Button");

Used in CADNA creation, the button will appear when displayed on the screen. This is also what CADNA will return to use when identifying the button event.

Button Events

One-touch button events can be captured by overloading the method action():

public boolean action(Event evt, Object obj) {
    if (evt.target instanceof Button)
        System.out.println((String) obj);
    else

Read More

Database Schema and Queries for Hockey League

Table Structures

Equipo Table

— Table structure for table Equipo

DROP TABLE IF EXISTS Equipo;

CREATE TABLE Equipo (

team_id int(11) NOT NULL,

teamName varchar(45) DEFAULT NULL,

PRIMARY KEY (team_id)

Estadísticas_Equipo Table

— Table structure for table Estadísticas_Equipo

DROP TABLE IF EXISTS Estadísticas_Equipo;

CREATE TABLE Estadísticas_Equipo (

game_id int(11) NOT NULL,

team_id int(11) NOT NULL,

tgoals int(11) DEFAULT NULL,

tshots int(11) DEFAULT NULL,

thits int(11) DEFAULT NULL,

PRIMARY KEY (game_id,team_

Read More

Java Person and Pet Management Code

Java Person and Pet Management

This Java code provides functionality to manage a list of people and their pets. It includes methods to create, read, update, and delete person records.

Create Person

The createPerson() method allows you to add a new person to the list. It prompts for the person’s name, age, and gender, and allows adding pets to the person’s record.

public static void createPerson() {
    String name = WordNotEmpty("Enter name:");
    if (getPersonByName(name) != null) {
        System.
Read More

Firewall Technologies: Packet Filtering, Proxy, and Stateful Inspection

Firewall Technologies

Packet filtering – Packets (small chunks of data) are analyzed against a set of filters. Packets that pass the filters are sent to the requesting system; all others are discarded.

Proxy service – Information from the Internet is retrieved by the firewall and then sent to the requesting system and vice versa.

Stateful inspection – A newer method that doesn’t examine the contents of each packet but instead compares certain key parts of the packet to a database of trusted information.

Read More

Java Code Snippets: Database, Lambda, and String Operations

Database URL: jdbc:mysql://mis-sql.uhcl.edu/agarwaln8497

Database username: agarwaln8497
Database password: 1005681
Error message: String errorMsg = "";
Connection: Connection c = null;
Statement: Statement s = null;
ResultSet: ResultSet rset = null;

Submit Method

This method handles database connection and data retrieval.

    
      public String Submit() {
        try {
          Class.forName("com.mysql.jdbc.Driver");
          System.out.println("Driver is ok.");
        } catch (ClassNotFoundException 
Read More

Database Recovery Techniques and Security

Purpose of Database Recovery

To bring the database into the last consistent state, which existed prior to the failure.

To preserve transaction properties (Atomicity, Consistency, Isolation, and Durability).

Types of Failure

Transaction failure: Transactions may fail because of incorrect input, deadlock, or incorrect synchronization.

System failure: System may fail because of addressing error, application error, operating system fault, RAM failure, etc.

Media failure: Disk head crash, power disruption,

Read More