• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Is it possible or not?

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See java.sql.Statement.addBatch(), java.sql.Statement.executeBatch().
HTH
- Peter
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i too have the same problem,
i want to insert a number og records from a table into another table.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gaurav,
Most databases allow a statement like this:

It lets you insert data into a table directly from another query.
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic