Can UPDATE be used for populating DB using JDBC

T

Tushar

Can UPDATE be used to populate an Access DB using JDBC? I donot want to
use INSERT because it appends data into the DB on each executionof the
aaplication.Pls help.
 
R

Rhino

Tushar said:
Can UPDATE be used to populate an Access DB using JDBC? I donot want to
use INSERT because it appends data into the DB on each executionof the
aaplication.Pls help.
INSERT is used to create new rows in a table so you will have to use it if
you want to create new rows.

UPDATE is used to change existing rows in a table. You cannot create a new
row with UPDATE, only change a row that is already in the database.

I don't understand why you object to the fact that INSERT adds rows to a
database. If your data is not already in the database, it has to be added to
the database. That will inevitably make the database bigger. That is a law
of nature. There is no database anywhere that is going to let you add rows
without taking up space.

Rhino
 
W

Wendy S

Tushar said:
Can UPDATE be used to populate an Access DB using JDBC? I donot want to
use INSERT because it appends data into the DB on each executionof the
aaplication.Pls help.

You can update a record if it exists... if not, you have to insert it. Have
you considered clearing the table when the application starts? That seems
to be the behavior you want.
 
L

Lee Weiner

Can UPDATE be used to populate an Access DB using JDBC? I donot want to
use INSERT because it appends data into the DB on each executionof the
aaplication.Pls help.

From this question and the last thread, it seems you want to add new records
each time the app is run, and not retain the previous records. If that's what
you want to do, then simply DELETE all records in the table before you add the
new ones.

Lee Weiner
lee AT leeweiner DOT org
 
A

Alan Gutierrez

From this question and the last thread, it seems you want to add new records
each time the app is run, and not retain the previous records. If that's what
you want to do, then simply DELETE all records in the table before you add the

For a table named "foo" do:

DELETE FROM foo

And the table is empty.

Tushar might be fretting about the fact that Access files always
grow, even if you are deleting or updating. You must compact the
database, which is really some form of copy to new database, and
move into place.

Tushar, why not smiply keep a copy of a blank database, and copy
it into place when your application starts?
 
D

David Segall

Tushar said:
Can UPDATE be used to populate an Access DB using JDBC? I donot want to
use INSERT because it appends data into the DB on each executionof the
aaplication.Pls help.
From your previous post it seems that your problem is with SQL and not
with Java. Access is the ideal tool to solve the problem. Use it to
see exactly what happens with your INSERT and UPDATE queries. I often
find it easier to formulate the query in the Access query design view
and then convert it to SQL using the SQL view. You can cut and past
the result to your Java program. You will probably need to substitute
some Java variables for the constants you used to write the query. If
so, you can use a Java debugger to show you the query just before it
is executed and, if necessary, cut and paste it to Access to debug it.
 
F

frankgerlach22

Access seems to be quite awkward, if you have to "compact" the database
from time to time. Good databases such as MySQL or ORACLE do this
automatically.
 
T

Tushar

Access seems to be quite awkward, if you have to "compact" the database
from time to time. Good databases such as MySQL or ORACLE do this
automatically.
 
D

David Segall

Access seems to be quite awkward, if you have to "compact" the database
from time to time. Good databases such as MySQL or ORACLE do this
automatically.
I was not suggesting that anybody use Access as a database. Not even
Microsoft does that
<http://www.microsoft.com/sql/msde/productinfo/overview.asp>. I do
think it is an excellent front end for a database and is particularly
useful for those who are not familiar with SQL. Incidentally, you can
use it as a front end to "good databases" including MySQL and Oracle.
All that is needed is an ODBC driver.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top