Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- import javafx.application.Application;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.Connection;
- import java.sql.SQLException;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.Statement;
- public class Main extends Application {
- static Connection connection = null;
- static String databaseName = "";
- static String url = "jdbc:mysql://localhost:3306/my_base?useTimezone=true&serverTimezone=UTC";
- static String username = "hbstudent";
- static String password = "hbstudent";
- @Override
- public void start(Stage primaryStage) throws Exception{
- Parent root = FXMLLoader.load(getClass().getResource("schemat.fxml"));
- primaryStage.setTitle("Import Project");
- primaryStage.setScene(new Scene(root));
- primaryStage.show();
- }
- public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- connection = DriverManager.getConnection(url, username, password);
- PreparedStatement ps = connection.prepareStatement("INSERT INTO CUSTOMERS (ID, NAME, SURNAME, AGE) VALUES (5, 'Jacek', 'Lisiecki', 24);");
- int status = ps.executeUpdate();
- if (status != 0) {
- System.out.println("Database was Connection");
- System.out.println("Record was Inserted");
- }
- }
- catch (Exception e)
- {
- }
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement