Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Getting name of CallableStatement before execute?

 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Trying to figure out a way to retrieve the value passed to prepareStatement() and the parameters thereof, but I do not see an immediate way to do this within the Statement, PreparedStatement, or CallableStatement objects.

Any ideas?

Thanks!
 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
What are you trying to do with the values? The database driver has a way of getting them, but an application developer normally wouldn't. You are passing in the values, so you have them at some point.
 
David Yutzy
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well...

While debugging some pesky bugs, we're trying to track database activity across multiple users and want to log all Stored Procedure calls, by user, and the parameters passed to SQL Server.

Yes, we're using SQL Profiler but the commands aren't sequential by user and sorting it all out is difficult.

What we come up with is to place a call in our central DB code to gather the CallableStatement calls and the passed parameters BEFORE they get to the DB.

We're not sure if it's a driver thing, a JNDI thing, a SQL Server thing, or what.

Also, certain users seem to have unusual behavior versus other users so it could be a permission or security thing as well.
 
Jeanne Boyarsky
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
I don't think it is possible to log at that level. The only places that I can think of to log that info:

1) When you set the string for the prepared statement
2) From a DAO wrapper for the prepared statement
3) From the callable statement itself
 
David Yutzy
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found a way to get what I need. We were having issues with the Microsoft SQL Server driver so I tried out the JTDS Open Source driver instead and found a CallableStatement_Base class in the driver source. By casting a regular CallableStatement (passed into my DAO), I was able to get the name of the Procedure and the parameters passed, all in a generic way.

I can post some code if anyone is interested.
[ July 07, 2004: Message edited by: David Yutzy ]
 
Jeanne Boyarsky
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool! Good to know a way of doing it.
 
Honk if you love justice! And honk twice for tiny ads!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic