|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
How to store data into database using Eclipse software
i need help on a current project..
my school need me to use the software (Eclipse) to do my project, however for the page of registration, i need to store my customers data into the database.. i need some sample codes.. who can help me please? thank you.. thanks, fr0oby |
|
#2
|
|||
|
|||
|
and if u need the software can jus leave me a note.. i can either send to u or depends what u need.. i really need help urgently.. thank you..
fr0oby |
|
#3
|
|||
|
|||
|
i have got the answer on how to store d data already.. thank anyway for trying??
publicclass SignUpPage { private JRadioButton jRadioButton1 = null; import javax.swing.JButton; private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new java.awt.Rectangle(360,496,85,30));
jButton1.setBackground(java.awt.Color.black);
jButton1.setIcon(new ImageIcon("C:/Chester/pictures/Buttons/Submit Button.jpg"));
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
publicvoid actionPerformed(java.awt.event.ActionEvent e) {
submitLogin(e);
}
});
}
returnjButton1;
}
publicvoid submitLogin(ActionEvent e){
String names = getJTextField().getText();
String pwd = new String(getJPasswordField().getPassword());
String id = getJTextField2().getText();
String age= getJTextField1().getText();
String securityqns = getJTextField3().getText();
String securityans = new String(getJPasswordField1().getPassword());
String gender = null;
if (jRadioButton.isSelected())
gender = jRadioButton.getText();
elseif (jRadioButton1.isSelected())
gender = jRadioButton1.getText();
System.out.println(id + " " + pwd + gender);
if (names.equals("") || pwd.equals("") || id.equals("") || gender.equals("") || securityqns.equals("") || securityans.equals(""))
JOptionPane.showMessageDialog(null, "Please enter all text field");
else{
User user = new User(names, age, gender, id, pwd, securityqns, securityans);
if (user.retrieveUser())
JOptionPane.showMessageDialog(null, "User already exists! Cannot Create.");
else{
if (user.createUser()==true);
JOptionPane.showMessageDialog(null, "You have sign up successfully!");
}
}
}publicboolean createUser(){
boolean success = false;
DBController db = new DBController();
db.setUp("myDatabase1");
String sql = "INSERT INTO Registration(names, age, gender, id, pwd, securityquestion, securityanswer) ";
sql += "VALUES ('" + names + "','" + age + "','" + gender + "','" + id + "','" + pwd + "','" + securityquestion + "','" + securityanswer + "')";
if (db.updateRequest(sql)==1)
success = true;
db.terminate();
returnsuccess;
}publicboolean retrieveUser(){
boolean success = false;
ResultSet rs = null;
DBController db = new DBController();
db.setUp("myDatabase1");
String dbQuery = "SELECT * FROM Registration WHERE id ='";
dbQuery += id + "'" ;
rs = db.readRequest(dbQuery);
try{
if (rs.next()){
pwd = rs.getString("pwd");
securityquestion = rs.getString("securityquestion");
securityanswer = rs.getString("securityanswer");
success = true;
}
}catch (Exception e) {
e.printStackTrace();
}
db.terminate();
return success;
} |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Database Development > How to store data into database using Eclipse software |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|