Please Sign up or sign in to vote. See more: Java. I have a Jtable. In Jtable I am displaying data from database to Jtable. Now I taken one Button Update. Displaying data from database to Jtable done.
Edited Values in Jtable has to update into the database that is not done. Posted Mar am samyuktha. Add a Solution. Richard MacCutchan Mar am.
What have you tried, and what is not working? Connection; import java. DatabaseMetaData; import java. DriverManager; import java. PreparedStatement; import java. ResultSet; import java. SQLException; import java. Statement; import javax. ActionEvent; import java. ActionListener; import java.
SwingControlDemo; import dbcomnew. Please do not just dump your unformatted code and expect us to figure out what it is supposed to do. Also add a full explanation of what is not working, and what results you see against what you expect. Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account.
This email is in use. Do you need your password? Submit your solution! When answering a question please: Read the question carefully.
Connect and share knowledge within a single location that is structured and easy to search. Reading is pretty easy, but updating a text file in-place ie without rewriting the whole file is very awkward. Read the whole file, make your changes, and then write the whole file to disk, overwriting the old version; this is quite easy, and will be fast enough for small files, but is not a good idea for very large files. Use a format that is not a simple text file.
A database would be one option and bear in mind that there is one, Derby, built into the JDK ; there are other ways of keeping simple key-value stores on disk like a HashMap, but in a file , but there's nothing built into the JDK. You can use OpenCSV with custom separators. Use InputStream s and Reader s to read file. Here is a code snippet that shows how to read file. Use OutputStream and Writer s to write to file. Although you can use random access files, i.
Much easier and robust way is to create new file every time you have to write something. I know that it is probably not the most efficient way, but you do not want to use DB for some reasons If you have to save and update partial information relatively often and perform search into the file I'd recommend you to use DB.
There are very light weight implementations including pure java implementations e. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to read and update row in file with Java Ask Question. Asked 10 years, 10 months ago.
Active 10 years, 10 months ago. Viewed 11k times. Improve this question. Post what you have so far, and what your results are. It will help people help you a lot better!
0コメント