Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.util.Random;
- import java.util.UUID;
- import java.math.*;
- import java.nio.charset.Charset;
- public class Main {
- public static void main(String[] args) {
- grupy();
- playlisty();
- }
- public static void grupy()
- {
- try {
- int leftLimit = 97; // letter 'a'
- int rightLimit = 122; // letter 'z'
- Random random = new Random();
- for(int i=0;i<500;i++)
- {
- int targetStringLength = random.nextInt(30);
- StringBuilder buffer = new StringBuilder(targetStringLength);
- for (int j = 0; j < targetStringLength; j++) {
- int randomLimitedInt = leftLimit + (int)
- (random.nextFloat() * (rightLimit - leftLimit + 1));
- buffer.append((char) randomLimitedInt);
- }
- String nazwa = buffer.toString();
- targetStringLength = random.nextInt(250);
- buffer = new StringBuilder(targetStringLength);
- for (int j = 0; j < targetStringLength; j++) {
- int randomLimitedInt = leftLimit + (int)
- (random.nextFloat() * (rightLimit - leftLimit + 1));
- buffer.append((char) randomLimitedInt);
- }
- String opis= buffer.toString();
- Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/platforma muzyczna2", "root", "root");
- Statement myStmt = myConn.createStatement();
- PreparedStatement posted= myConn.prepareStatement("INSERT INTO grupy(IdGr, Nazwa, Opis) VALUES("+i+", '"+nazwa+"', '"+opis+"')");
- posted.executeUpdate();
- }
- }
- catch (Exception exc)
- {
- exc.printStackTrace();
- }
- }
- public static void playlisty()
- {
- try {
- int leftLimit = 97; // letter 'a'
- int rightLimit = 122; // letter 'z'
- Random random = new Random();
- for(int i=0;i<500;i++)
- {
- int targetStringLength = random.nextInt(30);
- StringBuilder buffer = new StringBuilder(targetStringLength);
- for (int j = 0; j < targetStringLength; j++) {
- int randomLimitedInt = leftLimit + (int)
- (random.nextFloat() * (rightLimit - leftLimit + 1));
- buffer.append((char) randomLimitedInt);
- }
- String nazwa = buffer.toString();
- targetStringLength = random.nextInt(250);
- buffer = new StringBuilder(targetStringLength);
- for (int j = 0; j < targetStringLength; j++) {
- int randomLimitedInt = leftLimit + (int)
- (random.nextFloat() * (rightLimit - leftLimit + 1));
- buffer.append((char) randomLimitedInt);
- }
- String opis= buffer.toString();
- int czyPrywatna= random.nextInt(2);
- int ocena= random.nextInt(7);
- Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/platforma muzyczna2", "root", "root");
- Statement myStmt = myConn.createStatement();
- PreparedStatement posted= myConn.prepareStatement("INSERT INTO playlisty(IdPla, Nazwa, CzyPrywatna, Ocena, Opis) VALUES("+i+", '"+nazwa+"',"+czyPrywatna+","+ocena+", '"+opis+"')");
- posted.executeUpdate();
- }
- }
- catch (Exception exc)
- {
- exc.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement