• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How to link data input by user into database?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to insert data inserted by user from java swing into table in database ?
I found out many codes are for ourself to insert the data, but how if i want to insert the data inserted by the user ?
         
 
Saloon Keeper
Posts: 5395
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between "insert the data" and "insert the data input by the user"? What difference does where the data comes from to how to insert it into the DB?
 
Nadhirah Zunaidi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:What is the difference between "insert the data" and "insert the data input by the user"? What difference does where the data comes from to how to insert it into the DB?



For example,
INSERT INTO people (fname, lname) VALUES" + "('Joe', 'Bloggs'), ('Mary', 'Bloggs'), ('Jill', 'Hill')"

The code above will insert data into the table 'people'.
Okay how if, the data is from a JTextField (which is the data inserted by the user), and how do i code it so that it will be inserted into the 'people' table?  
Sorry for my bad english  
 
Rancher
Posts: 1943
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all use PreparedStatement for sql operations.  Forming a query like this is prone to bugs and vulnerable to sql injections.  Now coming to your question, you can write a method to insert records and to this method you can pass edit field values as parameters.
 
Swastik Dey
Rancher
Posts: 1943
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of the method that I mentioned can be somewhat like this



and you call the above method from where you wish to save the edit field values.
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
ScroogeXHTML - the small and fast RTF to HTML converter library
https://coderanch.com/t/707504/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!