
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Connect to HSQLDB Database Using JDBC Program
HSQLDB is a relational database management system implemented in pure Java. You can easily embed this database to your application using JDBC. Or you can use the operations separately.
Installing HSQLDB:
Download the latest version of HSQLDB database.
Install HSQLDB following the steps given in HSQLDB Tutorial.
Make sure that the HSQLDB database is up and running. The URL to connect to this database is jdbc:hsqldb:hsql://host_name/database_name and the driver class name is org.hsqldb.jdbc.JDBCDriver. Download the driver and set classpath to it.
Example
Following JDBC program establishes a connection with HSQL database.
import java.sql.Connection; import java.sql.DriverManager; public class ConnectDatabase { public static void main(String[] args) { 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); } } }
Output
Connection created successfully
Advertisements