473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Save a textfield data/values into mysql database.

Good day everyone, I'm trying to save an inputted data using JTextfield in JAVA GUI into MySQL database.
But when i pressed the save button nothing happens. I want to show you all my work right now.
Please try to help me, Thank you in advance!

Expand|Select|Wrap|Line Numbers
  1.     if(e.getSource().equals(save))    {
  2.  
  3.     String ID=custid.getText();
  4.     int custid=Integer.parseInt(ID);
  5.  
  6.     String fname=CustFName.getText();
  7.     String lname=CustLName.getText();
  8.     String tel=CustTelNum.getText();
  9.     String city=CustCity.getText();
  10.     String zcode=CustZCode.getText();
  11.     String status=CustStat.getText();
  12.     String creditcard=CreditCNum.getText();
  13.     String order=CustOrDt.getText();
  14.     String dfee=CustDFee.getText();
  15.     String inumber=MnuINum.getText();
  16.     String icost=MnuCost.getText();
  17.     String tcost=TotalCost.getText();
  18.  
  19.     try    {
  20.     rs.moveToInsertRow();
  21.  
  22.     rs.updateInt(ID, custid);
  23.     rs.updateString("First_Name", fname);
  24.     rs.updateString("Last_Name", lname);
  25.     rs.updateString("Tel_Num", tel);
  26.     rs.updateString("City", city);
  27.     rs.updateString("Zip_Code", zcode);
  28.     rs.updateString("Status", status);
  29.     rs.updateString("Credit_Card", creditcard);
  30.     rs.updateString("Order_Date", order);
  31.     rs.updateString("Delivery", dfee);
  32.     rs.updateString("Quantity", inumber);
  33.     rs.updateString("Item_Cost", icost);
  34.     rs.updateString("Total_Cost", tcost);
  35.  
  36.     rs.insertRow();
  37.     st.executeQuery("INSERT INTO thepizzadb.orderstable VALUES (ID,'fname','lname','tel'","'city','zcode','status','creditcard','order','dfee','inumber','icost','tcost')");
  38.  
  39.     st.close();
  40.     rs.close();
  41.  
  42.  
  43.     }catch(SQLException err){
  44.         JOptionPane.showMessageDialog(null, err.getMessage());
  45.     }
  46. }
Sep 27 '14 #1
1 4666
Luuk
1,047 Expert 1GB
Try to put the SQL-statement, that you are sending to the MySQL database at line #7 on a MySQL-prompt, and see if it returns any errors, and if you get the correct values in the database.

I'm not an expert in JAVA, but this SQL seems not correct for what you want to achieve:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO thepizzadb.orderstable VALUES (ID,'fname','lname','tel'","'city','zcode','status','creditcard','order','dfee','inumber','icost','tcost')"
  2.  
Sep 28 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
Nert
by: Nert | last post by:
hi, I've created a website, uhhmmn something like posting/uploading images and videos.., i made my site working well, i save images on database but the videos are just copied from the client...
1
by: viresh | last post by:
Hello everybody, I am quite beginner as a software professional in php & mysql. I want to know how I can fetch data from mysql database to show in a form's drop down box with php...
4
by: sssk28 | last post by:
i have written a jsp code which fetches data from mysql database. it performs insertion operation correctly but it fails while fetching the data. i am getting error on line which contains...
2
by: mfaisalwarraich | last post by:
Hi Everybody, I am using the following function to get the data from mysql database. i have entered appnum field as text filed in the database which has leading zeroes to this field like if...
2
by: sarah aziz | last post by:
Hello all I am trying to retrieve the data from mysql database by php to plot a flot graph can anyone help me please this is all i have done for now Php $sql = mysql_query("SELECT count(Msg_ID)...
17
by: msmjsuarez | last post by:
Hello, I need help... How to automatically insert data to mysql database without submit button using php? Is there a way on this? thanks a lot.
0
by: adajon92 | last post by:
I have a problem with mySQL database. To start off, I'm a super N00b and am trying to make a web page using PHP and MySQL for a class project. Currently the database and website are...
1
by: santhanalakshmi | last post by:
Hi, I wrote some coding, to import excel data in mysql database using PHP Script? But my script, its not all inserting the excel data in mysql database. I don't know, what mistake did i made?...
4
by: vishal prada | last post by:
there is one registration form where using dropdown box i select one country and it save into mysql database. now i want to fetch that value of mysql database table into edit profile form where i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.