• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can you insert into the database without using insert query in a Resultset

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

Can we insert into the database without using INSERT Query in a ResultSet into the database. The option I thought was using Stored Procedure. Is there any other way we could do this. Please let me know.

Thanks
Chandu
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I entirely understand the question, but I'll take a stab at it.

There are a few ways you can get data into a database via JDBC and SQL.

Using pure standard SQL, the SQL INSERT statement is the major way. For example, "INSERT INTO MY_TABLE (MY_COL_1, MY_OTHER_COL) values ('test', 3)";
For greater efficieny, inserts may be batched together with the batch facilities of PreparedStatement (if supported by your driver/database).

If your database supports stored procedures (SPs), then you can have them do the sql INSERT for you - it still does an INSERT (or whatever you program in the SP), you're just adding a layer of abstraction around it.

Some databases also support some non-standard SQL statments, some of which can add new data. For example, Oracle's MERGE statement will allow you to do INSERT-or-UPDATE in a single query.

Some databases and their drivers support updatable ResultSets (which you appear to be aware of), but not all do or do it well/efficiently.
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I phrased the question wrong. Thanks though...

Chandu
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic