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


相关推荐

  • PathFileExists 文件目录是否存在

    PathFileExists 文件目录是否存在if(!PathFileExists(_T(“d:\\test”)))    returnNULL; 也可用CFileFinder查找文件是否存在。PathFileExists可查看目录和文件。

    2022年7月12日
    20
  • android p是哪个版本,Android P是什么系统?Android P与Android有什么区别?[多图][通俗易懂]

    对于AndroidP系统,是一个既熟悉又陌生的概念,网上关于AndroidP爆料很多,但具体是什么系统,与Android系统有什么区别都不太清楚。随着一年一度的古哥I/O2018开发者大会的正式召开。AndroidP系统也渐渐解开了大家的问题,具体分析如下。这次大会,算是底层系统的更新,配合手机厂商的深度定制将会带来焕然一新的使用体验。全新的AndroidP开发者预览版正式加入…

    2022年4月6日
    42
  • Python语言有哪些数据类型「建议收藏」

    Python语言有哪些数据类型「建议收藏」在Python中,能够直接处理的数据类型有以下几种:一、整数Python可以处理任意大小的整数,当然包括负整数,在Python程序中,整数的表示方法和数学上的写法一模一样,例如:1,…

    2022年5月28日
    32
  • CSS画猪

    效果查看:http://hovertree.com/texiao/css3/6/CSS3画猪头:http://hovertree.com/texiao/css3/6/1/代码如下:转自:htt

    2021年12月22日
    45
  • layer 弹出层传递参数

    layer 弹出层传递参数layer弹出层轻量好用,一直喜欢用,但是却没有弹出层传参的接口,迫于无奈只能Url地址传参,总所周知,这个可是限制大小的,百度一番,看看大神们怎么处理,结果就感觉所有回答都是Ctrl+C加Ctrl+V,全是地址栏传参,页面缓存、cookie、localstorage,本着不甘心的原则,就想为什么不能在open的时候把参数一起作为属性传递了,强行看了layer源码(扒光慢慢看),于是乎…

    2022年7月13日
    15
  • css基础选择器有哪些

    css基础选择器有哪些css基础选择器有哪些(熟记)一、选择器作用:规范了页面中哪些元素能够定义好样式,同时也能帮助我们去二、选择器分类1.通用选择器(只能放在样式表)1.作用:匹配页面上的所有元素 2.语法:* 3.*{ 属性:属性值; }2.元素择器1.作用:匹配页面上某个元素的样式2.语法: 3.元素名{ 属性:属性…

    2025年5月24日
    5

发表回复

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

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