Dear All,

I'm trying to use remote_api to query and update an entity on
datastore.
I read the following article and successfully query the data.

http://code.google.com/intl/en/appengine/docs/java/tools/remoteapi.html

But the poor thing is, after the query, I would like to update the
entity. But it didn't work without any error message.

Here is part of my code. Would you plz help to check it?? Thanks!!

=======================
public class RemoteApiExample {
    public static void main(String[] args) throws IOException {
        String username = System.console().readLine("username: ");
        String password =
            new String(System.console().readPassword("password: "));
        RemoteApiOptions options = new RemoteApiOptions()
            .server("9x9tvqa.appspot.com", 443)
            .credentials(username, password);
        RemoteApiInstaller installer = new RemoteApiInstaller();
        installer.install(options);
        try {
            DatastoreService ds =
DatastoreServiceFactory.getDatastoreService();
//            System.out.println("Key of new entity is " +
//                ds.put(new Entity("Hello Remote API!")));

// My code is beginning here
            Key k0 = KeyFactory.createKey("MsoChannel", 7);
            Entity e0;

            e0 = ds.get(k0);

            String langCode = (String) e0.getProperty("langCode");
            System.out.println("Key=7, langCode=" + langCode);  // <--
this works, langCode="en"

            System.out.println("Now we are going to modify it to be
langCode=\"zh\"...");
            e0.setProperty("langCode", "zh");
            ds.put(e0);

        } catch (EntityNotFoundException e) {
            System.out.println("Exception caught!");

        }
        finally {
            installer.uninstall();
        }
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-appengine-java?hl=en.

Reply via email to