最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
JSP页面中连接IBM Cloudscape(derby)数据库
时间:2022-07-02 17:53:22 编辑:袖梨 来源:一聚教程网
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.***w3.org/TR/REC-html40/loose.dtd">
以前写过一个页面中连接mysql的例子
连接derby时,只是jdbc的连接属性有所改变,大同小异而已。
derby数据库与mysql不同的是,它有两种连接方式:embbed 和 net server
这里只用了第一种embbed的形式,第二种还没有试过。
系统运行环境:winxp+jdk1.4.2+tomcat+cloudscape10.0
以下是具体的网页代码:
String databaseURL ="jdbc:derby:C:DatabasejimmyDB"; //C:DatabasejimmyDB是数据库的存放位置
try{
Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); //derby数据库的embbed驱动名
out.println("Success loading derby Driver!");
}
catch(Exception e)
{
out.print("Error loading derby Driver!");
e.printStackTrace();
}
try{
Properties properties = new Properties();
properties.put("create", "true");//新建数据库
properties.put("user", "APP");//用户名
properties.put("password", "APP"); //密码
properties.put("retreiveMessagesFromServerOnGetMessage", "true");
//Get a connection
Connection connect= DriverManager.getConnection(databaseURL, properties);
out.print("Success connect derby server!");
Statement s = connect.createStatement();
s.execute("create table jimmyDB2(num int, addr varchar(40))");
out.println("Created table jimmyDB2");
s.execute("insert into jimmyDB2 values (1956,'Webster St.')");
out.println("Inserted 1956 Webster");
s.execute("insert into jimmyDB2 values (1910,'Union St.')");
out.println("Inserted 1910 Union");
相关文章
- 漫蛙3安卓下载最新版本安装包-安卓正版资源免费下载入口 02-25
- deepseek网页版免登录入口 02-25
- jm成人网页版-官方正版入口 02-25
- Twitter网页版登录指南-详细步骤与常见问题全解析 02-25
- deepseek电脑版2026-deepseek智能软件 02-25
- 漫蛙manwa2下载安卓官方正版安装包_网页最新版入口一键直达 02-25