• 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

retrieving parameter values from PreparedStatement

 
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
I would like to make a method which replaces the tipical preparedstatement clause (?) from a sql String with it's value.
This should be the method sign
public String preparedReplace (String argSql, PreparedStatement pstm)
I want to retrieve parameter values from the preparedStatement object but I don´t know how.
Is There any way of retrieving these parameter values?
The API (ParameterMetaData) doesn´t show how to do that.
Thanks in advance.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, there isn't a way to do this using the API. There are several frameworks that do similar things, such as p6spy or log4jdbc.

I've actually implemented a wrapper around PreparedStatement, which intercepts and stores the values of parameters being passed and can output the SQL query text with embedded literals. I haven't implemented it fully though, only those parts that are needed by my project. It doesn't support obtaining BLOB and CLOB parameters back, for example. Implementing it for the standard types isn't that hard, the hard part is to ensure it is used at all appropriate places.
 
Fernando Dominguez
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the quick response.

The idea is to make a simple method, nothing too complicated.

I didn´t know that frameworks. I not going to use them at the moment but they will probably be very usefull in a near future.

Thanks.


 
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic