Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1025801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:58:59+00:00 2026-05-16T11:58:59+00:00

import java.util.*; import org.directwebremoting.util.Logger; public class People { public People() { people = new

  • 0
 import java.util.*;
 import org.directwebremoting.util.Logger;
 public class People
{
public People()
{
    people = new HashSet();
    random = new Random();
    log.debug("Generating a new set of random people");
    for(int i = 0; i < 5; i++)
        people.add(getRandomPerson());

}

public Set getAllPeople()
{
    return people;
}

public void setPerson(Person person)
{
    log.debug("Adding person: " + person);
    if(person.getId() == -1)
        person.setId(getNextId());
    people.remove(person);
    people.add(person);
}

public void deletePerson(Person person)
{
    log.debug("Removing person: " + person);
    people.remove(person);
    debug();
}

private Person getRandomPerson()
{
    Person person = new Person();
    person.setId(getNextId());
    String firstname = FIRSTNAMES[random.nextInt(FIRSTNAMES.length)];
    String surname = SURNAMES[random.nextInt(SURNAMES.length)];
    person.setName(firstname + " " + surname);
    String housenum = (random.nextInt(99) + 1) + " ";
    String road1 = ROADS1[random.nextInt(ROADS1.length)];
    String road2 = ROADS2[random.nextInt(ROADS2.length)];
    String town = TOWNS[random.nextInt(TOWNS.length)];
    String address = housenum + road1 + " " + road2 + ", " + town;
    person.setAddress(address);
    float salary = Math.round(10F + 90F * random.nextFloat()) * 1000;
    person.setSalary(salary);
    return person;
}

protected void debug()
{
    Person person;
    for(Iterator it = people.iterator(); it.hasNext(); log.debug(person.toString()))
        person = (Person)it.next();

}

private static synchronized int getNextId()
{
    return nextId++;
}

static Class _mthclass$(String x0)
{
try
{
return Class.forName(x0);
}
catch(ClassNotFoundException x1)
{
throw new NoClassDefFoundError(x1.getMessage());
}
}

private Set people;
private static int nextId = 1;
private Random random;
private static final String FIRSTNAMES[] = {
    "Fred", "Jim", "Shiela", "Jack", "Betty", "Jacob", "Martha", "Kelly", "Luke", "Matt", 
    "Gemma", "Joe", "Ben", "Jessie", "Leanne", "Becky"
};
private static final String SURNAMES[] = {
    "Sutcliffe", "MacDonald", "Duckworth", "Smith", "Wisner", "Iversen", "Nield", "Turton", "Trelfer", "Wilson", 
    "Johnson", "Cowan", "Daniels"
};
private static final String ROADS1[] = {
    "Green", "Red", "Yellow", "Brown", "Blue", "Black", "White"
};
private static final String ROADS2[] = {
    "Close", "Drive", "Street", "Avenue", "Crescent", "Road", "Place"
};
private static final String TOWNS[] = {
    "Birmingham", "Kettering", "Paris", "San Francisco", "New York", "San Mateo",   "Barcelona"
};
private static final Logger log;

static 
{
    log = Logger.getLogger(People.class);
}
}

I dont want these data values FIRSTNAMES,TOWNS,ROADS2,ROADS1,SURNAMES inside the program rather i want to connect it to mysql table. How to do that anyone help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:59:00+00:00Added an answer on May 16, 2026 at 11:59 am

    You can take a look at this introductory tutorial.

    There are tons of tutorials online as well regarding connecting Java applications and MySQL.

    On the other hand, if you want to go that extra step forward, you might want to take a look at ORM Tools like Hibernate. It basically allows your Java application to connect to a database (just like JDBC). The advantage of such framework tough is that it allows you to change the Database you are using without having to make drastic changes to your application. Not to mention that it automatically maps data stored inside the database to objects and the other way round.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
So I've got a JPanel implementing MouseListener and MouseMotionListener : import javax.swing.*; import java.awt.*;
I have a very simple Java RMI Server that looks like the following: import
I have this simple Jsp page: <%@ page language=java import=java.awt.Color%> <% Color background =
import sys words = { 1 : 'one', 2 : 'two', 3 : 'three',
I need to import a csv file into Firebird and I've spent a couple
How can you import a foxpro DBF file in SQL Server?
I want to import an oracle dump into a different tablespace. I have a
How can you automatically import the latest build/revision number in subversion? The goal would
Are there any import and export tools that would let us move projects into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.