This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes Can you insert into the database without using insert query in a Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can you insert into the database without using insert query in a Resultset " Watch "Can you insert into the database without using insert query in a Resultset " New topic
Author

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

Chandra Sagi
Ranch Hand

Joined: May 05, 2005
Posts: 162
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
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
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

Joined: May 05, 2005
Posts: 162
I phrased the question wrong. Thanks though...

Chandu
 
GeeCON Prague 2014
 
subject: Can you insert into the database without using insert query in a Resultset