jQuery in Action, 2nd edition
The moose likes JDBC and the fly likes Dynamic sql - table name, column name unknown Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Dynamic sql - table name, column name unknown" Watch "Dynamic sql - table name, column name unknown" New topic
Author

Dynamic sql - table name, column name unknown

Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
Is there a way I can execute an insert like
insert into table_name(filed1, field2 ...)
values (vf1, vf2 ..)
Here everthing is variable. L like to pass table names, column names along with values to be inserted at runtime. I am writing a SQL that fits all table designs with primitive datatypes.

Any idea how to do it in JDBC?
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1112

Raj,
You need to build the [SQL] string in your java code.

If I understand your question correctly, you need to do something like the following:
[NOTE: Uncompiled and untested.]

Hope this helps clarify things for you.

Good Luck,
Avi.
Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
Thanks. I intend to use JSTL - c:query tag etc. Does that support this kind of dynamic sql, wher tablenames, colnames are unknown?
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1112

Raj,
You asked:

Does [JSTL] support this kind of dynamic sql

I don't know. I don't use JSTL. Try the JSP forum.

Good Luck,
Avi.
 
I agree. Here's the link: jrebel
 
subject: Dynamic sql - table name, column name unknown
 
Similar Threads
Passing variables
Simple mdb connection Error
SQL Error!!
Sql operation on mobile
Sybase database - insert statement problems