[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hsqldb-user
Subject:    Re: [Hsqldb-user] Maven + Spring + HSQL with database generated
From:       Marcelo Sena <marceloslacerda () gmail ! com>
Date:       2011-08-24 14:02:47
Message-ID: CAPmRTtMUnyrWg7mSTcuF9sWFjt_L9prqnVkd8HOvpKpnwXCWpA () mail ! gmail ! com
[Download RAW message or body]

That worked. Thanks a lot!

--
Marcelo Lacerda



On Tue, Aug 23, 2011 at 6:22 AM, Fred Toussi
<fredt@users.sourceforge.net> wrote:
> Use a normal memory table for the tests.
> 
> Use a separate TEXT table for import. Set its source to each CSV file
> then insert all the rows into the main table.
> 
> Fred
> 
> On Mon, 22 Aug 2011 11:42 -0300, "Marcelo Sena"
> <marceloslacerda@gmail.com> wrote:
> > Ok, I got around that by not deleting the database and instead just
> > not running the population scripts every time the tests are run.
> > But I have another question.
> > As I have mentioned in a previous email I am using csv files to load
> > my test database; The problem I am encountering now is that I have
> > several csv's to populate a single table and hsql seems to only load
> > data from a single csv whenever I use SET TABLE ... SOURCE ...;
> > In other words for every time I call SET TABLE ... SOURCE ...; for a
> > table the next time I try to set another source for that same table
> > the previous source is forgotten.
> > Is there a way around this problem that doesn't involve putting all
> > data in a single monster csv?
> > 
> > --
> > Marcelo Lacerda
> > 
> > 
> > 
> > On Tue, Aug 9, 2011 at 2:57 PM, Campbell Boucher-Burnet
> > <boucherb@gmail.com> wrote:
> > > You can steal from the HsqldbEmbeddedDatabaseDeleter class of the test suite.
> > > 
> > > But probably a more correct and maintainable solution would be to add
> > > a DROP database [DELETE FILES] kind of syntax.
> > > 
> > > The question has always been: is SQL syntax, versus a separate utility
> > > program, who would have the permission to execute such a statement?
> > > would one be required to connect to the target database as an admin
> > > user?  Or would this depend on some sort of external authorization
> > > scheme.
> > > 
> > > I also once tried to write a JMX-based suite of tools that included
> > > the ability to create and drop databases (without actually opening
> > > them through the session interface)
> > > This was based on reuse of the lock file mechanism, but without core
> > > support for creating/dropping database, separate from the concept of
> > > opening/connecting to/closing databases, all such efforts are doomed
> > > to eventually become out of date and broken, often fairly quickly.
> > > 
> > > On Tue, Aug 9, 2011 at 11:36 AM, Marcelo Sena <marceloslacerda@gmail.com> \
> > > wrote:
> > > > Ok, everything is working just fine now; But in the same topic I would
> > > > like to clean up the database files (.log, .properties, .script). How
> > > > do you guys do it?
> > > > I'm thinking about a ant task in maven that deletes those files before
> > > > each test is run but I'm thinking you have thought about something
> > > > smarter.
> > > > 
> > > > --
> > > > Marcelo Lacerda
> > > > 
> > > > 
> > > > 
> > > > On Fri, Aug 5, 2011 at 4:07 PM, Fred Toussi <fredt@users.sourceforge.net> \
> > > > wrote:
> > > > > You don't have to seperate the CREATE SCHEMA and CREATE TABLE statements
> > > > > into separate scripts.
> > > > > 
> > > > > Please note the script below is treated as a single schema creation
> > > > > statement. It works if you execute it in DatabaseManager as one example,
> > > > > and it should work with your Spring setup.
> > > > > 
> > > > > create schema myschema authorization dba
> > > > > 
> > > > > create table myschema.table1 (
> > > > > tab1id integer primary key
> > > > > )
> > > > > 
> > > > > create table myschema.table2(
> > > > > tab2id numeric(8,0) primary key,
> > > > > tab2tab1 integer references myschema.table1(tab1id)
> > > > > );
> > > > > 
> > > > > 
> > > > > Note the use of semicolon only at the end.
> > > > > 
> > > > > CREATE SCHEMA ... is potentially a very long statement which contains
> > > > > several CREATE statements in its body.
> > > > > 
> > > > > See this for an example of a long CREATE SCHEMA statement:
> > > > > 
> > > > > http://hsqldb.svn.sourceforge.net/viewvc/hsqldb/base/trunk/src/org/hsqldb/resources/lob-schema.sql?revision=4390&content-type=text%2Fplain
> > > > >  
> > > > > If you use the separate statements as in your example, the engine
> > > > > compiles them separately and fails because in the second create table,
> > > > > the reference to the first table cannot be resolved at compile time.
> > > > > 
> > > > > Fred
> > > > > 
> > > > > 
> > > > > 
> > > > > On Fri, 05 Aug 2011 13:12 -0300, "Marcelo Sena"
> > > > > <marceloslacerda@gmail.com> wrote:
> > > > > > I was able to isolate the problem:
> > > > > > 
> > > > > > create schema myschema authorization dba;
> > > > > > 
> > > > > > create table myschema.table1 (
> > > > > > tab1id integer primary key
> > > > > > );
> > > > > > 
> > > > > > create table myschema.table2(
> > > > > > tab2id numeric(8,0) primary key,
> > > > > > tab2tab1 integer references myschema.table1(tab1id)
> > > > > > );
> > > > > > 
> > > > > > The above lines of code produce the same "INVALID SCHEMA NAME" error.
> > > > > > By running the first part, the schema creation, and then running the
> > > > > > second part, the table creation I'm able to avoid the problem. So I'm
> > > > > > guessing by the time the table creation code is run, the schema isn't
> > > > > > ready yet right?
> > > > > > 
> > > > > > What is the preferred way do deal with this situation? I'm thinking
> > > > > > about splitting the script in two parts, one that generates the schema
> > > > > > and another that create the tables.
> > > > > > 
> > > > > > Thanks in advance,
> > > > > > 
> > > > > > Marcelo Lacerda
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On Thu, Aug 4, 2011 at 6:34 PM, Fred Toussi <fredt@users.sourceforge.net>
> > > > > > wrote:
> > > > > > > If you try some examples in DatabaseManager[Swing] you will probably
> > > > > > > figure out why:
> > > > > > > 
> > > > > > > create schema myschema authorization dba
> > > > > > > create text table myschema.mytable (
> > > > > > > tabcode integer primary key,
> > > > > > > tabalias varchar(80),
> > > > > > > tabname varchar(1024)
> > > > > > > )
> > > > > > > create table t (
> > > > > > > id int
> > > > > > > )
> > > > > > > ;
> > > > > > > 
> > > > > > > The above lot is a valid SQL statement and will execute. The single
> > > > > > > semicolon at the end indicates the end of schema creation.
> > > > > > > 
> > > > > > > But if there are statements in your script that are not allowed in a
> > > > > > > multi-
> > > > > > > object create schema statement, one of them may throw the exception you
> > > > > > > mention because the schema has not been created yet. It also depends \
> > > > > > > how Spring is executing the script. You can find out by starting an \
> > > > > > > HSQLDB server with silent=false and observe which statements are \
> > > > > > > executed against it.
> > > > > > > 
> > > > > > > Fred
> > > > > > > 
> > > > > > > 
> > > > > > > On Thu, 04 Aug 2011 17:56 -0300, "Marcelo Sena"
> > > > > > > <marceloslacerda@gmail.com> wrote:
> > > > > > > > Here at the company we used H2 in our projects as a test database. \
> > > > > > > > The database was auto filled from two scripts, one to generate the \
> > > > > > > > schema and tables(schema.sql) and a script to populate the database \
> > > > > > > > with a subset of the data we use in the production environment with \
> > > > > > > > the purpose of running our tests. But our database is in GMT and the \
> > > > > > > > test environment is in GMT and we wanted accurate tests so thats why \
> > > > > > > > we decided to switch.
> > > > > > > > 
> > > > > > > > Now e are facing some trouble since the way we used to create our
> > > > > > > > database in H2 doesn't run in HSQL out of the box, and now we are
> > > > > > > > getting cryptic errors from HSQL.
> > > > > > > > 
> > > > > > > > So here is how I have the environment set up:
> > > > > > > > 
> > > > > > > > at my pom.xml:
> > > > > > > > <dependency>
> > > > > > > > <groupId>org.hsqldb</groupId>
> > > > > > > > <artifactId>hsqldb</artifactId>
> > > > > > > > <version>2.2.4</version>
> > > > > > > > <scope>test</scope>
> > > > > > > > </dependency>
> > > > > > > > 
> > > > > > > > at my spring-config-test.xml
> > > > > > > > 
> > > > > > > > <bean id="dataSource"
> > > > > > > > class="org.apache.commons.dbcp.BasicDataSource"
> > > > > > > > destroy-method="close">
> > > > > > > > <property name="driverClassName"
> > > > > > > > value="org.hsqldb.jdbcDriver"/>
> > > > > > > > <property name="url"
> > > > > > > > value="jdbc:hsqldb:file:src/test/resources/h2/schema.sql"/>
> > > > > > > > <property name="username" value="sa"/>
> > > > > > > > <property name="password" value=""/>
> > > > > > > > </bean>
> > > > > > > > 
> > > > > > > > <jdbc:initialize-database data-source="dataSource"
> > > > > > > > ignore-failures="DROPS">
> > > > > > > > <jdbc:script location="classpath:/h2/data.sql"/>
> > > > > > > > </jdbc:initialize-database>
> > > > > > > > 
> > > > > > > > The error I'm getting now is a:
> > > > > > > > Caused by: org.hsqldb.HsqlException: invalid schema name: MYSCHEMA
> > > > > > > > 
> > > > > > > > With the schema.sql being something like:
> > > > > > > > 
> > > > > > > > create schema myschema authorization dba
> > > > > > > > 
> > > > > > > > create text table myschema.mytable (
> > > > > > > > tabcode integer primary key,
> > > > > > > > tabalias varchar(80),
> > > > > > > > tabname varchar(1024)
> > > > > > > > )
> > > > > > > > ...
> > > > > > > > 
> > > > > > > > Help?
> > > > > > > > 
> > > > > > > > --
> > > > > > > > Marcelo Lacerda
> > > > > > > > 
> > > > > > > > ------------------------------------------------------------------------------
> > > > > > > >  BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> > > > > > > > The must-attend event for mobile developers. Connect with experts.
> > > > > > > > Get tools for creating Super Apps. See the latest technologies.
> > > > > > > > Sessions, hands-on labs, demos & much more. Register early & save!
> > > > > > > > http://p.sf.net/sfu/rim-blackberry-1
> > > > > > > > _______________________________________________
> > > > > > > > Hsqldb-user mailing list
> > > > > > > > Hsqldb-user@lists.sourceforge.net
> > > > > > > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > > > > > > 
> > > > > > > 
> > > > > > > ------------------------------------------------------------------------------
> > > > > > >  BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> > > > > > > The must-attend event for mobile developers. Connect with experts.
> > > > > > > Get tools for creating Super Apps. See the latest technologies.
> > > > > > > Sessions, hands-on labs, demos & much more. Register early & save!
> > > > > > > http://p.sf.net/sfu/rim-blackberry-1
> > > > > > > _______________________________________________
> > > > > > > Hsqldb-user mailing list
> > > > > > > Hsqldb-user@lists.sourceforge.net
> > > > > > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > > > > > 
> > > > > > 
> > > > > > ------------------------------------------------------------------------------
> > > > > >  BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> > > > > > The must-attend event for mobile developers. Connect with experts.
> > > > > > Get tools for creating Super Apps. See the latest technologies.
> > > > > > Sessions, hands-on labs, demos & much more. Register early & save!
> > > > > > http://p.sf.net/sfu/rim-blackberry-1
> > > > > > _______________________________________________
> > > > > > Hsqldb-user mailing list
> > > > > > Hsqldb-user@lists.sourceforge.net
> > > > > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > > > > 
> > > > > 
> > > > > ------------------------------------------------------------------------------
> > > > >  BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> > > > > The must-attend event for mobile developers. Connect with experts.
> > > > > Get tools for creating Super Apps. See the latest technologies.
> > > > > Sessions, hands-on labs, demos & much more. Register early & save!
> > > > > http://p.sf.net/sfu/rim-blackberry-1
> > > > > _______________________________________________
> > > > > Hsqldb-user mailing list
> > > > > Hsqldb-user@lists.sourceforge.net
> > > > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > > > 
> > > > 
> > > > ------------------------------------------------------------------------------
> > > >  uberSVN's rich system and user administration capabilities and model
> > > > configuration take the hassle out of deploying and managing Subversion and
> > > > the tools developers use with it. Learn more about uberSVN and get a free
> > > > download at:  http://p.sf.net/sfu/wandisco-dev2dev
> > > > _______________________________________________
> > > > Hsqldb-user mailing list
> > > > Hsqldb-user@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > > 
> > > 
> > > ------------------------------------------------------------------------------
> > > uberSVN's rich system and user administration capabilities and model
> > > configuration take the hassle out of deploying and managing Subversion and
> > > the tools developers use with it. Learn more about uberSVN and get a free
> > > download at:  http://p.sf.net/sfu/wandisco-dev2dev
> > > _______________________________________________
> > > Hsqldb-user mailing list
> > > Hsqldb-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > > 
> > 
> > ------------------------------------------------------------------------------
> > uberSVN's rich system and user administration capabilities and model
> > configuration take the hassle out of deploying and managing Subversion
> > and
> > the tools developers use with it. Learn more about uberSVN and get a free
> > download at:  http://p.sf.net/sfu/wandisco-dev2dev
> > _______________________________________________
> > Hsqldb-user mailing list
> > Hsqldb-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> > 
> 
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> Hsqldb-user mailing list
> Hsqldb-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> 

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Hsqldb-user mailing list
Hsqldb-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hsqldb-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic