| Author |
sql newbie
|
rob armstrong
Ranch Hand
Joined: Jul 25, 2005
Posts: 77
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
rob armstrong
Ranch Hand
Joined: Jul 25, 2005
Posts: 77
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
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.
|
 |
 |
|
|
subject: sql newbie
|
|
|