Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.class
out/
*.csv

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# HorridDialog
The worst dialog box in the history of time.

No really it's true.
40 changes: 14 additions & 26 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import javafx.scene.text.Text;
import javafx.stage.Stage;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Expand Down Expand Up @@ -64,42 +67,27 @@ public void start(Stage primaryStage) throws Exception {
gridPane.add(error, 1, 6);

btn.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent e) {
String firstName = firstNameTextField.getText();
String lastName = lastNameTextField.getText();
String email = userTextField.getText();

if (firstName.isEmpty() ||
!validEmail(email) ||
lastName.isEmpty()) {
error.setFill(Color.FIREBRICK);
error.setText("Invalid Data");
} else {
Connection connection = null;

try {
BufferedWriter out = null;
try {
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/users";

connection = DriverManager.getConnection(url, "username", "password");

Statement stmt = connection.createStatement();

String insert = "insert into users (email, first_name, last_name)" +
" VALUES('" + email + "', '" + firstName + "', '" + lastName + "');";
stmt.executeUpdate(insert);
} catch (Exception e1) {

FileWriter fstream = new FileWriter("userdata.csv", true);
out = new BufferedWriter(fstream);
out.write(String.format("\n%s, %s, %s", firstName, lastName, email));
} catch (IOException ioe) {
System.err.println("Error: " + ioe.getMessage());
} finally {
try {
if (connection != null)
connection.close();
} catch (SQLException se) {

if (out != null) {
out.close();
}
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
Expand Down
58 changes: 0 additions & 58 deletions test/EmailValidatorTester.java

This file was deleted.