Results 1 to 9 of 9
- 12-14-2011, 01:59 PM #1
Member
- Join Date
- Dec 2011
- Location
- india
- Posts
- 16
- Rep Power
- 0
- 12-19-2011, 08:29 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Re: Using PreparedStatement with table name
moved from another thread...
If you manage to find this abhi7080, welcome to the forum!
- 12-19-2011, 11:19 AM #3
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Using PreparedStatement with table name
Why not use Statement?
Prepared statements are for repetitive queries. Does your database management system support parameterizing table names in DDL? I doubt it.
Which database system are you using? Unless the driver is simulating prepared statements, I doubt you can achieve what you want. Others may know differently, though. :-)
- 12-19-2011, 11:37 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
Re: Using PreparedStatement with table name
Using a Statement is bad advice; it makes the query vulnerable for SQL injection if it takes parameters. A prepared statement is pre-compiled and knowing the table(s) and/or view(s) at compile time is essential for the query optimizer so you can't pass the table/view name(s) as a parameter in a PreparedStatement.
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-19-2011, 11:48 AM #5
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Using PreparedStatement with table name
Last edited by 2by4; 12-19-2011 at 11:50 AM.
- 12-19-2011, 12:10 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
- 12-19-2011, 12:16 PM #7
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: Using PreparedStatement with table name
Sorry, a possibility is never "bad advice". I put forward a suggestion to be used if appropriate, and put it as a question.
Statement is absolutely appropriate in some instances, for example where the program is intended to be used by an administrator.
That's my last word on this before you derail the thread.
- 12-19-2011, 12:21 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
Re: Using PreparedStatement with table name
Ok, goodbye and stop giving bad advice to people new to the subject. You claim to be a Mr. Know-It-All in your replies, but you are not obviously.
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-19-2011, 01:13 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
How to embed HTML table in lotus notes tabbed table using java?
By mmsmohana in forum New To JavaReplies: 1Last Post: 09-27-2011, 06:06 AM -
How to repaint.refresh the table (table model) with combo box selection envent
By man4ish in forum AWT / SwingReplies: 1Last Post: 01-08-2010, 06:19 AM -
Deleting records from database table using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 02-09-2008, 08:31 PM -
Modifying data in database table using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 02-09-2008, 08:22 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks