Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql newbie

 
rob armstrong
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Made a sql database, can use select and insert. Made the database from notepad and renamed it .sql and works fine (mysql). How do I insert new rows into the database AND have the new rows saved in my .SQL file for permanent storage? Basically what i am saying is i can insert stuff but it does not save it for future use or can it??? Thanks in advance
roba dbnewbie
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
Welcome to JavaRanch!

If you are inserting through a Java program, you can write code to insert the row via JDBC and append it to your file using Java's I/O APIs. If you inserting at the mysql command line, you are going to have to manually add it to the file each time. Although I suppose you could write an operating system batch file to do it for you.
 
rob armstrong
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok sounds like i will have to use java to do it.
Ill look in the api's there than. Hopefuly that answers my other question... I have used the PrintStream object but notised it does not let you add to files it only saves a new copy each time. example .. Program makes a 'A' than tommorow you want to add a 'B'. load up the file and it just shows a 'B' no more 'A'. So i assume there is another object for adding to files. Just like the save button would do in 'NOTEPAD' or most other applications.
roba
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
Take a look at the FileWriter class. It has a constructor for appending to a file. If you have any more questions on writing to files, please post a new question in our I/O forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic