aspose file tools*
The moose likes JDBC and the fly likes Is it possible or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is it possible or not?" Watch "Is it possible or not?" New topic
Author

Is it possible or not?

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Hi
I have a vector of vectors
now each vector element of the parent vector contains a record
i want that all vector elements .i.e records shud be inserted into database at one go I mean
Is it possible to insert multiple records at same time
because insert statement inserts only one record at a time
and statement only will insert one record at a time
and on submit of form i want all records to be inserted
Can anyone pls throw some light on it
Thankx in advance
Gaurav

SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
See java.sql.Statement.addBatch(), java.sql.Statement.executeBatch().
HTH
- Peter
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
HI peter
thnkx for ur reply
but in my case i hvae to use same statement for inserting records in the db
and unless we commit first insert we cannot insert next statement
as it locks the row in which we intend to insert
i hope u get wht i m trying to explain
any other views r most welcome
Gaurav
Originally posted by Peter den Haan:
See java.sql.Statement.addBatch(), java.sql.Statement.executeBatch().
HTH
- Peter

Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Gaurav Chikara:
in my case i hvae to use same statement for inserting records in the db
and unless we commit first insert we cannot insert next statement
as it locks the row in which we intend to insert
i hope u get wht i m trying to explain

Sorry, but I do not quite get it. All the inserts are part of the same transaction, so the locks you acquire are irrelevant.
Anyway, addBatch() is AFAIK the only way to efficiently execute a batch of statements in JDBC.
- Peter
Ajay Singhal
Ranch Hand

Joined: Jan 10, 2001
Posts: 37
hi! friends
as u r trying to store vectors in database. can i store my java object in database like Emp.
if yes pls. specify how!!!
Ajay Singhal
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Look at Blob and Clob data types
they will help u
Originally posted by Ajay Singhal:
hi! friends
as u r trying to store vectors in database. can i store my java object in database like Emp.
if yes pls. specify how!!!
Ajay Singhal


[This message has been edited by Gaurav Chikara (edited February 05, 2001).]
stucko stuck
Greenhorn

Joined: Nov 24, 2004
Posts: 1
i too have the same problem,
i want to insert a number og records from a table into another table.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

"stucko stuck",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by stucko stuck:
i too have the same problem,
i want to insert a number og records from a table into another table.


how about insert as select.
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Peter den Haan did replied to this query a couple of years back and he was right.I dont know what you meant by
"How about insert as select"
[ November 26, 2004: Message edited by: Gaurav Chikara ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

Gaurav,
Most databases allow a statement like this:

It lets you insert data into a table directly from another query.


[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
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Originally posted by Jeanne Boyarsky:
Gaurav,
Most databases allow a statement like this:

It lets you insert data into a table directly from another query.


But here we were talking about using JDBC and not using DML statements in some databases.I am sure DB2 doesn't allow it
Never mind Thanks for remark
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

Gaurav,
You can do anything in JDBC that the underlying database lets you do in DML. (given that it isn't portable.)

I think you are correct that db2 doesn't support it though.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Gaurav Chikara:
Peter den Haan did replied to this query a couple of years back and he was right.I dont know what you meant by
"How about insert as select"


I just replied to stucko stuck's question. I dont know why that mate didn't make a new thread.

anyways, sorry for confusion.
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible or not?