Hi Bill,
I am using a similar setup and it works for me. I have described my
procedure in a previous post (I hope to get a working link...):
http://groups.google.com/group/google-web-toolkit/tree/browse_frm/thread/a60c42b29bbce71f/5b083ddda237e2e0?rnum=1#doc_d5da39ec906f4353
The only difference is I am on Linux (Ubuntu 9.10), but I do not think
it should make any difference.
I am using PHP Data Objects (PDO) with MySQL driver to access DB.
I post my PHP script here as an example. This simply return a custom
json file with data from a SQL query. I retrieve it via Restlet-GWT
client.
<?php
header("Content-type: application/json");
$columns = array('plantId', 'name', 'description');
try {
$user = 'anuser';
$pass = 'apassword';
$dbh = new PDO('mysql:host=localhost;dbname=anuserdb1', $user,
$pass, array(
PDO::ATTR_PERSISTENT => true
));
echo '{"columns":', json_encode($columns), ',"rows":[';
foreach($dbh->query('SELECT * FROM Plants') as $row) {
$plant = array();
foreach ($columns as $column) {
$plant[] = $row[$column];
}
echo json_encode($plant), ',';
}
echo ']}';
} catch (PDOException $e) {
header("HTTP/1.1 500 DB connection error");
exit;
}
$dbh = null;
?>
On 9 Apr, 10:26, BillGordon <[email protected]> wrote:
> Hi Sri,
>
> Thanks for the suggestion - Google App Engine isn't installed, though.
>
> Bill
>
> On Apr 8, 4:16 pm, Sripathi Krishnan <[email protected]>
> wrote:
>
> > Check your eclipse settings - Google App Engine may be enabled. GAE doesn't
> > allow you to use databases (or open network connections).
>
> > --Sri
>
> > On 8 April 2010 02:39, BillGordon <[email protected]> wrote:
>
> > > I followed the tutorial to create the JSON PHP variant of the
> > > Stockwatcher application. I quickly discovered that this won't work in
> > > Hosted mode unless web.xml is modified what was to me a non-obvious
> > > way. This information is missing from the tutorial and could be
> > > usefully added to prevent others from having to re-invent the wheel.
>
> > > With an unmodified web.xml, the built-in Jetty simply returns the text
> > > of a requested .php file, rather than executing the .php file and
> > > returning the output. (My Google searches showed that others had
> > > encountered this problem, but no-one has bothered posting a solution
> > > far as I could see.)
>
> > > The solution is to modify web.xml along the lines of
>
> > > <!-- Servlets -->
> > > <servlet>
> > > <servlet-name>PHP</servlet-name>
> > > <servlet-class>org.mortbay.servlet.CGI</servlet-class>
> > > <init-param>
> > > <param-name>commandPrefix</param-name>
> > > <param-value>"H:\Program Files\PHP\php-cgi.exe"</param-value>
> > > </init-param>
> > > <!-- Path, other ENV_variables including ENV_SystemRoot,
> > > ENV_REDIRECT_STATUS on Windows -->
> > > </servlet>
>
> > > <servlet-mapping>
> > > <servlet-name>PHP</servlet-name>
> > > <url-pattern>*.php</url-pattern>
> > > <!-- Any other URL patterns that are needed by your app to be
> > > processed by PHP -->
> > > </servlet-mapping>
>
> > > but pointing to your particular PHP installation, of course.
>
> > > This works as expected. However, I became ambitious, and extended the
> > > project to use a .php script that uses MySQL. This unfortunately fails
> > > - PHP is unable to open a socket to the MySQL server. The same script
> > > works perfectly when called from the command line, or loaded through
> > > IIS. It appears that the environment in which Jetty runs the script
> > > restricts PHP's ability to use the TCP/IP stack. Now, does anyone have
> > > a solution for this?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Web Toolkit" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-web-toolkit%[email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.