hi i am having trouble inserting data into a MySQL database. the user is suppose to fill out a gui form made using swing compnents and then add all the contents from the textfield into the database.
it creates a new row but does not add any values for some unknown reason. i checked the contents of the table and everything is blank besides the incremented primary key..
here is the code below:
private void btn_RegisterActionPerformed(java.awt.event.ActionEvent evt) {
String username = null;
String password = null;
String Re_pass = null;
String email = null;
username = fld_new_usename.getText();
password = fld_password.getText();
Re_pass = fld_retype.getText();
email = fld_Email.getText();
try
{
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/i-comm";
Connection con = DriverManager.getConnection( url,"root", "mankind");
stmt = con.createStatement();
stmt.executeUpdate(
"INSERT INTO users(Username, " +
"password, " + "Email) VALUES(username,password,email)");
con.close();
} catch( Exception e )
{
e.printStackTrace();
}//end catch// TODO add your handling code here:
}