Thanks, Hatim!
I had put together a .sql script for HSQLDB that imported a text table (from the file) into a database, running it directly from the hsqldb.jar. Something like this:
Code:
CREATE TABLE real (
Id char(3) NOT NULL,
Comment varchar(150) NULL);
CREATE TEXT TABLE tmp (
Id char(3) NOT NULL,
Comment varchar(150) NULL);
SET TABLE tmp SOURCE "temp.tab;ignore_first=true;encoding=UTF-8;fs=\t";
select count(*) from tmp;
select count(*) from real;
INSERT INTO real (
Id,
Comment
) SELECT
Id,
Comment
FROM tmp;
commit;
select count(*) from real;
Looking at the hsqldb database's .script file, I do see individual INSERT entries for all the ~7000 items in my text file (okay, it's really a .tab file, not a .csv
).
So I might be able to move out these INSERT entries out into a separate .sql file and populate the table that way. Another way to do it would be to hack the web app database's .script file (add in the .script statements from the test database). The drawback there would be that the data is no longer in a generic .sql format - so moving to another database takes a little more work.
If I go the .sql statement route, where do I need to add the hook in the web app to verify that the table is created (and call the .sql file if it isn't)? ContextLoaderServlet?