[squeak-dev] Mysql

Bèrto ëd Sèra berto.d.sera at gmail.com
Fri Jun 20 10:55:09 UTC 2008

I' really doing something wrong :) This is what I tried:

| connection spec statement resultSet value OWm2command|
Socket initializeNetwork.
Transcript open.
spec :=    (JdmConnectionSpec new initialize
        user: 'root'; password: 'owm2';
        host: (NetNameResolver addressForName: 'localhost');
        database: 'owm2';
        port: 3306).

OWm2command := 'OWM2_PARSE(',$' asString,'<?xml version="1.0"
encoding="UTF-8" ?><OWM2><Query command="list" type="class" id="12" ><Output
/></Query></OWM2>',$' asString,')'.

connection := JdmConnection on: spec.
statement := connection createStatement.
resultSet := statement executeQuery: OWm2command.
"print column names"
Transcript cr; show: (resultSet columns collect: [:col | col name])

[resultSet next]
    value := resultSet valueNamed: 'id_object'. "get column named name"
    Transcript cr; show: value printString.
connection close.

Obviously it could not go to the end, but I was expecting to be able to
inspect the resultSet and find out how to call the "column" from there.
Actually this function returns simply an XML string. Yet the point where I'm
breaking is the query execution itself. It *might* be because the concation
I tried looks weird. What I see inspecting the values is:
'OWM2_PARSE(''<?xml version="1.0" encoding="UTF-8" ?><OWM2><Query
command="list" type="class" id="12" ><Output /></Query></OWM2>'')'

Now... this will surely break because it was meant to have " only for the
internal XML parameters...so this way the string cannot be passed. I'm sure
there's a way, only I cannot find it.

2008/6/20 Bèrto ëd Sèra <berto.d.sera at gmail.com>:

> All seems to work fine, I have but one problem: how do you state a "string
> in a string"? The query I need to execute inputs an XML command to a stored
> proc, so it looks like
> resultSet := statement executeQuery: 'OWM2_PARSE('<?xml version="1.0"
> encoding="UTF-8" ?><OWM2><Query command="list" type="class" id="12" ><Output
> /></Query></OWM2>')'.
> Can't remember what's the equivalent of
> resultSet := statement executeQuery: 'OWM2_PARSE(/'<?xml version="1.0"
> encoding="UTF-8" ?><OWM2><Query command="list" type="class" id="12" ><Output
> /></Query></OWM2>/')'.
> in smalltalk...
> Very stupid question, I know :(
> Bèrto
> 2008/6/16 Keith Hodges <keith_hodges at yahoo.co.uk>:
> Bèrto ëd Sèra wrote:
>>> A connection for statement is not a problem, since I can pack any number
>>> of queries into a single XML statement it's not going to impact on
>>> performance ;) I'll try this later this week and let you know if it works.
>>> Thanks
>>> Berto
>>>  Try http://www.squeaksource.com/MySql for more recent version of the
>> driver. You don't actually need a new connection for each query, but that is
>> the way that I use it myself.
>> There is also some code for using the driver in
>> http://mc.lukas-renggli.ch/magritteaddons package Magritte-RDB
>> Keith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080620/9639857f/attachment.htm

More information about the Squeak-dev mailing list