Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
add use of dotenv files
Browse files Browse the repository at this point in the history
  • Loading branch information
L23de committed Mar 30, 2022
1 parent 1f8bd85 commit e523918
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions numa/src/main/java/numa/NUMA.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;

import io.github.cdimascio.dotenv.Dotenv;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.io.IOException;
import java.sql.Connection;

public class NUMA {
final static String DB_URL = "jdbc:oracle:thin:@edgar1.cse.lehigh.edu:1521:cse241";
final static boolean DEV = true;

public static void main (String[] args) throws IOException {
boolean connected = false;

// Re-prompts whenever user is not connected
do {
try {
Reader input = new Reader();
String[] loginInfo = getLogin(input);
String[] loginInfo = new String[2];
String DB_URL = "";
if (DEV) {
Dotenv dotenv = Dotenv.load();
String USER = dotenv.get("USERNAME");
String PASS = dotenv.get("PASSWORD");
DB_URL = dotenv.get("DB_URL");
loginInfo[0] = USER;
loginInfo[1] = PASS;
} else {
System.out.print("Enter Oracle DB URL: ");
DB_URL = input.readLine();
loginInfo = getLogin(input);
}

// Try logging in and creating a prepared statement
try (
Expand Down Expand Up @@ -83,6 +99,7 @@ public static void main (String[] args) throws IOException {
catch (SQLException e) {
// Specific exception for bad user/pass combo
if (e.getErrorCode() == 1017) {
System.out.println(e);
System.out.println("Login denied. Please try again\n");
} else {
System.out.println("SQLException: " + e);
Expand Down

0 comments on commit e523918

Please sign in to comment.