#Why saving data for 3 columns into 1 column?
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
What?
Is sqlite if you may help, want to insert data into table, but the inserion is wrong, if you can see the image
Print out in the code what is actually in guide.getMobileNumber() at the point it is retrieved by this method
Here is: Connection to SQLite has been established.
Inserting the following data:
First Name: rich
Last Name: cooper
Email: [email protected]
password: rich
mobileNumber785412,professional,201465
qualificationsnull
VerificationStatusfalse
account number0
roleguide
Data inserted successfully!
Cool, put this line:
System.out.println("guide.getQualifications() contains: %s".formated(guide.getQualifications()));
right under this line:
pstmt.setString(6, guide.getQualifications());
And send what gets printed out
Connection to SQLite has been established.
guide.getQualifications() contains: null
Inserting the following data:
First Name: halanad
Last Name: manc
Email: [email protected]
password: manc4521
mobileNumber:789621,professional,102145
qualifications:null
VerificationStatus:false
account number:0
role:guide
Data inserted successfully!
This look correct though?
In your logs it says mobileNumber:789621,professional,102145
in your column it's mobileNumber:789621,professional,102145
so your guide.getMobileNumber() is wrong
Ok, that is interesting, because is says: guide.getQualifications() contains: null, which means it got null from that method - why would it insert something like that...
Observation - all the values before mobile number in that log contain ":", the rest don't.
I would try to search where that log comes from and start looking for something fucky in there
Also, I would try inserting plain string there, see what happens
Actually, what I would like to see is
System.out.println("guide.getPassword() contains: %s".formated(guide.getPassword()));
Thankz, all, the error was coming from here
<label for="mobileNumber">Mobile Number:</label>
<input type="tel" id="mobileNumber" name="mobileNumber" required/>
<label for="qualifications"> qualifications:</label>
<input type="qualifications" id="qualifications" name="mobileNumber" required/>
<label for="">accountNr:</label>
<input type="accountNr" id="accountNr " name="mobileNumber" required/>
What sort of definition is that?
I am assuming you are using some framework, but this does not ring a bell...
Iam using Springboot, sqlite and Java in a Maven, it rang a bell coz the attribute name of all the 3 columns were mobilenumber which was the name of the column that all the 3 attributes were inserted.
I am talking about that XML up there, never saw that before
html lol...
I was not sure, but attributes without values kinda suggest html, yeah...
seems like this now
<label for="mobileNumber">Mobile Number:</label>
<input type="tel" id="mobileNumber" name="mobileNumber" required/>
<label for="qualifications">Qualifications:</label>
<input type="text" id="qualifications" name="qualifications" required/>
<label for="accountNr">Account Number:</label>
<input type="text" id="accountNr" name="accountNr" required/>
Do you see the difference? I was sitting 5hrs only those
May I ask what is the name of the file this html is in?
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
Thymeleaf...yeah, I never used that 🙂
same here, lesson learnt
Detected code, here are some useful tools:
Dammit, ignore that
need some other help, are you expert on Java?
Expert? No, but I know things
Hhhhh meant some better than me, Iam college student
for logical help
I have this method: ``` public boolean updateUserProfile(String email, String password) {
Connection conn = null;
try {
conn = DbConfig.connectDb();
String query = "UPDATE user SET password = ? WHERE email = ?";
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, password);
statement.setString(2, email);
int rowsUpdated = statement.executeUpdate();
// Check if any rows were updated; if yes, the update operation was successful.
if (rowsUpdated > 0) {
return true;
}
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return false;
} ```
in two classes those are almost the same, so I want to abstract as interface and both implement, so I want to make crud operatio without interacting with the database?
...what you are doing is pretty low level, I wonder why are you not using any framework
Anyway, sorry, gotta go, but unless anybody else helps I should be around in couple of hours
I can only use what is allowed
Sure - so my first thought in this case would be to go abstract - make abstract class that has all the functionality and a abstract method that retrieves the non-common part (just the table name?) Then extend it by two classes, one for user, other for that other table and implement just that method
Ok, thankz will do if it wouldn’t cause an issue for the frontend of the web
Best of luck