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 Lurtz Ugluk <lu...@yahoo.es> on 2006/03/08 17:39:21 UTC

get the statement

 How Can I get the sql statement that de iBatis
execute?
I need the sql statement at runtime to create a
String and save it.
 
 Thanks.


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

Re: get the statement

Posted by Beemsterboer Software <ha...@beemsterboer-software.nl>.
Get the iBatis source and look inside the kitchen for the following class:

com\ibatis\sqlmap\engine\execution\SqlExecutor

As its name suggests, this class executes sql statements, e.g.:

  public void executeQuery(RequestScope request, Connection conn, String 
sql, Object[] parameters,
                           int skipResults, int maxResults, 
RowHandlerCallback callback)
      throws SQLException

You can use this class to cook up your own version.

Greetings,
Hans.

Lurtz Ugluk wrote:
>  How Can I get the sql statement that de iBatis
> execute?
> I need the sql statement at runtime to create a
> String and save it.
>  
>  Thanks.
>
>   


Re: get the statement

Posted by Nathan Maves <Na...@Sun.COM>.
Lurtz,

As of right now I don't believe that ibatis can do this.  Feel free  
to open a JIRA request for this type of enhancement.

Nathan
On Mar 9, 2006, at 1:15 AM, Lurtz Ugluk wrote:

> I've see the log, and It's fine, but I want to store
> some especial INSERTS, UPDATES and DELETES that the
> application is executing, to create a file with that
> especial statements.
>
> Have I read the log and get lines from it? hummmm
>
> Example
>
> select * from table
> <dynamic WHERE>
> <isNull prepend = AND > FIELD = #field# </isNull>
> </dynamic>
>
> iBatis knows if the FIELD is null and then the SQL may
> be
> select * from table
> or
> select * from table where FIELD  = ?
>
> I want to know the sql in the implementation
> (sqlmapdao) after the execution (or before, I don't
> mind).
> Now I'm seeing if the parameters are null and doing
> the sql string by myself, but if I could get the sql
> from iBatis..... much better ;-)
>
> Thanks and excuse my english ;)
>
>
>  --- Nathan Maves <Na...@Sun.COM> escribió:
>
>> The logging will give you all the information that
>> you need.
>>
>> Ex.
>>
>> select * from table where id = #id#
>>
>> The logging will show you the PS
>>
>> select * from table where id = ?
>>
>> And then show you the parameters.  You will be able
>> to see just what
>> is being called.  The only gotcha is that you can
>> not copy and paste
>> the sql in one shot.  You have to do the
>> substitution for the
>> parameters yourself.
>>
>> Give it a try :)
>>
>>
>> Nathan
>>
>>
>> On Mar 8, 2006, at 10:09 AM, Lurtz Ugluk wrote:
>>
>>> I've look the link above and I read "Why? Because
>> the
>>> only information we have available is the
>>> PreparedStatement and the parameters."
>>> That's that I need (I think ;-) ), with the
>>> preparedStatement I can get the SQL that I will
>>> execute, can't I?
>>> How can I get that PreparedStatement and its
>>> parameters at runtime ?
>>>
>>> More thanks
>>>
>>>  --- Nathan Maves <Na...@Sun.COM> escribió:
>>>
>>>> Not really sure if you truly want to save the sql
>> or
>>>> just look at if
>>>> for debugging purposes.
>>>>
>>>> If you are just trying to debug the look at
>> setting
>>>> up logging for
>>>> your application.  The following page on the wiki
>>>> should help you set
>>>> that up.
>>>>
>>>>
>>>
>>
> http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do
>>>>
>>>> +I+get+SqlMapClient+to+log+SQL+statements
>>>>
>>>> Nathan
>>>>
>>>> On Mar 8, 2006, at 9:39 AM, Lurtz Ugluk wrote:
>>>>
>>>>>  How Can I get the sql statement that de iBatis
>>>>> execute?
>>>>> I need the sql statement at runtime to create a
>>>>> String and save it.
>>>>>
>>>>>  Thanks.
>>>>>
>>>>>
>>>>> 		
>>>>> ______________________________________________
>>>>> LLama Gratis a cualquier PC del Mundo.
>>>>> Llamadas a fijos y móviles desde 1 céntimo por
>>>> minuto.
>>>>> http://es.voice.yahoo.com
>>>>
>>>>
>>>
>>>
>>>
>>> 		
>>> ______________________________________________
>>> LLama Gratis a cualquier PC del Mundo.
>>> Llamadas a fijos y móviles desde 1 céntimo por
>> minuto.
>>> http://es.voice.yahoo.com
>>
>>
>
>
>
> 		
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com


Re: get the statement

Posted by Lurtz Ugluk <lu...@yahoo.es>.
I've see the log, and It's fine, but I want to store
some especial INSERTS, UPDATES and DELETES that the
application is executing, to create a file with that
especial statements.

Have I read the log and get lines from it? hummmm 

Example

select * from table
<dynamic WHERE>
<isNull prepend = AND > FIELD = #field# </isNull>
</dynamic>

iBatis knows if the FIELD is null and then the SQL may
be
select * from table  
or 
select * from table where FIELD  = ?

I want to know the sql in the implementation
(sqlmapdao) after the execution (or before, I don't
mind). 
Now I'm seeing if the parameters are null and doing
the sql string by myself, but if I could get the sql
from iBatis..... much better ;-)

Thanks and excuse my english ;)


 --- Nathan Maves <Na...@Sun.COM> escribió:

> The logging will give you all the information that
> you need.
> 
> Ex.
> 
> select * from table where id = #id#
> 
> The logging will show you the PS
> 
> select * from table where id = ?
> 
> And then show you the parameters.  You will be able
> to see just what  
> is being called.  The only gotcha is that you can
> not copy and paste  
> the sql in one shot.  You have to do the
> substitution for the  
> parameters yourself.
> 
> Give it a try :)
> 
> 
> Nathan
> 
> 
> On Mar 8, 2006, at 10:09 AM, Lurtz Ugluk wrote:
> 
> > I've look the link above and I read "Why? Because
> the
> > only information we have available is the
> > PreparedStatement and the parameters."
> > That's that I need (I think ;-) ), with the
> > preparedStatement I can get the SQL that I will
> > execute, can't I?
> > How can I get that PreparedStatement and its
> > parameters at runtime ?
> >
> > More thanks
> >
> >  --- Nathan Maves <Na...@Sun.COM> escribió:
> >
> >> Not really sure if you truly want to save the sql
> or
> >> just look at if
> >> for debugging purposes.
> >>
> >> If you are just trying to debug the look at
> setting
> >> up logging for
> >> your application.  The following page on the wiki
> >> should help you set
> >> that up.
> >>
> >>
> >
>
http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do
> >>
> >> +I+get+SqlMapClient+to+log+SQL+statements
> >>
> >> Nathan
> >>
> >> On Mar 8, 2006, at 9:39 AM, Lurtz Ugluk wrote:
> >>
> >>>  How Can I get the sql statement that de iBatis
> >>> execute?
> >>> I need the sql statement at runtime to create a
> >>> String and save it.
> >>>
> >>>  Thanks.
> >>>
> >>>
> >>> 		
> >>> ______________________________________________
> >>> LLama Gratis a cualquier PC del Mundo.
> >>> Llamadas a fijos y móviles desde 1 céntimo por
> >> minuto.
> >>> http://es.voice.yahoo.com
> >>
> >>
> >
> >
> >
> > 		
> > ______________________________________________
> > LLama Gratis a cualquier PC del Mundo.
> > Llamadas a fijos y móviles desde 1 céntimo por
> minuto.
> > http://es.voice.yahoo.com
> 
> 



		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

Re: get the statement

Posted by Nathan Maves <Na...@Sun.COM>.
The logging will give you all the information that you need.

Ex.

select * from table where id = #id#

The logging will show you the PS

select * from table where id = ?

And then show you the parameters.  You will be able to see just what  
is being called.  The only gotcha is that you can not copy and paste  
the sql in one shot.  You have to do the substitution for the  
parameters yourself.

Give it a try :)


Nathan


On Mar 8, 2006, at 10:09 AM, Lurtz Ugluk wrote:

> I've look the link above and I read "Why? Because the
> only information we have available is the
> PreparedStatement and the parameters."
> That's that I need (I think ;-) ), with the
> preparedStatement I can get the SQL that I will
> execute, can't I?
> How can I get that PreparedStatement and its
> parameters at runtime ?
>
> More thanks
>
>  --- Nathan Maves <Na...@Sun.COM> escribió:
>
>> Not really sure if you truly want to save the sql or
>> just look at if
>> for debugging purposes.
>>
>> If you are just trying to debug the look at setting
>> up logging for
>> your application.  The following page on the wiki
>> should help you set
>> that up.
>>
>>
> http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do
>>
>> +I+get+SqlMapClient+to+log+SQL+statements
>>
>> Nathan
>>
>> On Mar 8, 2006, at 9:39 AM, Lurtz Ugluk wrote:
>>
>>>  How Can I get the sql statement that de iBatis
>>> execute?
>>> I need the sql statement at runtime to create a
>>> String and save it.
>>>
>>>  Thanks.
>>>
>>>
>>> 		
>>> ______________________________________________
>>> LLama Gratis a cualquier PC del Mundo.
>>> Llamadas a fijos y móviles desde 1 céntimo por
>> minuto.
>>> http://es.voice.yahoo.com
>>
>>
>
>
>
> 		
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com


Re: get the statement

Posted by Lurtz Ugluk <lu...@yahoo.es>.
I've look the link above and I read "Why? Because the
only information we have available is the
PreparedStatement and the parameters." 
That's that I need (I think ;-) ), with the
preparedStatement I can get the SQL that I will
execute, can't I?
How can I get that PreparedStatement and its
parameters at runtime ?

More thanks

 --- Nathan Maves <Na...@Sun.COM> escribió:

> Not really sure if you truly want to save the sql or
> just look at if  
> for debugging purposes.
> 
> If you are just trying to debug the look at setting
> up logging for  
> your application.  The following page on the wiki
> should help you set  
> that up.
> 
>
http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do
> 
> +I+get+SqlMapClient+to+log+SQL+statements
> 
> Nathan
> 
> On Mar 8, 2006, at 9:39 AM, Lurtz Ugluk wrote:
> 
> >  How Can I get the sql statement that de iBatis
> > execute?
> > I need the sql statement at runtime to create a
> > String and save it.
> >
> >  Thanks.
> >
> >
> > 		
> > ______________________________________________
> > LLama Gratis a cualquier PC del Mundo.
> > Llamadas a fijos y móviles desde 1 céntimo por
> minuto.
> > http://es.voice.yahoo.com
> 
> 



		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

Re: get the statement

Posted by Nathan Maves <Na...@Sun.COM>.
Not really sure if you truly want to save the sql or just look at if  
for debugging purposes.

If you are just trying to debug the look at setting up logging for  
your application.  The following page on the wiki should help you set  
that up.

http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do 
+I+get+SqlMapClient+to+log+SQL+statements

Nathan

On Mar 8, 2006, at 9:39 AM, Lurtz Ugluk wrote:

>  How Can I get the sql statement that de iBatis
> execute?
> I need the sql statement at runtime to create a
> String and save it.
>
>  Thanks.
>
>
> 		
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com