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


相关推荐

  • Python之用虚拟环境隔离项目,并重建依赖关系

    下面将以安装django和mysqlclient介绍如何用虚拟环境隔离项目,并重建依赖关系。操作系统:windows10;python版本:python3.71.安装python虚拟环境(1)

    2021年12月30日
    41
  • ReadProcessMemory函数的分析「建议收藏」

    ReadProcessMemory函数的分析「建议收藏」ReadProcessMemory函数用于读取其他进程的数据。我们知道自远古时代结束后,user模式下的进程都有自己的地址空间,进程与进程间互不干扰,这叫私有财产神圣不可侵犯。但windows里还真就提供了那么一个机制,让你可以合法的获取别人的私有财产,这就是ReadProcessMemory和WriteProcessMemory。为什么一个进程居然可以访问另一个进程的地址空间呢?因为独立的只是低

    2022年10月4日
    2
  • C++ nullptr

    c++nullptr

    2022年4月6日
    40
  • 也谈VC中ModifyStyle&ModifyStyleEx无法改变控件的Style)

    也谈VC中ModifyStyle&ModifyStyleEx无法改变控件的Style)一个View中用到了一个CListCtrl,在OnInitialUpdate函数里面他调用了m_listCtrl.ModifyStyleEx(0,LVS_EX_FULLROWSELECT);但是结果是并没有改变View中这个ListCtrl的效果。     仔细的查阅了MSDN的关于ModifyStyleEx的说明,发现没什么可以的地方,调试几遍发现也没异常,最后在网上一搜索Modif

    2022年7月19日
    18
  • vs实现用户注册登录_用户注册登录怎么填写

    vs实现用户注册登录_用户注册登录怎么填写publicstaticUserInfoGetUser(stringname,stringpwd){//填写搜索姓名和密码的sql语句stringsql=string.Format(“select*fromUserInfowhereLoginName='{0}’andPassword='{1}'”,name,pwd);DataTabledt=DBHelper.ExcuteTab.

    2022年10月13日
    1
  • centos7 安装gitea使用

    centos7 安装gitea使用参考官网 https gitea iohttps docs gitea iohttps docs gitea io en us install from binary 关于 GiteaGitea 是一个自己托管的 Git 服务程序 他和 GitHub BitbucketorG 等比较类似 他是从 Gogs 发展而来 不过我们已经 Fork 并且命名为 Gitea 对

    2025年9月25日
    4

发表回复

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

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