站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题学习J2EE第三天(Cloudscape数据库的安装和了解)

学习J2EE第三天(Cloudscape数据库的安装和了解)

摘要: 学习J2EE第三天(Cloudscape数据库的安装和了解)
IBM Cloudscape Version 10.1

简介

Cloudscape 是一个以 Java 类库形式提供的、轻量级的、可嵌入的关系引擎。它的本机接口是带有 Java 关系扩展的 Java Database Connectivity(JDBC)。它实现了 SQL92E 标准和许多 SQL 99 扩展。该引擎提供了事务和崩溃恢复,支持多个连接,而且支持使用一个连接的多个线程。因为 Cloudscape 是一个 Java 类库,您可以很容易地将它嵌入到任何 Java 应用程序或服务器架构中,同时还不会损害该应用程序的 Java 特性。当需要扩充数据库时,Cloudscape 支持复杂 SQL 事务和 JDBC,该特性允许它将应用程序迁移到其他 SQL 数据库,例如 IBM DB2® Universal Database™(UDB)。

Cloudscape Version 10:技术概述
http://www-128.ibm.com/developerworks/cn/db2/library/techarticles/dm-0408anderson/index.html
下载安装程序
http://www-128.ibm.com/developerworks/cn/db2/library/techarticles/dm-0408cline/index.html

一、安装数据库程序
设置环境变量DERBY_INSTALL=D:\Program Files\IBM\Cloudscape_10.1
设置CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;

打开cmd.

//查看系统信息
>java org.apache.derby.tools.sysinfo

二、数据库的简单使用
//进入了默认自带已经建立好的演示数据库文件夹
>cd D:\Program Files\IBM\Cloudscape_10.1\demo\databases\

启动ij工具.
>java org.apache.derby.tools.ij

ij>

//连接到数据库
ij> connect 'jdbc:derby:toursDB';

//建立一个叫address的表
ij> create table address (name varchar(60), street varchar(255), zipcode int);
0 rows inserted/updated/deleted

//建立一个叫zipmap的表
ij> create table zipmap (zipcode int, city varchar(255));
0 rows inserted/updated/deleted

//插入数据
ij> insert into zipmap values(201, 'shanghai');
1 row inserted/updated/deleted
ij> insert into zipmap values(123456, 'abcde');
1 row inserted/updated/deleted

//查看表里所有数据
ij> select * from zipmap;
ZIPCODE |CITY
------------------------------------------------------------
201 |shanghai

123456 |abcde


2 rows selected

//查找数据
ij> select zipmap.zipcode from zipmap where zipmap.city = 'shanghai';
ZIPCODE
-----------
201

1 row selected

//删除表
ij> drop table zipmap;
0 rows inserted/updated/deleted
ij> drop table address;
0 rows inserted/updated/deleted

//断开连接
ij> disconnect;
//退出ij工具
ij> exit;
D:\Program Files\IBM\Cloudscape_10.1\demo\databases>

三、可以使用的驱动:
org.apache.derby.jdbc.EmbeddedDriver
这个就是可以嵌入到环境中的,当数据库与程序运行在同一个JVM中.

org.apache.derby.jdbc.ClientDriver
这个是用于网络的,比如client/server之类的应用.

四、Cloudscape Technical resource center
http://www.ibm.com/developerworks/db2/zones/cloudscape/

The developerWorks editors have assembled a broad collection of technical resources in the Cloudscape zone. The "zone" is a great place to find all the information you need to get started with IBM Cloudscape.


↑返回目录
前一篇: 学习J2EE第四天(从网络程序开始)
后一篇: 浅析J2EE与.NET平台优劣