Matthew Blake

Greenhorn
+ Follow
since Aug 01, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matthew Blake

Finally got this working. It appeared to be a few different problems ranging from proper login credentials to needing to revise my database table. Thanks for your help gentleman!
11 years ago
Thanks for sticking with me, I struggle with programming, but hopefully I can get my head around this.

I made a couple changes. The first is I added a connection just under getSimpleConnection() with: Connection conn = null
At the end, just above the first try/catch I placed: conn = DriverManager.getConnection(DB_CONN_STRING, USER_NAME, PASSWORD);
I also have e.printStackTrace() at line 38. Did I implement it correctly?
Lastly, I removed result completely and replaced it with conn throughout the code
This seems to have no effect though. I must be missing some a concept somewhere.
Here is my current code with the updates I made:
11 years ago
Paul: I took a look at the lines mentioned but didn't see anything wrong with the code. Netbeans is not throwing any errors at me either.

Rob: I added e.printStackTrace() after line 36, but there is nothing different in the output box. Should I be looking somewhere else for the information?

Additional code from class StudentAppDriver:
11 years ago
I am finishing a program and I am having trouble getting the database to connect properly. I just completely removed and reinstalled MySQL so I don't think the error is caused by a bad password. Thanks for your help!

The error I'm getting is:

Driver loaded, but cannot connect to db: jdbc:mysql://localhost:3306/registrar
Exception in thread "main" java.lang.NullPointerException
at student.Undergraduate.add(Undergraduate.java:156)
at student.StudentAppDriver.addStudent(StudentAppDriver.java:102)
at student.StudentAppDriver.start(StudentAppDriver.java:30)
at student.StudentAppDriver.main(StudentAppDriver.java:20)

Code:
11 years ago