Showing posts with label DB-SQL. Show all posts
Showing posts with label DB-SQL. Show all posts

Jun 8, 2012

(How To) Run Hypersonic SQL (HSQL) as a HTTP Server

Sometimes, a firewall may not allow the HSQL DB to be run in HSQL Server mode. In such scenarios, the HTTP Server mode comes to our help. To run the HSQL DB in HTTP Server mode, we need to do the following:

1) Place the hsqldb.jar in a folder where you want to create the database
2) In command prompt, execute the command:
java -cp hsqldb.jar org.hsqldb.server.WebServer --database.0 
                       file:/data/learning --dbname.0 phonebook
- /data/learning is the location where the database will be created.
- "phonebook" is alais name used to refer to the database. This also hides the actual database from the clients.
- Settings to connect to the database from HSQL Database Manager is shown below:

Jun 7, 2012

(How To) Run Hypersonic SQL (HSQL) as a HSQL Server


1) Place the hsqldb.jar in a folder where you want to create the database
2) In command prompt, execute the command:
java -cp hsqldb.jar org.hsqldb.server.Server --database.0 
                     file:/data/learning --dbname.0 phonebook
- /data/learning is the location where the database will be created.
- "phonebook" is alais name used to refer to the database. This also hides the actual database from the clients.
- Settings to connect to the database from HSQL Database Manager is shown below:

(How To) Create a table in Hypersonic SQL(HSQL) with an auto-increment field



Create table "contacts":
create table contacts(
 id integer generated by default as identity (start with 1 
          increment by 1) not null primary key,
 name varchar(25) not null,
 phone integer not null
)

To insert records into the above table:
insert into contacts(name,phone) values('raja','12345')
insert into contacts(name,phone) values('rams','67890')
 
To view the inserted records:
select * from contacts