You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Laurent Sacaut <ls...@8d.com> on 2006/02/24 22:23:40 UTC

setup-db problems

When trying to run the setup-db ant task from the build file, I am
getting an error coming from the build-torque.xml file.
I modified builds.properties and OJB.properties to fit my test project
but can get it to run.

I created the database first in MySQL 5.0
I am able to build the project. But when I run setup-db, here is the log
from the console:

Buildfile: /home/lsacaut/projets/product_manager_8/build.xml
compile:
xdoclet:
[ojbdoclet] 2006-02-24 16:07:00,636 [main] INFO 
xdoclet.XDocletMain.start - Running <ojbrepository/>
[ojbdoclet] 2006-02-24 16:07:00,936 [main] INFO 
xdoclet.XDocletMain.start - Running <torqueschema/>
setup-db:
     [copy] Copying 1 file to
/home/lsacaut/projets/product_manager_8/build/database
check-use-classpath:
check-run-only-on-schema-change:
sql-check:
sql:
     [echo] +------------------------------------------+
     [echo] |                                          |
     [echo] | Generating SQL for YOUR Torque project!  |
     [echo] |                                          |
     [echo] +------------------------------------------+
sql-classpath:
     [echo] loading templates from classpath
[torque-sql] Using contextProperties file:
/home/lsacaut/projets/product_manager_8/build.properties
[torque-sql] Using classpath
[torque-sql] Generating to file
/home/lsacaut/projets/product_manager_8/build/database/report.product_manager_8.sql.generation
[torque-sql] 2006-02-24 16:07:01,992 [main] INFO 
org.apache.torque.engine.database.transform.XmlToAppData - Parsing file:
'ojbcore-schema.xml'
[torque-sql] 2006-02-24 16:07:01,998 [main] INFO 
org.apache.torque.engine.database.transform.DTDResolver - Resolver: used
database.dtd from 'org.apache.torque.engine.database.transform' package
[torque-sql] 2006-02-24 16:07:02,051 [main] INFO 
org.apache.torque.engine.database.transform.XmlToAppData - Parsing file:
'project-schema.xml'
[torque-sql] 2006-02-24 16:07:02,053 [main] INFO 
org.apache.torque.engine.database.transform.DTDResolver - Resolver: used
'http://db.apache.org/torque/dtd/database_3_2.dtd'
sql-template:
create-db-check:
create-db:
[torque-data-model] Using classpath
[torque-data-model] Generating to file
/home/lsacaut/projets/product_manager_8/build/database/create-db.sql
[torque-data-model] 2006-02-24 16:07:03,294 [main] INFO 
org.apache.torque.engine.database.transform.XmlToAppData - Parsing file:
'ojbcore-schema.xml'
[torque-data-model] 2006-02-24 16:07:03,297 [main] INFO 
org.apache.torque.engine.database.transform.DTDResolver - Resolver: used
database.dtd from 'org.apache.torque.engine.database.transform' package
[torque-data-model] 2006-02-24 16:07:03,334 [main] INFO 
org.apache.torque.engine.database.transform.XmlToAppData - Parsing file:
'project-schema.xml'
[torque-data-model] 2006-02-24 16:07:03,336 [main] INFO 
org.apache.torque.engine.database.transform.DTDResolver - Resolver: used
'http://db.apache.org/torque/dtd/database_3_2.dtd'
shutdown-check:
append-shutdown-sql:
     [echo] Executing the create-db.sql script ...
      [sql] Executing file:
/home/lsacaut/projets/product_manager_8/build/database/create-db.sql
      [sql] 2 of 2 SQL statements executed successfully
insert-sql:
[torque-sql-exec] Our new url -> jdbc:mysql://localhost/product_manager_8
[torque-sql-exec] Executing file:
/home/lsacaut/projets/product_manager_8/build/database/project-schema.sql
[torque-sql-exec] Failed to execute: #
-----------------------------------------------------------------------
[torque-sql-exec] # Client #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists Client; CREATE TABLE Client ( id
INTEGER NOT NULL, firstname VARCHAR (100), lastname VARCHAR (100),
address1 VARCHAR (255), address2 VARCHAR (255), city VARCHAR (100),
province VARCHAR (2), PRIMARY KEY(id) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # Product #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists Product; CREATE TABLE Product (
id INTEGER NOT NULL, name VARCHAR (100), price FLOAT, stock INTEGER,
PRIMARY KEY(id) );
[torque-sql-exec] java.sql.SQLException: Syntax error or access
violation,  message from server: "You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '; CREATE TABLE Client ( id INTEGER NOT NULL,
firstname VARCHAR (100), lastname V' at line 3"
[torque-sql-exec] Executing file:
/home/lsacaut/projets/product_manager_8/build/database/ojbcore-schema.sql
[torque-sql-exec] Failed to execute: #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_HL_SEQ #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_HL_SEQ; CREATE TABLE
OJB_HL_SEQ ( TABLENAME VARCHAR (250) NOT NULL, MAX_KEY BIGINT, GRAB_SIZE
INTEGER, VERSION INTEGER, PRIMARY KEY(TABLENAME) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_NRM #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_NRM; CREATE TABLE OJB_NRM (
NAME VARCHAR (250) NOT NULL, OID_ LONGBLOB, PRIMARY KEY(NAME) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DLIST #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DLIST; CREATE TABLE OJB_DLIST
( ID INTEGER NOT NULL, SIZE_ INTEGER, PRIMARY KEY(ID) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DLIST_ENTRIES #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DLIST_ENTRIES; CREATE TABLE
OJB_DLIST_ENTRIES ( ID INTEGER NOT NULL, DLIST_ID INTEGER NOT NULL,
POSITION_ INTEGER, OID_ LONGBLOB, PRIMARY KEY(ID) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DSET #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DSET; CREATE TABLE OJB_DSET (
ID INTEGER NOT NULL, SIZE_ INTEGER, PRIMARY KEY(ID) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DSET_ENTRIES #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DSET_ENTRIES; CREATE TABLE
OJB_DSET_ENTRIES ( ID INTEGER NOT NULL, DLIST_ID INTEGER NOT NULL,
POSITION_ INTEGER, OID_ LONGBLOB, PRIMARY KEY(ID) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DMAP #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DMAP; CREATE TABLE OJB_DMAP (
ID INTEGER NOT NULL, SIZE_ INTEGER, PRIMARY KEY(ID) ); #
-----------------------------------------------------------------------
[torque-sql-exec] # OJB_DMAP_ENTRIES #
-----------------------------------------------------------------------
[torque-sql-exec] drop table if exists OJB_DMAP_ENTRIES; CREATE TABLE
OJB_DMAP_ENTRIES ( ID INTEGER NOT NULL, DMAP_ID INTEGER NOT NULL,
KEY_OID LONGBLOB, VALUE_OID LONGBLOB, PRIMARY KEY(ID) );
[torque-sql-exec] java.sql.SQLException: Syntax error or access
violation,  message from server: "You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '; CREATE TABLE OJB_HL_SEQ ( TABLENAME VARCHAR
(250) NOT NULL, MAX_KEY BIGINT, GR' at line 3"
[torque-sql-exec] 0 of 2 SQL statements executed successfully
BUILD SUCCESSFUL
Total time: 4 seconds


How do I fix this????

thx
Laurent

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/1/06, Laurent Sacaut <ls...@8d.com> wrote:

> I tested the sql statements generated by torque in project--schema under
> build/database directly in the mysql command-line AND using mysqlcc and
> they work just fine.

Please use a tool that uses the JDBC driver, e.g. Squirrel SQL, or
Ant's sql task.

> I then created a small java class with a simple jdbc connection to run
> the same statment and i got some interesting results.
>
> When I use the executeQuery method such as stmt.executeQuery(sSQL); a
> similar error as mentioned in the original post stating that there is a
> syntax error or access violation. (I used a user/password combination
> that had rights to do so)
> Then I tried the executeUpdate method.
>
> I get no error when each statement is passed to the method separately.
> When I feed the whole file as a string, such as the 'drop table if
> exists ...' statement and the 'create table ...' statement separated by
> a semi-colon (;), I get a syntax error near the ';', which seems to make
> sense since the javadoc on the Statement java class does not mention
> that it can process multiple sql statements.
>
> I would think Torque would be able to handle this situation, maybe I am
> missing a library.

That is to be expected because AFAIK Torque does not execute the
generated SQL in one execute call but rather splits them.

> It seems that I am running into a parsing problem. I noticed that
> ojb-blank does not contain xercesImpl.jar, so I added one from another
> project but the version of it might be more or less compatible.
> How come the build-torque file refers to libraries that are not present
> in ojb-blank?

This is because its quite big, and all newer java distributions
contain an XML parser (I don't think Torque specifically needs Xerces,
they only require an XML parser), so there is usually no need to
include it into ojb-blank. Btw, you would have encountered an XML
parser way before these SQL problems - in fact you should not get that
far at all if you miss an XML parser.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Laurent Sacaut <ls...@8d.com>.
Hi Tom,

I tested the sql statements generated by torque in project--schema under
build/database directly in the mysql command-line AND using mysqlcc and
they work just fine.
I then created a small java class with a simple jdbc connection to run
the same statment and i got some interesting results.

When I use the executeQuery method such as stmt.executeQuery(sSQL); a
similar error as mentioned in the original post stating that there is a
syntax error or access violation. (I used a user/password combination
that had rights to do so)
Then I tried the executeUpdate method.

I get no error when each statement is passed to the method separately.
When I feed the whole file as a string, such as the 'drop table if
exists ...' statement and the 'create table ...' statement separated by
a semi-colon (;), I get a syntax error near the ';', which seems to make
sense since the javadoc on the Statement java class does not mention
that it can process multiple sql statements.

I would think Torque would be able to handle this situation, maybe I am
missing a library.

It seems that I am running into a parsing problem. I noticed that
ojb-blank does not contain xercesImpl.jar, so I added one from another
project but the version of it might be more or less compatible.
How come the build-torque file refers to libraries that are not present
in ojb-blank?

thx
Laurent


Thomas Dudziak wrote:

>On 2/28/06, Laurent Sacaut <ls...@8d.com> wrote:
>
>  
>
>>I ran the sql generated by torque as you suggested (the 3 files it
>>created: create-db.sql, ojbcore-schema.sql and project-schema.sql) and
>>they are fine. No error from MySQL 5.0 and all the tables are created.
>>
>>I am suspecting something subtile such as the order of the jar, or other
>>configuration settings or file location.
>>    
>>
>
>It could be anything really. You should ensure that you're using the
>newest JDBC driver. And you could test to execute the creation sql
>with your connection settings in a tool like Squirrel SQL
>(http://squirrel-sql.sourceforge.net/) to ensure that the user (i.e.
>'user@computer') is allowed to do this.
>
>Tom
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/28/06, Laurent Sacaut <ls...@8d.com> wrote:

> I ran the sql generated by torque as you suggested (the 3 files it
> created: create-db.sql, ojbcore-schema.sql and project-schema.sql) and
> they are fine. No error from MySQL 5.0 and all the tables are created.
>
> I am suspecting something subtile such as the order of the jar, or other
> configuration settings or file location.

It could be anything really. You should ensure that you're using the
newest JDBC driver. And you could test to execute the creation sql
with your connection settings in a tool like Squirrel SQL
(http://squirrel-sql.sourceforge.net/) to ensure that the user (i.e.
'user@computer') is allowed to do this.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Laurent Sacaut <ls...@8d.com>.
I ran the sql generated by torque as you suggested (the 3 files it
created: create-db.sql, ojbcore-schema.sql and project-schema.sql) and
they are fine. No error from MySQL 5.0 and all the tables are created.

I am suspecting something subtile such as the order of the jar, or other
configuration settings or file location.

I have class variables set to the top of their respective directories:

JAVA_HOME=/usr/lib/j2sdk1.5-sun/bin
ANT_HOME=/usr/share/ant/bin


Am i missing any other ones?
Laurent

Thomas Dudziak wrote:

>On 2/27/06, Laurent Sacaut <ls...@8d.com> wrote:
>
>  
>
>>Here are the settings from build.properties in ojb:
>>    
>>
>
><snip>
>
>These all look ok.
>
>  
>
>>I left the build-torque.xml file untouched, but I noticed that in the
>><path id="torque-classpath"> section, it is trying to include files I
>>don't have such as
>>commons-lang-1.0.1.jar    <-- using commons.lang.1.2.1.jar instead
>>village-2.0-dev-20030825.jar
>>xercesImpl-2.0.2.jar         <-- using xerces.jar instead
>>xmlParserAPIs-2.0.2.jar
>>    
>>
>
>Yep, that's ok.
>
>  
>
>>Any idea or suggestions?
>>    
>>
>
>It's a bit strange, the SQL that MySql complains about (CREATE TABLE
>Client ...), works without problems in MySQL 4.1.
>Could you try to execute the SQL that Torque generated (in
>build/database) manually via the mysql commandline ? If that fails,
>could you send me the SQL (off the list if you want) ?
>
>Tom
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/27/06, Laurent Sacaut <ls...@8d.com> wrote:

> Here are the settings from build.properties in ojb:

<snip>

These all look ok.

> I left the build-torque.xml file untouched, but I noticed that in the
> <path id="torque-classpath"> section, it is trying to include files I
> don't have such as
> commons-lang-1.0.1.jar    <-- using commons.lang.1.2.1.jar instead
> village-2.0-dev-20030825.jar
> xercesImpl-2.0.2.jar         <-- using xerces.jar instead
> xmlParserAPIs-2.0.2.jar

Yep, that's ok.

> Any idea or suggestions?

It's a bit strange, the SQL that MySql complains about (CREATE TABLE
Client ...), works without problems in MySQL 4.1.
Could you try to execute the SQL that Torque generated (in
build/database) manually via the mysql commandline ? If that fails,
could you send me the SQL (off the list if you want) ?

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Laurent Sacaut <ls...@8d.com>.
Hi Tom,

Here are the settings from build.properties in ojb:

"
header sniped...
...

cdAlias=prom8
databaseName=product_manager_8
databaseUser=root
databasePassword=

# For MySQL this would look like:
dbmsName=MySQL
jdbcLevel=3.0
jdbcRuntimeDriver=com.mysql.jdbc.Driver
urlProtocol=jdbc
urlSubprotocol=mysql
urlDbalias=//localhost/${databaseName}

torque.database=mysql

torque.database.createUrl=${urlProtocol}:${urlSubprotocol}://localhost/${databaseName}

torque.database.buildUrl=${torque.database.createUrl}


# Set this to the name of the jar file you want produced from the dist
target
jar.name=productManager8.jar

# This is the class containing the main method. Set this so that an
executable jar and
# appropriate batch/shell skripts can be automatically generated for you.
#source.main.class=org.apache.ojb.tutorial1.Application

################################################################################
# Build Properties - you shouldn't have to change anything here
#
source.dir=src
source.java.dir=${source.dir}/java
source.resource.dir=${source.dir}/resources
source.test.dir=${source.dir}/test
source.schema.dir=${source.dir}/schema

build.dir=build
lib.dir=lib

target.dir=target
"

I left the build-torque.xml file untouched, but I noticed that in the
<path id="torque-classpath"> section, it is trying to include files I
don't have such as
commons-lang-1.0.1.jar    <-- using commons.lang.1.2.1.jar instead
village-2.0-dev-20030825.jar
xercesImpl-2.0.2.jar         <-- using xerces.jar instead
xmlParserAPIs-2.0.2.jar


Any idea or suggestions?

Laurent

Thomas Dudziak wrote:

>On 2/24/06, Laurent Sacaut <ls...@8d.com> wrote:
>  
>
>>When trying to run the setup-db ant task from the build file, I am
>>getting an error coming from the build-torque.xml file.
>>I modified builds.properties and OJB.properties to fit my test project
>>but can get it to run.
>>
>>I created the database first in MySQL 5.0
>>I am able to build the project. But when I run setup-db, here is the log
>>from the console:
>>    
>>
>
>What are the settings that you feed to Torque (e.g. mysql profile, or
>build.properties when using ojb-blank) ?
>
>Tom
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: setup-db problems

Posted by Thomas Dudziak <to...@gmail.com>.
On 2/24/06, Laurent Sacaut <ls...@8d.com> wrote:
> When trying to run the setup-db ant task from the build file, I am
> getting an error coming from the build-torque.xml file.
> I modified builds.properties and OJB.properties to fit my test project
> but can get it to run.
>
> I created the database first in MySQL 5.0
> I am able to build the project. But when I run setup-db, here is the log
> from the console:

What are the settings that you feed to Torque (e.g. mysql profile, or
build.properties when using ojb-blank) ?

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org