Javadb学习 连接Javadb的两种方法 javadb-10_5_1_1.zip[通俗易懂]

Javadb学习 连接Javadb的两种方法 javadb-10_5_1_1.zip[通俗易懂]Javadb学习环境变量设置:DERBY_HOME=D:\ProgramFiles\Environment\javadbpath=.;%JAVA_HOME%/bin;%path%;%CATALINA_HOME%/bin;%ANT_HOME%/bin;%ANT_HOME%/bin;C:\ProgramFiles\IDMComputerSolutions\UltraEdit\;%JA…

大家好,又见面了,我是你们的朋友全栈君。

Javadb学习

环境变量设置:

DERBY_HOME=D:\ProgramFiles\Environment\javadb

path=.;%JAVA_HOME%/bin;%path%;%CATALINA_HOME%/bin;%ANT_HOME%/bin;%ANT_HOME%/bin;C:\Program Files\IDM Computer Solutions\UltraEdit\;%JAVA_HOME%\jre\lib;%DERBY_HOME%\bin

 

classpath=.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\bin;%JAVA_HOME%\jre\lib;%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbyclient.jar;%DERBY_HOME%\lib\derbynet.jar;%DERBY_HOME%\lib\derbyrun.jar

 

开启Javadb服务:

java -jar %derby_home%\lib\derbyrun.jar server start

关闭javadb服务

java -jar %derby_home%\lib\derbyrun.jar server shutdown

 

 

ij

ij> exit;  退出

 

Email server : derby-user@db.apache.org

 

 

 用ij连接数据库javadb

Creating a Derby database and running SQL statements
Now, you will use the Derby ij tool to load the Derby database engine. You will use the
Derby embedded driver to create and connect to the firstdb database. You will also
use a few basic SQL statements to create and populate a table.
1. Run the Derby ij tool.
If you included the DERBY_HOME/bin directory in your PATH environment variable,
type:
ij
Otherwise, you can use the java command to start the ij tool.
Operating
System
Command
UNIX
(Korn Shell)
java -jar $DERBY_HOME/lib/derbyrun.jar ij
ij version 10.5
Windows java -jar %DERBY_HOME%\lib\derbyrun.jar ij
ij version 10.5
2. Create the database and open a connection to the database using the embedded
driver.
CONNECT ‘jdbc:derby:firstdb;create=true’;
Description of connection command:
connect
The ij command to establish a connection to a database. The Derby
connection URL is enclosed in single quotation marks. An ij command can
be in either uppercase or lowercase.
jdbc:derby:
The JDBC protocol specification for the Derby driver.
firstdb
The name of the database. The name can be any string. Because no
filepath is specified, the database is created in the default working directory
(DERBYTUTOR).
;create=true
The Derby URL attribute that is used to create a database. Derby does not
have an SQL create database command.
;
Getting Started with Java DB
23
The semicolon is the ij command terminator.
3. Create a table with two columns using standard SQL.
CREATE TABLE FIRSTTABLE
(ID INT PRIMARY KEY,
NAME VARCHAR(12));
0 rows inserted/updated/deleted
4. Insert three records.
INSERT INTO FIRSTTABLE VALUES
(10,’TEN’),(20,’TWENTY’),(30,’THIRTY’);
3 rows inserted/updated/deleted
5. Perform a simple select of all records in the table.
SELECT * FROM FIRSTTABLE;
ID |NAME
————————
10 |TEN
20 |TWENTY
30 |THIRTY
3 rows selected
6. Perform a qualified select of the record with column ID=20.
SELECT * FROM FIRSTTABLE
WHERE ID=20;
ID |NAME
————————
20 |TWENTY
1 row selected
7. Optional: Create and populate additional tables and other schema objects.
a. Load the SQL script ToursDB_schema.sql.
run ‘ToursDB_schema.sql’;
ij> …
CREATE TABLE AIRLINES
(
AIRLINE CHAR(2) NOT NULL ,
AIRLINE_FULL VARCHAR(24),
BASIC_RATE DOUBLE PRECISION,

0 rows inserted/updated/deleted
… Other output messages not shown …
b. Populate the tables with data by running the script loadTables.sql.
run ‘loadTables.sql’;
ij> run ‘loadCOUNTRIES.sql’;
ij> insert into COUNTRIES values ( ‘Afghanistan’,’AF’,’Asia’);
1 row inserted/updated/deleted
ij> insert into COUNTRIES values ( ‘Albania’,’AL’,’Europe’);
1 row inserted/updated/deleted
… Other output messages not shown …
8. Exit the ij tool.
exit;
You should be returned to the DERBYTUTOR directory.
9. Browse the most

 

Activity 2: Run SQL using the client driver

java -jar %DERBY_HOME%\lib\derbyrun.jar server start

换一个dos窗口

java -jar %DERBY_HOME%\lib\derbyrun.jar ij

CONNECT ‘jdbc:derby://localhost:1527/seconddb;create=true’;

备注区别:CONNECT ‘jdbc:derby:firstdb;create=true’; 

 

CREATE TABLE SECONDTABLE
(ID INT PRIMARY KEY,
NAME VARCHAR(14));
0 rows inserted/updated/deleted

 

 

INSERT INTO SECONDTABLE VALUES
(100,’ONE HUNDRED’),(200,’TWO HUNDRED’),(300,’THREE HUNDRED’);
3 rows inserted/updated/deleted

 

SELECT * FROM SECONDTABLE;
ID |NAME
————————
100 |ONE HUNDRED
200 |TWO HUNDRED
300 |THREE HUNDRED
3 rows selected

 

Exit ij.

 

java -jar %DERBY_HOME%\lib\derbyrun.jar server
shutdown

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/156994.html原文链接:https://javaforall.net

(0)
上一篇 2022年7月8日 上午11:46
下一篇 2022年7月8日 下午12:00


相关推荐

  • 6.PyCharm试用

    6.PyCharm试用文章目录 1 PyCharm 试用 1 1 前期步骤 1 2 中间步骤 1 3 后期步骤 1 4 查看试用时间 1 PyCharm 试用 ps 技术缺陷在不端的被更新 暂时适用于当下 1 1 前期步骤 1 打开 PyCharm2 Plugins3 选中齿轮符号 gt managePlugin 4 弹出信息框 gt 5 将 https plugins zhile io 填写进入 gt ok6 选择界面中的 MarKetplace 弹出搜索框 7 在搜索框中输入 IDEEval

    2026年3月27日
    2
  • OpenClaw插件配置错误修复完全指南

    OpenClaw插件配置错误修复完全指南

    2026年3月13日
    2
  • 进销存管理系统【源码开放】[通俗易懂]

    进销存管理系统【源码开放】[通俗易懂]进销存管理系统的功能需求:1,实现采购订单的持久化,对采购商品入库处理,还有就是采购的退货处理;2,实现商品的入库、出库操作,查询商品的库存信息,修改商品的仓库号3,实现销售订单的添加,销售发货处理,并且销售的退货处理4,实现新建员工培训信息和查询员工培训记录功能5,实现对商品、供应商、客户资料的管理,对员工用户的管理,最重要的是对系统数据的备份和恢复代码的截图如下所示:系统的截图如下所示:bean层manage的代码如下所示:packag.

    2022年5月31日
    31
  • Druid介绍及入门[通俗易懂]

    Druid介绍及入门[通俗易懂]1.什么是Druid?Druid是一个高效的数据查询系统,主要解决的是对于大量的基于时序的数据进行聚合查询。数据可以实时摄入,进入到Druid后立即可查,同时数据是几乎是不可变。通常是基于时序的事实事件,事实发生后进入Druid,外部系统就可以对该事实进行查询。Druid采用的架构: shared-nothing架构与lambda架构 Druid设计三个原则:1.快速查询(FastQu…

    2022年7月23日
    10
  • 联席CEO是一捧脆弱的琉璃

    联席CEO是一捧脆弱的琉璃文 财经琦观如果 将 2009 年至 2020 年这一时段定义为互联网创投领域的黄金时代 那么 献出的最后一支舞中 总会有快手的身影 传统互联网领域中 快手踩的是最后一个风口 短视频 行业里规模足够大 且结结实实的最后一场近身肉搏大战 由快手和抖音联袂奉献 投资市场的对传统互联网信心尚未崩塌之前 快手作为独角兽 最后一个上市且掀起狂欢 以及 联席 CEO 这一仓促的 蓬勃时代的 充满了 权宜 味道的特殊架构 快手也为它献上了最后谢幕 01 接力 10 月 29 日 快手在港交所发布公告 宿华

    2026年3月26日
    1
  • php haystack,haystack(示例代码)

    php haystack,haystack(示例代码)1 haystack 简介 Haystack 是 django 的开源全文搜索框架 全文检索不同于特定字段的模糊查询 使用全文检索的效率更高 该框架支持 Solr Elasticsearc Whoosh Xapian 搜索引擎它是一个可插拔的后端 很像 Django 的数据库层 所以几乎你所有写的代码都可以在不同搜索引擎之间便捷切换 全文检索不同于特定字段的模糊查询 使用全文检索的效率更高 并且能够

    2026年3月18日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号