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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java课程设计—中国象棋(源代码及视频)「建议收藏」

    谢谢大家的支持,您的一键三连是罡罡同学前进的最大动力!一键三连一键三连一键三连一键三连一键三连一键三连传送地址数据结构课程设计——校园导游系统(C语言):B站视频:https://www.bilibili.com/video/BV1ui4y137X9CSDN源码:https://blog.csdn.net/m0_46625346/article/details/107149473Java课程设计——中国象棋B站视频:https://www.bilibili

    2022年4月8日
    49
  • qsqlquery查询到的数据个数_获取sequence的当前值

    qsqlquery查询到的数据个数_获取sequence的当前值publicintselectAll(finalStringtime1, finalStringtime2,finalintcityname,finalStringairstatus){ finalStringBufferhql=newStringBuffer( “selectcount(air)fromTableNameair

    2022年9月26日
    0
  • dedecms的各个文件代表的意思

    dedecms的各个文件代表的意思

    2022年4月3日
    46
  • 安全帽识别系统的基本参数「建议收藏」

    安全帽识别系统的基本参数「建议收藏」随着鹰眸安全帽识别系统的不断落地,应用的领域不断扩大,部分客户对产品的认知还不够,下面就给大家详细介绍一下安全帽识别系统的主要参数和性能:鹰眸安全帽识别系统对监控摄像机的品牌没有要求,只要分配率不低于720P的网络彩色摄像机(支持RTSP协议)即可,兼容市面上99%的摄像机。摄像机安装高度建议在2-2.5m,水平角度大于15度,识别效果更理想识别目标距离,这个主要是跟监控摄像机的镜头参数有关,…

    2022年5月19日
    39
  • ScriptManager局部刷新「建议收藏」

    ScriptManager局部刷新「建议收藏」ScriptManager和UpdatePanel控件联合使用可以实现页面异步局部更新的效果。其中的UpdatePanel就是设置页面中异步局部更新区域,它必须依赖于ScriptManager存在,因为ScriptManger控件提供了客户端脚本生成与管理UpdatePanel的功能。几个重要的属性:ScriptManager控件的EnablePartialRendering属性:true…

    2022年7月13日
    14
  • 最新手机号码归属地数据库(2017年4月1日)

    最新手机号码归属地数据库(2017年4月1日)2017年4月1日版近36万条记录celldb.cc最新号码归属地数据库手机号段数据库移动联通电信移动号段联通号段电信号段虚拟170号段171号段号码字段包括省市运营商邮编区号等信息移动号码:134135136137138139147150151152157158159178182183184187188联通…

    2022年7月22日
    10

发表回复

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

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