MarioNote

November 24, 2012

“Database is locked” on SQLite

Filed under: Database,Java,SQLite,Uncategorized — mariojump @ 8:42 pm

An article below helped me remove SQLite’s “Database is locked” messages.

http://sqlite-howto.blogspot.jp/2009/08/sqlite-s-database-is-locked-solution.html

First, I added the following lines to all methods that use Hibernate.
session.close();
sessionFactory.close();

For those non-Hibernate code, (plain JDBC codes), ensure it has something like:

stat.close();

conn.close();

“Database is locked” disappeared.

Advertisements

December 28, 2009

Microsoft Access SQL to calculate the time from midnight in minutes, seconds, etc.

Filed under: Access,Database,Sample code,Software Development — mariojump @ 10:00 pm

MS Access SQL to find the time from the midnight.

MS Access’s timestmap values consist of integer part (number of days from
the certain date), and fractional part (e.g. 6am = 6/24 =0.25 day
from midnight.).

By using this, we can run a query like:

SELECT
my_timestamp_column – INT(my_timestamp_column) AS Time_From_Midnight,
/* note: date part will be lost */

INT((my_timestamp_column – INT(my_timestamp_column))*24*60*60) AS
Seconds_From_Midnight,

INT(INT((my_timestamp_column – INT(my_timestamp_column))*24*60*60 ) /
60) AS Minutes_From_Midnight

FROM my_table_with_timestamp;

December 9, 2009

Oracle Data Import / Export command (imp, exp) samples

Filed under: Database,Linux,Oracle,Software Development — mariojump @ 2:59 pm
Tags: , , , ,

There are occasions we need to export or import data from/to Oracle.

These are sample command line inputs to do so.  The database can be local (localhost, 127.0.0.1) or remote server.

$ exp db_username1/password_of_username1@127.0.0.1 TABLES=(db_username1.%) FILE=exportfile1.dat exportfile2.dat exportfile3.dat exportfile4.dat FILESIZE=1024MB INDEXES=n LOG=logfile.log

$ imp system/password_of_system@127.0.0.1 FROMUSER=(db_username) TOUSER=(maybe_another_db_username) FILE=./exportfile1.dat INDEXES=n GRANTS=y STATISTICS=RECALCULATE LOG=importlog.log

Blog at WordPress.com.