HyperSql is a portable RDBMS implemented in pure JAVA.
Download latest release of HyperSQL database from http://hsqldb.org website and extract it.
Here "bin" directory contains some batch files those can be used to run a swing based GUI tool.
Now prepare a file named server.properties and place it in hsqldb directory with following contents.
Now execute following command on command prompt.
As above command executes you will see some output and a new directory will be created into current path with named home in which you will find following contents.
Then you need to run runManagerSwing.bat file from bin directory. Before start you have to enter some connection configurations and then press ok button to connect to the graphical user interface to database.
Create one table named user with some columns.
In eclipse, using JUnit to test it.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import junit.framework.TestCase;
public class HsqlTest extends TestCase {
Connection connection;
protected void setUp() {
try {
Class.forName("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/testdb", "sa", "");
} catch (Exception e) {
e.printStackTrace();
}
}
public void testselect() {
Statement stmt = null;
ResultSet rs = null;
try {
stmt = connection.createStatement();
String sql = "select * from user";
rs = stmt.executeQuery(sql);
while (rs.next()) {
System.out.print("Id=" + rs.getString("u_id"));
System.out.print("\tName=" + rs.getString("u_name"));
System.out.println("\tPhone=" + rs.getString("u_phone"));
}
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
try {
rs.close();
stmt.close();
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
protected void tearDown() {
try {
connection.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
Congratulations!