用客户端连接项目中嵌入的derby数据库方法

最近,做网站静态化辅助项目,打算将需要静态化的url存入内嵌式数据库里。第一次使用derby,下面把如何用客户端(选择coolsql,可以选择其他工具)连接程序中的derby方法,分享下:
1.程序中创建数据库时,如果没有指定目录,会默认在项目的根目录下,生成一个以derby数据库名的目录,如:
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
System.out.println("Load the embedded driver");
Connection conn = null;
Properties props = new Properties();
props.put("user", "test");
props.put("password", "test");
// create and connect the database named helloDB
conn = DriverManager.getConnection(
"jdbc:derby:testDB;create=true", props);
System.out.println("create and connect to testDB");
conn.setAutoCommit(true);

其中:“jdbc:derby:testDB;create=true”,则在项目根目录下生成一个testDB目录。
2.下载安装coolsql后,操作如下:
1>新建一个书签,选择驱动
找到derby-10.9.1.0.jar(或其他版本jar),选择下面的:org.apache.derby.jdbc.EmbeddedDriver 。
2>下一步,输入用户名、密码,填写程序中赋值的:test,test;下面的数据库名字填写时,要注意,写系统的绝对路径,如:E:\eclipse3.7\wordspace_mvn\staticize\testDB(staticize为项目根目录),下面的url:jdbc:derby:E:\eclipse3.7\wordspace_mvn\staticize\testDB(自动填写)。
3>保持连接就可以了。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值