Ok, LAST QUESTION lol. I have only one more issue. I'm trying to start HSQLDB from within my program so the user doesn't have to start it and stop it manually each time.
Here is my startStop class
Code:
package addressbook;
import java.sql.*;
public class StartStopHSQLDB {
private Connection c = null;
public void startHSQLDB(){
//Start Hypersonic
try{
Class.forName("org.hsqldb.jdbcDriver").newInstance();
c = DriverManager.getConnection(
"jdbc:hsqldb:file:test", "sa", "");
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
public void stopHSQLDB(){
//Shutdown Hypersonic
try{
Statement stmt = c.createStatement();
stmt.execute("SHUTDOWN");
c.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}
I start the database by creating an object and calling the startHSQLDB() method and that's the first thing my main method does. And here's the exception that I get
Code:
May 21, 2010 1:59:04 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
May 21, 2010 1:59:04 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
May 21, 2010 1:59:04 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 21, 2010 1:59:04 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
May 21, 2010 1:59:04 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 21, 2010 1:59:04 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.2.GA
May 21, 2010 1:59:04 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: addressbook.Person
May 21, 2010 1:59:04 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity addressbook.Person on table Person
May 21, 2010 1:59:04 PM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
INFO: Hibernate Validator not found: ignoring
May 21, 2010 1:59:04 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 21, 2010 1:59:04 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 21, 2010 1:59:04 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: true
May 21, 2010 1:59:04 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost
May 21, 2010 1:59:04 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=sa, password=****, autocommit=true, release_mode=auto}
May 21, 2010 1:59:05 PM org.hibernate.cfg.SettingsFactory buildSettings
WARNING: Could not obtain connection metadata
java.sql.SQLException: socket creation error
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at addressbook.Main.init(Main.java:18)
at addressbook.Main.main(Main.java:69)
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: sample] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at addressbook.Main.init(Main.java:18)
at addressbook.Main.main(Main.java:69)
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 5 more
Java Result: 1
And here's my persistence.xml file if that helps with anything...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>addressbook.Person</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Do I need to move my database driver to a different location or would I need to move my database?