Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package a_Zadania.a_Dzien_2.c_Relacje_1_1;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Main3 {
- public static String queryCreateTable ="CREATE TABLE Payments(\n" +
- " id int AUTO_INCREMENT,\n" +
- " tickets_id int NOT NULL,\n" +
- " type varchar(255),\n" +
- " date DATE,\n" +
- " PRIMARY KEY(id),\n" +
- " FOREIGN KEY(tickets_id)\n" +
- " REFERENCES Tickets(id)\n" +
- " ON DELETE CASCADE\n" +
- " );";
- public static void main(String[] args) {
- try (Connection conn = DriverManager
- .getConnection("jdbc:mysql://localhost:3306/cinemas?useSSL=false",
- "root", "coderslab")) {
- Statement stmt = conn.createStatement();
- stmt.executeUpdate(queryCreateTable);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment