最新下载
热门教程
- 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");
相关文章
- 开放空间宁蒙有什么技能 09-15
- 小鸡舰队出击天空首领活动怎么玩 09-15
- 魔法工艺套装如何解锁使用 09-15
- 三国群英传策定九州资源地有什么打法技巧 09-15
- 下一站江湖2马夫人任务怎么完成 09-15
- 小鸡舰队出击终焉灵王队伍如何搭配 09-15