JFrame SQLite Login Credentials Interaction Error
I'm making a currency exchange application in Java using JFrame. I've created a SQLite Database with user login credentials in the src directory of my project. My program correctly accesses the database. I have multiple accounts with filled in with credentials, but when I launch my application and enter correct information for a user to login, it hits my exception handling that the "username and password are invalid". Can anyone figure out a flaw in my logic that would cause my application to be incorrectly reading the database? I'm fairly sure my SQLite syntax for search query is correct.
github link to repository: https://github.com/JTSipowicz/Software-Engineering-Project
Posted Apr 28, 2020, 10:25 PM UTC
16
At https://github.com/JTSipowicz/Software-Engineering-Project/blob/aed60607a0708c7b6351f15a8a601f7149212b95/Application.java#L77:
Hope this helps.
I feel like an idiot. Changed it to count = count + 1 and it works. Now I'm wondering why count++ doesn't work? Thanks for the help.
count++is the postfix increment operator. It's equivalent to:So when you combine that together with
count = count++, you're assigning the previous value of count prior to incrementing it.. back into count. So nothing happens.The prefix increment operator,
++count, increments first and returns the incremented value instead.If you put
count++;on its own without the assignment operator, your code would also work as expected. You can also have SQL do the counting for you with "select count(*) from blah where blah" - it'll return a result set with 1 row and 1 column with the number of rows.Makes total sense now. I've been thinking too big; I'm coding this project pretty much all by myself. My group members aren't versed in Java. Crazy how 1 tiny mistake in logic throws everything off. Thanks so much for breaking it down for me. My knight in shining armor!
Just saw your explanation on mobile format. You’re the best!
:) thanks