今天初了下 hsqldb
下载 hsqldb
http://sourceforge.net/project/showfiles.php?group_id=23316下载 hsqldb_1_8_0_7.zip
解压到 D:/hsqldb
在 D:/hsqldb 目录下创建 runxdb.bat 文件如下:
cd data
java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 xdb -dbname.0 xdb
然后双击 runxdb.bat 启动 hsqldb Server
到目录 demo 下运行 runManagerSwing.bat 来创建表
type : HSQL Database Engine Server
url : jdbc:hsqldb:hsql://localhost/xdb
user : SA
建表:
CREATE MEMORY TABLE TEXT(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,NAME VARCHAR);
添加数据:
INSERT INTO TEXT VALUES(1,'chenlb')
INSERT INTO TEXT VALUES(2,'Tenny')
Java 文件
package hsqldb;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author chenlb 2007-4-28
*
*/
public class HsqldbFirstSimple {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Class.forName("org.hsqldb.jdbcDriver" );
} catch (Exception e) {
System.out.println("ERROR: failed to load HSQLDB JDBC driver.");
e.printStackTrace();
return;
}
try {
Connection c = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/xdb", "sa", "");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("select * from text");
while(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getString(2));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
posted on 2007-04-28 15:31
流浪汗 阅读(2458)
评论(0) 编辑 收藏 所属分类:
OpenSource