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


相关推荐

  • wine怎么打开exe_exe是什么格式的文件

    wine怎么打开exe_exe是什么格式的文件1,WinExec():  WinExec主要运行EXE文件,不能运行其他类型的文件。不用引用特别单元。  原型:UINTWinExec(exePath,ShowCmd)  示例,我想要用记事本打开”C:\HDC.TXT”,以正常方式运行:WinExec(pChar(‘notepadc:\taoyoyo.txt’),SW_SHOWNORMAL);  参数说明:  –xePath:命令行参数。注意,要用pChar转化一下。  –ShowCmd:外部程序…

    2022年7月27日
    2
  • plugins webpack_webplugin插件无法安装

    plugins webpack_webplugin插件无法安装plugin插件是webpack的支柱功能。webpack自身也是构建于你在webpack配置中用到的相同的插件系统之上!插件目的在于解决loader无法实现的其他事。常用的插件

    2022年7月31日
    7
  • HttpCanary下载_HTML自我介绍

    HttpCanary下载_HTML自我介绍前言首先,我们无论学习哪个框架,都要带着问题,带着思考去学习思考1:HttpRunner是什么?思考2:HttpRunner的设计模式是什么?思考3:为什么我们要学习HttpRunner?他的

    2022年7月31日
    2
  • js中判断对象是否为空

    js中判断对象是否为空1.es6中可以使用Object.keys(obj)vardata={};vararr=Object.keys(data);alert(arr.length==0);//true为空,false不为空2.将json对象转化为json字符串,再判断该字符串是否为"{}"vardata={};varb=(JSON.stringify(data)==…

    2022年6月14日
    22
  • 三星刷机工具Odin图文刷机教程

    三星刷机工具Odin图文刷机教程解压完,双击安装包选择语言,语言栏选择simplifiedCinnese国家选择c朱雀网络www.zhuquewl.comROM包下载hina安装路径可选择其他驱动盘,或者直接安装亦可注意事项: 1)手机电池有个一半的电量或是更少点都没问题,反正不要刷机过程中没电就行。真是没电了,也没事,充电,重刷就行了。2)给手机做好备份。3)下载刷机包,就自己准备着下载。4)下载刷机工具,

    2022年7月21日
    15
  • 各种智能优化算法比较与实现(matlab版)

    各种智能优化算法比较与实现(matlab版)各种智能优化算法比较与实现(matlab版)一、方法介绍1免疫算法(ImmuneAlgorithm,IA)1.1算法基本思想免疫算法是受生物免疫系统的启发而推出的一种新型的智能搜索算法。它是一种确定性和随机性选择相结合并具有“勘探”与“开采”能力的启发式随机搜索算法。免疫算法将优化问题中待优化的问题对应免疫应答中的抗原,可行解对应抗体(B细胞),可行解质量对应免疫细胞与抗原的亲和度。如…

    2022年5月24日
    58

发表回复

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

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