yogesh jalodara yogesh jalodara - 1 year ago 118
Java Question

Need a Fake data generator for Java console application

I need a Fake Data Generator (e.g., For a person's personal information like first name, last name, email and all) for console based jdbc application.
Because I want to add those data of random person to MySQL database.

My code for MySQL as below :

String url1 = "jdbc:mysql://localhost:3306/restaurant";
String user = "root";
String password = "root";

conn1 = DriverManager.getConnection(url1, user, password);
if (conn1 != null) {
System.out.println("Connected to the database restaurant");
// I want add data generator here.

Answer Source

You have DataFactory. It generated names (even some specific region names), addresses, birth dates or other dates, general random strings, you can even give it some arrays of random stuff to generate from, etc

Edit: usage example

In order to get different output each time, create it with your seed for Random(). The best seed is nano time:

DataFactory df1 = DataFactory.create(System.nanoTime());

Everytime you create it, you will get different output.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download