JDBC Connection with HyperSQL
What is HyperSQL?
HyperSQL(HSQL) is a rational database written in Java. It gives small, multithreaded and transactional database engine with in-memory tables, it supports embedded and server mode.How to use HSQL?
Get HSQL
Download the latest version of HSQL from here.
Starting HSQL Server
Extract downloaded files to a location and create a "server.properties" file in the same directory.
server.database.0 = file:dbs/demodb server.dbname.0 = testdb
Now create a folder "dbs", this will hold the database and tables on which you will be performing queries.
Open command prompt/terminal and run the following command to start the server.
Open command prompt/terminal and run the following command to start the server.
java -cp lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:hsql --dbname.0 testdb
Basic Configuration
Go to "bin" directory, run "runManagerSwing.bat" and create a new configuration as shown in below image.
Connecting to HSQL Server
Create a new Java Project and add "hsqldb.jar" to build path.
Now using the below code snippet make the connection to HSQL server.
Connection con = null; try { //Registering the HSQLDB JDBC driver Class.forName("org.hsqldb.jdbc.JDBCDriver"); //Creating the connection with HSQLDB con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/testdb", "SA", ""); if (con!= null){ System.out.println("Connection created successfully"); }else{ System.out.println("Problem with creating connection"); } } catch (Exception e) { e.printStackTrace(System.out); }
Once it is done you can perform SQL queries 34x faster than MYSQL.
JDBC Connection with HyperSQL
Reviewed by Karan Sawhney
on
12:11 AM
Rating:
Reviewed by Karan Sawhney
on
12:11 AM
Rating:

No comments: