Problem Connecting Hsqldb from Portlet Program
I am not a good programmer in java programming language and thus facing a big problem with a concept. can anyone help me in getting a small program to understand. I am not able to understand the connecting concept of hsqldb from porlet program. Can any one help me in understanding this concept.
Your help will be appreciated
Re: Problem Connecting Hsqldb from Portlet Program
Code:
package pms;
import java.sql.*;
public class First {
public static void main(String args[])
{
try {
Class.forName("org.hsqldb.jdbcDriver" );
System.out.println("hi");
Connection con= DriverManager.getConnection("jdbc:hsqldb:hsql:pms", "sa", "");
System.out.println("connection established");
Statement st=con.createStatement();
String s="create table student(sid integer,sname varchar(20))";
ResultSet rs=st.executeQuery(s);
System.out.println("values inserted");
}
catch (Exception e) {
System.out.println("ERROR: failed to load HSQLDB JDBC driver.");
e.printStackTrace();
return;
}
}
}
but i am getting an exception at
Connection con= DriverManager.getConnection("jdbc:hsqldb:hsql:pms", "sa", "");
Re: Problem Connecting Hsqldb from Portlet Program
Connect to Jahia public CVS server:
Check out the 'jforum_JSR168' module
Add the attached project.xml and project.properties to the Eclipse project
Generate and populate the tables in the HSQL database using the provided SQL files
Update systemglobals.properties to switch the database to 'hsqldb'
Update hsqldb.properties with the correct URL
Update the web.xml to include the Pluto portlet servlet
Build the WAR using the 'war' Maven goal
Deploy the WAR into Tomcat
Publish the portlet as 'jforum-portlet.JForum'
Re: Problem Connecting Hsqldb from Portlet Program
The HSQLDB jar package is located in the /lib directory and contains several components and programs. Different commands are used to run each program.
Components of the Hsqldb jar package
HSQLDB RDBMS
HSQLDB JDBC Driver
Database Manager (Swing and AWT versions)
Query Tool (AWT)
Sql Tool (command line)
The HSQLDB RDBMS and JDBC Driver provide the core functionality. The rest are general-purpose database tools that can be used with any database engine that has a JDBC driver.
Re: Problem Connecting Hsqldb from Portlet Program
All tools can be run in the standard way for archived Java classes. In the following example the AWT version of the Database Manager, the hsqldb.jar is located in the directory ../lib relative to the current directory.
Code:
java -cp ../lib/hsqldb.jar org.hsqldb.util.DatabaseManager
If hsqldb.jar is in the current directory, the command would change to:
Code:
java -cp hsqldb.jar org.hsqldb.util.DatabaseManager
Main classes for the Hsqldb tools
org.hsqldb.util.DatabaseManager
org.hsqldb.util.DatabaseManagerSwing
org.hsqldb.util.Transfer
org.hsqldb.util.QueryTool
org.hsqldb.util.SqlTool
Some tools, such as the Database Manager or SQL Tool, can use command line arguments or entirely rely on them. You can add the command line argument -? to get a list of available arguments for these tools. Database Manager features a graphical user interface and can be explored interactively.
Running Hsqldb
HSQLDB can be run in a number of different ways. In general these are divided into Server Modes and In-Process Mode (also called Standalone Mode). A different sub-program from the jar is used to run HSQLDB in each mode.
Each HSQLDB database consists of between 2 to 5 files, all named the same but with different extensions, located in the same directory. For example, the database named "test" consists of the following files:
test.properties
test.script
test.log
test.data
test.backup
The properties files contains general settings about the database. The script file contains the definition of tables and other database objects, plus the data for non-cached tables. The log file contains recent changes to the database. The data file contains the data for cached tables and the backup file is a zipped backup of the last known consistent state of the data file. All these files are essential and should never be deleted. If the database has no cached tables, the test.data and test.backup files will not be present. In addition to those files, HSQLDB database may link to any formatted text files, such as CSV lists, anywhere on the disk.