last day (14 days later) » 

2:21 PM
1
A: How to go through all rows in employeeID column in database and retrieve hourly pay rate one at a time?

ThodgnirIf i understand your question the simple way to do this is to make something like this: PreparedStatement ps3 = con.prepareStatement("SELECT employeeID, HourlyRate FROM payroll_system.employee_info"); ResultSet rs = ps3.executeQuery(); Statement statement2 = con.createStatement(); /...

 
Essentially what the previous answer suggested. Great to see that there is a common solution, thanks very much Thodgnir!
 
Yup i ended writing this code while @raiserle posted his answer, so i posted my to confirm :)
 
By the way, will an update statement work if there is a null value in the database? Or does it only work to replace an actual value?
 
this statement2.executeUpdate executing normal sql update like "UPDATE payroll_system.employee_info SET FirstName = 'hank' WHERE employeeID = " + employeeID. So basicly there is no matter if there is null value or not.
 
Hmm I was just testing to see if your logic worked, but the database is not updating, could you please take a look at my test code in the updated question :)
Oops Nevermind, I forgot to execute haha...
actually it's still not working! Is there supposed to be a where clause in the initial preparedstatement?
 
2:21 PM
What is not working ?
 
I updated the question at the bottom you can see the logic I tried :)
 
are you there ?
i make answer under your question
 
Hi, I'll check :)
I removed the where clause
But it's still not working
Could you please see the update answer? :)
I'm not sure how the initial preparedstatement with the select should look like. Should it have a where clause or nothing? The first line of the code
 
Change this SELECT HourlyRate FROM payroll_system.employee_info

to this

SELECT employeeID, HourlyRate FROM payroll_system.employee_info
or just write there SELECT * FROM payroll_system.employee_info
 
Ah, it's working, thanks very much!
Really appreciate it
Silly mistake there
by me
 
2:34 PM
Yup :)
those are the worst :)
np
good luck in future coding :)
 
Haha, thanks very much! I'm in high school by the way, this is my project.
 

last day (14 days later) »