Results 1 to 2 of 2
  1. #1
    hafiz is offline Member
    Join Date
    Sep 2014
    Posts
    1
    Rep Power
    0

    Default what the problem?

    package login.pkgfinal;

    import java.io.InputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.fxml.Initializable;
    import javafx.fxml.JavaFXBuilderFactory;
    import javafx.scene.Scene;
    import javafx.scene.layout.AnchorPane;
    import javafx.stage.Stage;
    import login.pkgfinal.login.model.User;
    import login.pkgfinal.login.model.Admin;
    import login.pkgfinal.login.security.Authenticator;
    import java.sql.*;

    public class Main extends Application {

    private Stage stage;
    private User loggedUser;
    private final double MINIMUM_WINDOW_WIDTH = 390.0;
    private final double MINIMUM_WINDOW_HEIGHT = 500.0;

    public static void main(String[] args) {
    Application.launch(Main.class, (java.lang.String[])null);
    }

    @Override
    public void start(Stage primaryStage) throws ClassNotFoundException, SQLException {



    Connection conn = null;
    Statement stmt = null;
    try{
    //STEP 2: Register JDBC driver
    Class.forName("com.mysql.jdbc.Driver");

    //STEP 3: Open a connection
    System.out.println("Connecting to database...");
    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/e_voting?zeroDateTimeBehavior=convertToNull","root ","");

    //STEP 4: Execute a query
    System.out.println("<?php ?>");
    stmt = conn.createStatement();
    String sql;
    sql = "SELECT id, first, last, age FROM Employees";
    ResultSet rs = stmt.executeQuery(sql);

    stage = primaryStage;
    stage.setTitle("Login Main");
    stage.setMinWidth(MINIMUM_WINDOW_WIDTH);
    stage.setMinHeight(MINIMUM_WINDOW_HEIGHT);
    gotoLogin();
    primaryStage.show();
    } catch (Exception ex) {
    Logger.getLogger(Main.class.getName()).log(Level.S EVERE, null, ex);
    }
    }


    public User getLoggedUser() {
    return loggedUser;
    }
    public boolean userLogging(String userId, String password){
    if (Authenticator.validate(userId, password)) {
    loggedUser = User.of(userId);
    gotoPageVote();
    return true;
    } else {
    return false;
    }
    }

    void userLogout(){
    loggedUser = null;
    gotoLogin();
    }

    private void gotoPageVote() {
    try {
    PageVoteController pagevote = (PageVoteController) replaceSceneContent("PageVote.fxml");
    pagevote.setApp(null);
    } catch (Exception ex) {
    Logger.getLogger(Main.class.getName()).log(Level.S EVERE, null, ex);
    }
    }

    private void gotoLogin() {
    try {
    LoginController login = (LoginController) replaceSceneContent("Login.fxml");
    login.setApp(null);
    } catch (Exception ex) {
    Logger.getLogger(Main.class.getName()).log(Level.S EVERE, null, ex);
    }
    }

    private Initializable replaceSceneContent(String fxml) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    InputStream in = Main.class.getResourceAsStream(fxml);
    loader.setBuilderFactory(new JavaFXBuilderFactory());
    loader.setLocation(Main.class.getResource(fxml));
    AnchorPane page;
    try {
    page = (AnchorPane) loader.load(in);
    } finally {
    in.close();
    }
    Scene scene = new Scene(page, 800, 600);
    stage.setScene(scene);
    stage.sizeToScene();
    return (Initializable) loader.getController();
    }


    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: what the problem?

    You tell us.

    First off, when posting code here please wrap it in [code] tags [/code] so it retains its formatting. Unformatted code is hard to follow.

    Second, you need to tell us what the problem is. Not make us guess.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem with a Simple Histogram Problem
    By kathmandu in forum New To Java
    Replies: 12
    Last Post: 06-25-2013, 01:19 AM
  2. Replies: 0
    Last Post: 11-07-2012, 12:44 PM
  3. Small problem with problem with Java, C++ parse program.
    By dragstang86 in forum New To Java
    Replies: 4
    Last Post: 10-30-2011, 03:43 AM
  4. Replies: 9
    Last Post: 09-21-2010, 04:15 PM
  5. simple line problem / for loop problem
    By helpisontheway in forum New To Java
    Replies: 1
    Last Post: 11-17-2009, 06:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •