Esbach, Brandon wrote:
Hmm the list server messes up formatting :(
Added a bunch of lines to see if that's better
<%
import groovy.sql.Sql;
def sendSQL = Sql.newInstance("jdbc:mysql://localhost/myotherdatabase",
"username-can-be-root",
"password-goes-here", "com.mysql.jdbc.Driver")
sendSQL.eachRow("select * from mytable") {row ->
println "${row.sessions_guid}"
}
%>
Hi,
Prior to trying to understand last Vincent entry, I am trying to make the sample code to
work here.
I have no problem to get single values by using the firstRow method of the sqll class as
here...
11: <%
12: import groovy.sql.Sql;
13: def sendSQLoo =
Sql.newInstance("jdbc:mysql://mire.environmentalchange.net/epec"epec",
"epec_ReadOnly", "epec_ReadOnly", "com.mysql.jdbc.Driver")
14: row_a = sendSQLoo.firstRow("select code from epec.spot")
15: println "Row: code = ${row_a.code}"
16: %>
But I am not able the get an iteration. I've tried...
19: <%
20: import groovy.sql.Sql;
21: println "This is a sample to access ibdona in *localhost*"
22: def sendSQLibd = Sql.newInstance("jdbc:mysql://localhost/ibdona",
"root", "", "com.mysql.jdbc.Driver")
23: sendSQLibd.eachRow("SELECT * FROM ibdona.library_location l") {row
->println "${row.location}"}
24: %>
and
1: <%
2: import groovy.sql.Sql
3: sql = Sql.newInstance("jdbc:mysql://localhost/ibdona", "root",
"", "com.mysql.jdbc.Driver")
4: sql.eachRow("SELECT * FROM ibdona.library_location l", { println it.location
+ " -- ${it.year} --"} );
5: %>
No error messages. Just a white page in the second script or a page with the static line
printed by line 21 for the first one. I'm guessing the query is successful and the sql
instance is correctly created, but for any reason I am failing when trying to print the
iteration. Please, could you help me with this issue? Thanks!
Best,
Ricardo
--
Ricardo RodrÃguez
Your XEN ICT Team