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 suprememenu <sh...@gmail.com> on 2010/01/28 12:04:33 UTC
how to write Sql query in system out or to a log using ibatis?
hi all,
Can anyone can guide me how can i write the sql query in system.out?
This query is in a.xml file
<select id="getDetailsId" resultClass="Trans" parameterClass="string">
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=#Id#
</select>
when i call this query i need to write to the System.out the executing of
the query
for
System.out("The executing query is "+
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=25662);
when i use in normal jdbc connection
like for ex
sql="select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id="+<%=id%>
System.out("The executing query is "+ sql);
rs.executeQuery(sql)
I tried to system.out to just know the query before executing .
--
View this message in context: http://old.nabble.com/how-to-write-Sql-query-in-system-out-or-to-a-log-using-ibatis--tp27354226p27354226.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
RE: how to write Sql query in system out or to a log using ibatis?
Posted by Tom Henricksen <To...@A-t-g.com>.
Use something like log4j and add something like this to your log4j.xml.
<logger name="java.sql">
<level value="debug" />
</logger>
You will get something like this:
java.sql.PreparedStatement - {pstm-100028} Executing Statement:
SELECT * FROM EMP WHERE EMPNAME = ?
java.sql.PreparedStatement - {pstm-100028} Parameters: [BOB]
java.sql.PreparedStatement - {pstm-100028} Types: [java.lang.String]
System.out.println should be avoided.
-----Original Message-----
From: suprememenu [mailto:shaikhid@gmail.com]
Sent: Thursday, January 28, 2010 5:05 AM
To: user-java@ibatis.apache.org
Subject: how to write Sql query in system out or to a log using ibatis?
hi all,
Can anyone can guide me how can i write the sql query in
system.out?
This query is in a.xml file
<select id="getDetailsId" resultClass="Trans" parameterClass="string">
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=#Id#
</select>
when i call this query i need to write to the System.out the executing
of
the query
for
System.out("The executing query is "+
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=25662);
when i use in normal jdbc connection
like for ex
sql="select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id="+<%=id%>
System.out("The executing query is "+ sql);
rs.executeQuery(sql)
I tried to system.out to just know the query before executing .
--
View this message in context:
http://old.nabble.com/how-to-write-Sql-query-in-system-out-or-to-a-log-u
sing-ibatis--tp27354226p27354226.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
RE: how to write Sql query in system out or to a log using ibatis?
Posted by meindert <me...@eduflex.com>.
That question comes up a lot, you can log the actual query if you switch
log4j logging on (see documentation) but
a) I wouldn't know a easy way to get the query back to your code
b) The query is parameterized, the parameter values are in the log
Meaning you can get the query string like
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=?);
What is send to the JDBC layer
-----Original Message-----
From: suprememenu [mailto:shaikhid@gmail.com]
Sent: 28 January 2010 01:05 PM
To: user-java@ibatis.apache.org
Subject: how to write Sql query in system out or to a log using ibatis?
hi all,
Can anyone can guide me how can i write the sql query in system.out?
This query is in a.xml file
<select id="getDetailsId" resultClass="Trans" parameterClass="string">
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=#Id#
</select>
when i call this query i need to write to the System.out the executing of
the query
for
System.out("The executing query is "+
select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id=25662);
when i use in normal jdbc connection
like for ex
sql="select sequenceId,
name,
lastname,
mobileNo,
from mytable where
Id="+<%=id%>
System.out("The executing query is "+ sql);
rs.executeQuery(sql)
I tried to system.out to just know the query before executing .
--
View this message in context:
http://old.nabble.com/how-to-write-Sql-query-in-system-out-or-to-a-log-using
-ibatis--tp27354226p27354226.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.733 / Virus Database: 271.1.1/2650 - Release Date: 01/27/10
21:36:00
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org