jsp連線h2例子

2021-08-26 21:38:55 字數 899 閱讀 9739

一、通過server形式連線

1.將h2.jar複製到web-inf/lib

2.配置web.xml

org.h2.server.web.dbstarter  

db.url

jdbc:h2:tcp://localhost/~/test

db.user

sa

db.password

sa

db.tcpserver

-tcpallowothers

3.jsp連線h2

string driver="org.h2.driver"; 

string url="jdbc:h2:tcp://localhost/~/test;user=sa;password=sa";

connection conn=null; //資料庫連線

statement stmt=null;

resultset rs = null; //查詢結果

class.forname("org.h2.driver");

connection con = drivermanager.getconnection(url);

stmt=con.createstatement();

rs = stmt.executequery("select * from acct_group");

二、通過file形式連線

這個就比較簡單,將jar複製進lib,無需配置web.xml,直接在jsp內寫入

string url="jdbc:h2:~/test;user=sa;password=sa";

h2連線模式

h2連線模式 嵌入方式 本地使用jdbc訪問 伺服器方式 遠端通過tcp ip使用jdbc,odbc訪問 混合方式 同時相容嵌入方式和伺服器方式 嵌入方式 jdbc h2 file home目錄 jdbc h2 test 其他 jdbc h2 file c jdbc h2 file 記憶體資料庫 資...

H2資料庫連線方式速查表

轉至官方文件 topic url format and examples embedded local connection jdbc h2 file jdbc h2 test jdbc h2 file data sample jdbc h2 file c data sample windows o...

Camera2例子鏈結

最後,在網上發現幾個使用camera api2開發的例項程式,總結一下方便後續參考 1.camera2 basic 演示如何使用camera2 api基本功能的demo。你可以從中學會如何遍歷相機裝置的所有特性,顯示預覽 以及拍照。2.camera2 video l camera是乙個開源的實驗性質...