Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Overwriting a Access Database using JDBC
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Brian Hetrick, post: 600122"] It seems your problem is that in fact you do not have an empty database. If you did, it wouldn't get bigger with each run of your program and you wouldn't be getting duplicate rows. If I understand correctly, you need to handle two cases: - Handling a new database - Handling an old database You can try a statement of the form: UPDATE Addresses SET Name = 'MAnik', LastName = 'Desai', Spouse='Sabrina' WHERE ID='3'; This will then modify the row where the ID value is 3. If that state- ment fails, then you probably want: INSERT INTO Addresses (ID, Name, LastName, Spouse) VALUES ('3', 'MAnik', 'Desai', 'Sabrina'); which will create the row in the first place. Another possibility is to throw away any data currently in the data- base: DROP TABLE Addresses; and then recreate the table: CREATE TABLE Addresses (ID INTEGER PRIMARY KEY, Name TEXT (30) NOT NULL, LastName TEXT (30) NOT NULL, Spouse TEXT (30)); (obviously you should use whatever fields and datatypes you need as I am just guessing). This will give you an 'empty' database. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Overwriting a Access Database using JDBC
Top