AndyLu AndyLu - 1 year ago 115
Java Question

Google App Engine - Connect to remote datastore locally using Objectify

I've looked everywhere and wasted a lot of time on something that I think is probably very simple. Thanks for the help in advance. I have a google app engine app using the cloud datastore written in Java. I have an entity class as follows:

public class Student {

@Id private Long studentId;
@Index private League league;
@Index private String year;
private String firstName;
private String lastName;

I have a csv file of 1K students. I need to upload this info into the cloud datastore. I also generally want to interact locally with my remote datastore for testing etc. I want to be able to do the following (row is a row of the csv file, i'll handle that).

for ( Row row : Iterator<Row> ){
Student student = new Student(row);

This code should run on my local machine and save entities to the cloud datastore.
I can connect to the datastore using the GCD JSON following the methodology at

However, this doesn't allow for the use of objectify. My app relies on objectify and need to populate in that manner. Does anyone have a clue how to generically connect and populate the datastore that allows objectify/Java? Thanks!

Answer Source

If you need to connect to remote datastore from local machine, I think you need to use the Remote API:

The Java SDK includes a library called Remote API that lets you transparently access App Engine services from any Java application. For example, you can use Remote API to access a production datastore from an app running on your local machine.

This works for Datastore API, which are used by Objectify. So you're good to go.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download