You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Lucy Fang <fa...@acs.rutgers.edu> on 2004/12/16 20:25:08 UTC
Are there any ways to view the SQL mapping statements?
Hi,
Are there any ways I can view the SQL mapping statements after created a
dynamic SQL statement and passed all of parameters to it?
I have a dynamic SQL mapping statement with
select * from campus where campuscode in #campusCode#
if I use campuscode in (03,04), it works good. But if I use the parameter
campusCode replace the value, it doesn't work. I pretty sure the parameter
value is "(03,04)".
The database I am using is Oracle and iBatis is SQL Map 2.0.
Thanks.
Lucy
RE: Are there any ways to view the SQL mapping statements?
Posted by Lucy Fang <fa...@acs.rutgers.edu>.
Hi Brandon,
I have set up my log4j.properties for iBatis (it works with other part of my
application) by following the user guide, but I still can't get the sql
statement log. I don't know how I can get a special sql statement pass to
the log in the java code. For example I want to view the sql statement for
"selectOrganizationById".
Thanks.
Lucy
Here is my Log4j.properties
===========================
log4j.rootLogger=DEBUG, stdout
# SqlMap logging configuration...
#log4j.logger.com.ibatis=DEBUG
#log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
#log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
#log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
#log4j.logger.java.sql.Connection=DEBUG
#log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
#log4j.logger.java.sql.ResultSet=DEBUG
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
-----Original Message-----
From: Brandon Goodin [mailto:brandon.goodin@gmail.com]
Sent: Thursday, December 16, 2004 3:58 PM
To: fang@acs.rutgers.edu
Cc: ibatis-user-java@incubator.apache.org
Subject: Re: Are there any ways to view the SQL mapping statements?
You could use logging to view your sql statement and the parameters it is
receiving. But, there is no simple way to view the sql statement combined
with your parameters. IBatis uses PreparedStatement underneath and there is
no way to view the compiled sql statement in java. There is a section in the
User Guide that explains how to log your SQL
On Thu, 16 Dec 2004 14:25:08 -0500, Lucy Fang <fa...@acs.rutgers.edu> wrote:
>
>
> Hi,
>
> Are there any ways I can view the SQL mapping statements after created
> a dynamic SQL statement and passed all of parameters to it?
>
> I have a dynamic SQL mapping statement with
> select * from campus where campuscode in #campusCode#
> if I use campuscode in (03,04), it works good. But if I use the parameter
> campusCode replace the value, it doesn't work. I pretty sure the parameter
> value is "(03,04)".
>
> The database I am using is Oracle and iBatis is SQL Map 2.0.
>
> Thanks.
>
> Lucy
Re: Are there any ways to view the SQL mapping statements?
Posted by Brandon Goodin <br...@gmail.com>.
You could use logging to view your sql statement and the parameters it
is receiving. But, there is no simple way to view the sql statement
combined with your parameters. IBatis uses PreparedStatement
underneath and there is no way to view the compiled sql statement in
java. There is a section in the User Guide that explains how to log
your SQL
On Thu, 16 Dec 2004 14:25:08 -0500, Lucy Fang <fa...@acs.rutgers.edu> wrote:
>
>
> Hi,
>
> Are there any ways I can view the SQL mapping statements after created a
> dynamic SQL statement and passed all of parameters to it?
>
> I have a dynamic SQL mapping statement with
> select * from campus where campuscode in #campusCode#
> if I use campuscode in (03,04), it works good. But if I use the parameter
> campusCode replace the value, it doesn't work. I pretty sure the parameter
> value is "(03,04)".
>
> The database I am using is Oracle and iBatis is SQL Map 2.0.
>
> Thanks.
>
> Lucy
RE: Are there any ways to view the SQL mapping statements?
Posted by Lucy Fang <fa...@acs.rutgers.edu>.
Brice,
It does solve my problem.
Thanks.
Lucy
-----Original Message-----
From: Brice Ruth [mailto:bdruth@gmail.com]
Sent: Thursday, December 16, 2004 3:50 PM
To: fang@acs.rutgers.edu
Cc: ibatis-user-java@incubator.apache.org
Subject: Re: Are there any ways to view the SQL mapping statements?
You'll need to use $campusCode$ to use the literal value, otherwise iBATIS
will quote the string, which won't work. This doesn't directly answer your
question, but it should solve your problem :)
To answer your question, yes, you can use log4j to view the SQL statements
that are sent to the database. The iBATIS documentation contains information
on how to set this up, and of course the log4j website and the
commons-logging documentation (which is what iBATIS
uses) will be your friends.
I've also heard a product called P6spy mentioned which does this at the JDBC
driver level, if I'm not mistaken. I don't have any experience with it, tho.
Regards,
Brice
On Thu, 16 Dec 2004 14:25:08 -0500, Lucy Fang <fa...@acs.rutgers.edu> wrote:
>
>
> Hi,
>
> Are there any ways I can view the SQL mapping statements after created
> a dynamic SQL statement and passed all of parameters to it?
>
> I have a dynamic SQL mapping statement with
> select * from campus where campuscode in #campusCode#
> if I use campuscode in (03,04), it works good. But if I use the parameter
> campusCode replace the value, it doesn't work. I pretty sure the parameter
> value is "(03,04)".
>
> The database I am using is Oracle and iBatis is SQL Map 2.0.
>
> Thanks.
>
> Lucy
Re: Are there any ways to view the SQL mapping statements?
Posted by Brice Ruth <bd...@gmail.com>.
You'll need to use $campusCode$ to use the literal value, otherwise
iBATIS will quote the string, which won't work. This doesn't directly
answer your question, but it should solve your problem :)
To answer your question, yes, you can use log4j to view the SQL
statements that are sent to the database. The iBATIS documentation
contains information on how to set this up, and of course the log4j
website and the commons-logging documentation (which is what iBATIS
uses) will be your friends.
I've also heard a product called P6spy mentioned which does this at
the JDBC driver level, if I'm not mistaken. I don't have any
experience with it, tho.
Regards,
Brice
On Thu, 16 Dec 2004 14:25:08 -0500, Lucy Fang <fa...@acs.rutgers.edu> wrote:
>
>
> Hi,
>
> Are there any ways I can view the SQL mapping statements after created a
> dynamic SQL statement and passed all of parameters to it?
>
> I have a dynamic SQL mapping statement with
> select * from campus where campuscode in #campusCode#
> if I use campuscode in (03,04), it works good. But if I use the parameter
> campusCode replace the value, it doesn't work. I pretty sure the parameter
> value is "(03,04)".
>
> The database I am using is Oracle and iBatis is SQL Map 2.0.
>
> Thanks.
>
> Lucy