开发者

Can I use a MySQL database with an App Engine application

I know that App Engine has its own datastore. This is great for most cases and fairly easy to used. However, we have a MySQL database that we use for severa开发者_StackOverflow社区l applications and not all of them are Web based. We want to use App Engine for many reasons, but would like to have the App Engine application access our MySQL database. The documentation I've found doesn't clearly state whether I can do this or not. Has anyone done it or have pointers to documents that show how to do it?


Google recently announced support for Cloud SQL in GAE - http://googleappengine.blogspot.com/2011/10/google-cloud-sql-your-database-in-cloud.html


You cannot create a direct network connection to your database. The overview page outlines the major restrictions that would stop you from using Mysql - the major one in this case being "arbitrary network connections". You can only make http(s) calls from within app engine.

The JVM runs in a secured "sandbox" environment to isolate your application for service and security. The sandbox ensures that apps can only perform actions that do not interfere with the performance and scalability of other apps. For instance, an app cannot spawn threads, write data to the local file system or make arbitrary network connections. An app also cannot use JNI or other native code. The JVM can execute any Java bytecode that operates within the sandbox restrictions.


The simple answer is : NO.

The way to access your MySQL would be by exposing a web-service interface to it.


Look at SDC (Secure Data Connector).

And same question

App Engine and MySQL


Using a Local MySQL Instance During Development:

 

 import com.google.appengine.api.rdbms.AppEngineDriver;
    public static void makeConnection() {
        try {
            if (conn == null || !conn.isValid(0)) {
                String url = "localhost/databasename";
                String username = "root";
                String password = "password";
                DriverManager.registerDriver(new AppEngineDriver());
                String urlForConnection = "jdbc:mysql://" + url;
                conn = DriverManager.getConnection(urlForConnection, username, password);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

// in web.xml
    <filter>
        <filter-name>_ah_DevSocketFilter</filter-name>
        <filter-class>com.google.appengine.api.socket.dev.DevSocketFilter</filter-class>
        <init-param>
            <param-name>use-native-sockets</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>_ah_DevSocketFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Using cloud

 

    DriverManager.registerDriver(new AppEngineDriver());
              c = DriverManager.getConnection("jdbc:google:rdbms://instance_name/guestbook");


Yes, but not the normal, by creating a web service or a simple php page that acts as an intermediate and passing the data in json or xml.


Yes, you can.

Read about int https://cloud.google.com/sql/docs

You can use it with any language supported by GAE and connect over it from outside GAE too.


I am still in the learning phase of all this, but I am fairly certain you can do this now a few ways:

  • Link Apps Scripts to App Engine and use the JDBC and ink it to Google
  • Store your SQL database on Google Cloud Storage
  • Connect Apps Scripts via spreadsheet scripting
  • Use their Cloud SQL

"Google Apps Script has the ability to make connections to databases via JDBC with the Jdbc Service. The current support extends to MySQL, Microsoft SQL Server and Oracle. Apps Script makes it easy to connect to databases hosted on Google Cloud SQL, but also works with other cloud hosting platforms and even local databases." https://developers.google.com/apps-script/jdbc

(origionally from App Engine Question)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜