Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Dimension;
- import java.awt.Toolkit;
- import java.util.ArrayList;
- import java.sql.*;
- import javafx.application.Application;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.geometry.Insets;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextArea;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.StackPane;
- import javafx.scene.layout.VBox;
- import javafx.stage.Stage;
- public class GUI extends Application {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Button createTables;
- Button populateTables;
- Button selectAll;
- Button queries;
- Button query1;
- Button query2;
- Button query3;
- Button query4;
- Button query5;
- Button dropTables;
- TextArea output;
- public static void main(String[] args){
- launch(args);
- }
- @Override
- public void start(Stage primaryStage) throws Exception {
- // Stage set-up
- Stage myStage = primaryStage;
- myStage.setTitle("Online Job Posting");
- double screenWidth = screenSize.getWidth();
- double screenHeight = screenSize.getHeight();
- createTables = new Button("Create Tables");
- populateTables = new Button("Populate Tables");
- selectAll = new Button("Select All");
- queries = new Button("Queries");
- query1 = new Button("Query1");
- query2 = new Button("Query2");
- query3 = new Button("Query3");
- query4 = new Button("Query4");
- query5 = new Button("Query5");
- dropTables = new Button("Drop Tables");
- output = new TextArea();
- VBox vBox = new VBox();
- vBox.setPrefWidth(100);
- vBox.setPadding(new Insets(5, 5, 10, 5));
- vBox.setSpacing(2);
- createTables.setMinWidth(vBox.getPrefWidth());
- populateTables.setMinWidth(vBox.getPrefWidth());
- selectAll.setMinWidth(vBox.getPrefWidth());
- queries.setMinWidth(vBox.getPrefWidth());
- query1.setMinWidth(vBox.getPrefWidth());
- query2.setMinWidth(vBox.getPrefWidth());
- query3.setMinWidth(vBox.getPrefWidth());
- query4.setMinWidth(vBox.getPrefWidth());
- query5.setMinWidth(vBox.getPrefWidth());
- dropTables.setMinWidth(vBox.getPrefWidth());
- createTables.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- String username = "clrosier";
- String password = "apple321";
- Connection c;
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- c = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl", username, password);
- Statement stmt = c.createStatement();
- String query = "CREATE TABLE table_name ( PersonID int, OtherAtt VARCHAR2(30), OtherAtt2 VARCHAR2(30) );";
- ResultSet rset = stmt.executeQuery(query);
- } catch (ClassNotFoundException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- } catch (SQLException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- }
- });
- populateTables.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- selectAll.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- queries.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- query1.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- query2.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- query3.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- query4.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- }
- });
- query5.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- output.setText("query5..");
- }
- });
- dropTables.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle (ActionEvent e)
- {
- //SQL Functionality goes in here
- output.setText("droptables..");
- }
- });
- output.setMinSize(290, 245);
- output.setMaxSize(290, 245);
- output.setTranslateX(105);
- output.setTranslateY(-245);
- vBox.getChildren().addAll(createTables, populateTables, queries, query1, query2, query3, query4, query5, dropTables, output);
- Scene myScene = new Scene(vBox, 400, 250);
- myStage.setScene(myScene);
- myStage.setResizable(false);
- myStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement