jiql – 说明文档(一个运行在GAE上面的Mysql)(翻译未完成)
概览
jiql是在JAVA GAE上访问Google Datastore的JDBC wrapper(这个不知道怎么说了,请大家见谅)
jiql支持标准的sql语言进行访问
jiql supports the use of standard SQL as a method for accessing jiql支持使用标准的SQL访问jiql数据储存
设计
jiql介绍一个概念叫做“叶表”(Table Leafs) 。 叶表是一种可以无限量动态添加或者合并在一起形成一个新表的数据储存方式。叶表用SQL提供了一个标准的方法,用来避开GAE不超过一千个返回结果的限制,为了优化结果,在相似叶表中他们拥有相同的父级。这意味着所有的叶表成员都储存在同一个google云节点,可以高速访问数据。
要禁用叶表,可以在创建表的声明末尾添加:
tableleafs=false
Quickstart 快速入门
下载jiql.jar (JAVA Database engine和驱动)放在WEB-INF/lib/目录下
注意: appengine-api.jar也必须置于WEB-INF/lib下面 。该文件是GAE SDK下的重要文件。下面我们将创建一个JDBC连接上jiql数据库
在你需要的地方使用下面的代码:
String url = "jdbc:jiql://local";
String password = "";
String user = "";
Properties props = new Properties();
props.put("user",user);
props.put("password",password);
Class clazz = Class.forName("org.jiql.jdbc.Driver");
Driver driver = (Driver) clazz.newInstance();
Connection Conn = driver.connect(url,props);
下面是一个通过JDBC创建的一个简单GAE留言板程序:
http://jiql.googlecode.com/files/jiql-jdbc-guestbook.war
下载iql-jdbc-guestbook.war后用winrar解压到你的GAE应用目录。
编辑./WEB-INF/appengine-web.xml添加你自己的GAE应用ID。
上传到你的可运行JAVA的GAE上面。
首先你要运行下面的这个jsp页面,这将创建所需要的数据表。
http://yourapp.appspot.com/init.jsp
然后你可以浏览http://yourapp.appspot.com/guestbook.jsp 开始使用这个留言板程序。
源代码也可以在下面的网址下载:
http://jiql.googlecode.com/files/jiql-jdbc-guestbook.src.zip
Remote Access 远程访问
你可以通过JiqlServlet远程访问google datastore。
This requires setting up the GAE-J Server as well as the Client Application configuration. 这就需要建立GAE约翰逊服务器以及客户端应用程序配置。
这需要按照客户端应用配置你的GAE-jiql。
GAE-J 服务的配置:
首先在web.xml中配置JiqlServlet:
<servlet>
<servlet-name>jiqlservlet</servlet-name>
<servlet-class>org.jiql.JiqlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jiqlservlet</servlet-name>
<url-pattern>/jiqlservlet</url-pattern>
</servlet-mapping>
接着在jiql.properties文件中添加验证信息。
File: ./WEB-INF/jiql.properties
Entries:
user=admin
password=jiql
客户端应用程序配置
按照下面的步骤在你的JAVA代码中创建一个到jiql的连接:
String url = "jdbc:jiql:https://yourapp.appspot.com/jiqlservlet";
String user = "admin";
String password = "jiql";
//or
// String url = "jdbc:jiql:https://yourapp.appspot.com/jiqlservlet?user=admin&password=jiql";
Properties props = new Properties();
props.put("user",user);
props.put("password",password);
Class clazz = Class.forName("org.jiql.jdbc.Driver");
Driver driver = (Driver) clazz.newInstance();
Connection Conn = driver.connect(url,props);
远程客户端所需要的lib文件:
jiql.jar
appengine-api.jar
Apache Commons HTTPClient – you may download the bundled JAR here .
jiql一定程度支持了Transactions 。
Transactions 的支持是基于谷歌数据存储Transactions引擎的。 谷歌数据存储不支持全局事务。
Transactions 仅限于Entities/Rows 内或Table/Kind。
这意味着您无法在同一Transactions对Table/Kind执行多个操作。为了使用Transactions,设置enable.transactions连接属性选项为true 。
注意:Transactions不支持远程连接。
Limitations 限制
FILTERS
对于较大的数据集,设置较少的限制条件将只会返回大约1000项结果。(GAE限制)结果将可能返回超时,在这种情况下,你应该尝试更多的限制条件。(这段请参看原文,谢谢~~)
JOINS
When working with large data sets, JOINS should be combined with at least 1 filter acting on a specific table. Otherwise, the query would involve traversing the entirety of all the tables in the JOIN. Such an operation is time consuming and may create a Google App Engine Timeout if the operation exceeds 30 seconds.
Optional Properties 可选属性
date.format
指定的日期格式的日期时间字段。
例如date.format =yyyy / mm / dd
enable.transactions
使Transactions(请参阅交易专题)
例如enable.transactions=true
DatabaseProductVersion
用来模拟其他数据库版本,如MySQL的。
例如DatabaseProductVersion=4.0.0
DriverVersion
用来模拟其他数据库类型,如MySQL的。
例如 DriverVersion=mysql-connector-java-5.0.4 ()
Catalog
用于指定数据库目录。
例如Catalog=jiql
MetaCache
用于缓存元数据,如DatabaseMetaData 。
例如 MetaCache=true
jiql Functions
除了标准的SQL函数,有一些jiql特殊函数。
LOAD
LOAD DATA INTO TABLE table_name INTEXT column1,column2
1,’text1′ 1
2,’text2′ 2
tableleafs
指定是否要使用叶表(默认使用) 。
tableleafs =false
prefix
指定是否要为jiql所创建的表添加一个前缀 (默认为true)
prefix =false
prefix_value
指定要为jiql创建的表添加的前缀名称(默认为“jiql” )
prefix_value =jiql
如何不改变MYSQL指令直接运行PHP
在Google App Engine for JAVA上运行PHP需要一个集成jiql的Quercus(一个在java上执行的php5)。
请在下面的网址下载:
jiql – quercus.war -一个集成jiql的Quercus 。
jiql – quercus.src.zip -集成jiql的Quercus源码
下载jiql – quercus.war后 ,用winrar解压到您的GAE程序目录。
Add your PHP files to the root of the unpacked Quercus application. 添加你的PHP文件到解压Quercus的目录下面。
编辑./WEB-INF/appengine-web.xml 文件并添加您的GAE程序ID 。
上传到GAE服务器。
Below is a simple PHP application from PLUS2NET as a starting PHP example: 下面是一个来自plus4net的简单PHP应用:
http://www.plus2net.com/php_tutorial/guest_book.zip
JRuby on RAILS JRuby on Rails的
Download jiql.jar java database engine and driver library and place under WEB-INF/lib/. 下载jiql.jar Java的数据库引擎和驱动程序库和下举行WEB-INF/lib / 。
Configure your database.yml like so: 配置database.yml象这样:
production: 生产:
adapter: jdbc 适配器: JDBC的
driver: org.jiql.jdbc.Driver 司机: org.jiql.jdbc.Driver
url: jdbc:jiql:local 网址: JDBC的: jiql :地方
username: admin 用户名:管理员
password: appcloem 密码: appcloem
encoding: utf8 编码:很少
Now of course Google App Engine for JAVA does not allow you to perform pre-deployment tasks, 现在当然谷歌应用程序引擎的JAVA不允许您执行部署前的任务,
such as running rake to setup your RAILS application database. 如运行耙设置你的钢轨应用数据库。 You have 2 choices. 您有2个选择。
First configure your jiql for remote access . 首先设定jiql的远程访问 。 Then run the rake DB task from your PC. 然后运行数据库任务耙从你的电脑。
For this copy of your Application, you would configure the database.yml like so: 这份对您的申请,您将配置database.yml象这样:
production: 生产:
adapter: jdbc 适配器: JDBC的
driver: org.jiql.jdbc.Driver 司机: org.jiql.jdbc.Driver
url: jdbc:jiql:https://myapp.appspot.com/jiqlservlet?user=admin&password=jiql 网址: JDBC的: jiql网址为: https : / / myapp.appspot.com / jiqlservlet ?用户=管理及密码= jiql
username: admin 用户名:管理员
password: appcloem 密码: appcloem
encoding: utf8 编码:很少
The second choice is to export the Database to a SQL formatted script. 第二种选择是 , 以出口到SQL数据库格式脚本。
With the SQL script, you have a number of choices to import the SQL script to your 随着SQL脚本,您有许多选择 , 导入到您的SQL脚本
jiql Database, which includes the use of Eclipse Database Tools Project (DTP) or jiqlAdmin . jiql数据库,其中包括使用Eclipse的数据库工具项目(排版) ,或jiqlAdmin 。
Below is the link to a GAE-Ready phonebook application WAR: 以下是链接到一个GAE就绪电话簿应用战争:
http://jiql.googlecode.com/files/jiql-jruby-rails-phonebook.war http://jiql.googlecode.com/files/jiql-jruby-rails-phonebook.war
After downloading jiql-ruby-rails-phonebook.war, unpack to your GAE Application directory. 下载后jiql -红宝石栏杆, phonebook.war ,解压到您的游戏应用程序目录。
Edit the ./WEB-INF/appengine-web.xml file and add your GAE Application ID. 编辑。 /网络干扰素/ appengine – web.xml中的文件并添加您的游戏应用程序ID 。
Upload to Google App Engine for JAVA. 上传到谷歌应用程序引擎的JAVA 。
Since we are not able to run ‘rake db:migrate’ on Google App Engine, 因为我们无法运行’耙分贝:迁移’的谷歌应用程序引擎
you must first run the following JSP, which will create the Database table. 您必须先运行下面的JSP技术,这将创建数据库表。
http://yourapp.appspot.com/init.jsp http://yourapp.appspot.com/init.jsp
Then browse to http://yourapp.appspot.com/people 然后浏览到http://yourapp.appspot.com/people
to start using the RAILS phonebook application. 开始使用铁轨电话簿应用。
As jiql uses the standard JDBC protocol to manage Google DataStore, there are a number 作为jiql使用标准的JDBC议定书管理谷歌数据存储,有一些
of tools that can be used locally or remotely to manage jiql. 的工具 , 可用于本地或远程管理jiql 。 Available database management 提供数据库管理
tools include: 工具包括:
jiqlAdmin Data Querying tool for Google’s DataStore. jiqlAdmin数据查询工具 , 谷歌的数据存储。
Eclipse Database Tools Project (DTP). Eclipse的数据库工具项目(排版) 。 When configuring DTP for jiql, 当配置为jiql排版,
the Eclipse Connection Type should be set to Generic JDBC_1. Eclipse的连接类型应设置为通用JDBC_1 。
Source – Compiling 来源-编译
- Download the source here -下载源在这里
- JAVA JDK 1.6 or higher is required. -的JAVA的JDK 1.6或更高的要求。 The reason for this is that jiql implements 这样做的理由是 , jiql实施
the latest JDBC API. 最新的JDBC的API 。 The latest JDBC references SQL extensions that 最新的JDBC提到的SQL扩展
are included with JDK 1.6. 附带的JDK 1.6 。 These SQL extensions are not included in 这些数据库的扩展 , 则不会包括在
previous JAVA JDK releases. 以往的JAVA的JDK版本。
- There are 2 ways of compiling the source. -有两种方法编制的来源。 But first an explanation 但首先解释
of the JAVA source tree. 的Java源代码树。
org.jiql – is the core jiql source code. org.jiql -是核心jiql源代码。
tools. 工具。 – are code for a general library used by jiql and other projects. -是代码一般图书馆使用jiql和其他项目。
- Minimum dependencies for compiling: -最低相依汇编:
appengine-api.jar appengine – api.jar
hibernate3.jar hibernate3.jar
For minimum compiling: 最低汇编:
Download the jiql.jar and uncompress to your output folder. 下载jiql.jar并解压缩到您的输出文件夹中。
Add the output path to your classpath. 新增的输出路径到您的类路径。
This will allow you to edit org.jiql.* code and rebuild. 这将允许您编辑org.jiql .*代码和重建。
- However to compile all code, including tools.*, the following dependencies must -然而编译所有代码,包括各种工具.* ,下列相依必须
be added to your classpath: 被添加到您的类路径:
servlet-api.jar 的servlet – api.jar
ant.jar ant.jar
不知作者有没有感觉jiql很慢很慢?我现在禁用WP的http.php已经可以让wp在GAE上运行了,但是无法在30s内INSERT所有wp_options表项
另外,您的网站是GAE的吗?
我也没有做成,卡在了安装wp时INSERT wp_options时超时,我对wp不是很了解,即使手动一个个插入表项,wp仍然会再次INSERT。
jiql-quercus.war,wp2.8.5,对wp进行了小的修改:
删掉http.php
注释cron.php:229
wp-settings.php:352
functions.php:
1931-1949,2071,2074,2168,2171
还有其他要修改的,这样修改肯定进不了后台。但目前卡在了INSERT上了。
那个网站是PHP+MySQL,GAE只是一个反向代理+memcache加速
@Reply lostriver:
看来如果要用上GAE 的WP还漫长啊,
可能要换一个数据库……
等段时间空闲了就开始弄,
是啊,我也是这样觉得,
可以详细说一下你的配置吗,
呵呵,其实我没有弄成功的,
主要是禁用http.php