java - HSQL Connection Error. Any insight? -
i'm trying connect hsql using java. i'm using tutorial work jdbc , hibernate. it's lynda tutorials. anyway, here's code below:
package com.lynda.javatraining.db; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; public class main { private static final string username = "dbuser"; private static final string password = "dbpassword"; private static final string conn_string = "jdbc:hsqldb://data/explorecalifornia"; public static void main(string[] args) throws sqlexception { //class.forname("com.mysql.jdbc.driver"); connection conn = null; system.out.println("a"); system.out.println(conn == null); system.out.println(conn_string); try { system.out.println("b1"); conn = drivermanager.getconnection(conn_string, username, password); system.out.println("b1-2"); system.out.println("connected!"); } catch (sqlexception e) { system.out.println("b2"); system.err.println(e); } { system.out.println("b3"); if (conn != null) { conn.close(); } } system.out.println("c"); } }
here's error i'm getting:
a true jdbc:hsqldb://data/explorecalifornia b1 2014-06-27t15:26:27.430-0400 severe not reopen database org.hsqldb.hsqlexception: database lock acquisition failure: lockfile: org.hsqldb.persist.lockfile@76d682a[file =/data/explorecalifornia.lck, exists=false, locked=false, valid=false, ] method: openraf reason: java.io.filenotfoundexception: /data/explorecalifornia.lck (no such file or directory) @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.error.error.error(unknown source) @ org.hsqldb.persist.lockfile.newlockfilelock(unknown source) @ org.hsqldb.persist.logger.acquirelock(unknown source) @ org.hsqldb.persist.logger.openpersistence(unknown source) @ org.hsqldb.database.reopen(unknown source) @ org.hsqldb.database.open(unknown source) @ org.hsqldb.databasemanager.getdatabase(unknown source) @ org.hsqldb.databasemanager.newsession(unknown source) @ org.hsqldb.jdbc.jdbcconnection.<init>(unknown source) @ org.hsqldb.jdbc.jdbcdriver.getconnection(unknown source) @ org.hsqldb.jdbc.jdbcdriver.connect(unknown source) @ java.sql.drivermanager.getconnection(drivermanager.java:571) @ java.sql.drivermanager.getconnection(drivermanager.java:215) @ com.lynda.javatraining.db.main.main(main.java:24) b2 java.sql.sqlexception: database lock acquisition failure: lockfile: org.hsqldb.persist.lockfile@76d682a[file =/data/explorecalifornia.lck, exists=false, locked=false, valid=false, ] method: openraf reason: java.io.filenotfoundexception: /data/explorecalifornia.lck (no such file or directory) b3 c
can tell e i"m doing wrong? thanks.
a database has lock file explorecalifornia.lck
prevents communication. should delete lock file , restart database. may happens time time when accidentally shutdown database or system.
see syntax of command used command line invoke shutdown. there's option how shutdown server in java.
Comments
Post a Comment