Hello, I am using JDBC driver I would like to know if there is a way to display the SQL query associated with a PreparedStatement. I would like to fill the parameters, and then display the query as it will be thrown to the Websphere server to debug my application. Sample: PreparedStatement ps = new connection.prepareStatement("Select * from foo where bar = ?") ; ps.setInt(1, 1) ; and then use somethind like: // This line does not actually work. System.out.println("Query is: " +ps.toString()) ; // But i would like it to print Query is: Select * from foo where bar = 1 Thanks
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Check out the DebuggableStatement. There is a thread about it here But first... "longbeach forever", Display names are not allowed to be fictitious. Please see the JavaRanch naming policy here then edit your profile to set a valid display name. Accounts with invalid display names get deleted. thanks, Dave.
You just updated it to another invalid display name. You need to look at the JavaRanch naming policy. Your display name must be two words: your first name, a space, then your last name. Fictitious names are not allowed. Please try again. It's unfortunate when get deleted through misunderstandings! thanks, Dave