Re: sql statements execution error
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] com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 Still no luck, and now we see the same problem crop up yet again. I tried the following to debug this: 1. Create an ant task insert-sql in build.xml that directly calls the insert-sql task in build-torque.xml: target name=insert-sql property name=torque.buildFile value=${source.schema.dir}/build-torque.xml/ property name=torque.project value=${databaseName}/ property name=torque.schema.dir value=${build.dir}/database/ property name=torque.output.dir value=${build.dir}/database/ property name=torque.sql.dir value=${torque.output.dir}/ property name=torque.useClasspath value=true/ property name=torque.database.driver value=${jdbcRuntimeDriver}/ property name=torque.database.user value=${databaseUser}/ property name=torque.database.password value=${databasePassword}/ ant dir=. antfile=${torque.buildFile} target=insert-sql /ant /target 2. Edit the generated project-schema.sql and ojbcore-schema.sql and run ant insert-sql I found that if there is only 1 SQL statement in each .sql file this works! For example if project-schema.sql reads: # --- # Product # --- drop table if exists Product; CREATE TABLE Product ( id INTEGER NOT NULL, name VARCHAR (100), price FLOAT, stock INTEGER, PRIMARY KEY(id) ); it fails. if i remove everything before CREATE it works, but if I leave the drop table it fails. I can leave the comments in and it succeeds. So my question is - how do I get torque to automatically set up the DB for me? I thought this would be working out of the box? It is not convinient for me to browse the .sql files to snip each one out into mysql manually every time i change the schema. Anyone??? I Really need help on this one. Thanks, -- Brian From: Prestige Spas spasprest...@yahoo.com.au To: ojb-user@db.apache.org Sent: Friday, 13 February, 2009 9:54:00 AM Subject: Re: sql statements execution error Hello All, I have searched the archives and not seen an answer to this, but I am having the same trouble with the torque insert-sql task, as called from the OJB build.xml. I have attached an old post that shows the exact same problem I am seeing here. My project is assembled from ojb-blank.jar and my settings are similar to what is reported below, except that I am not running inside of tomcat, simply trying to develop in eclipse at this stage and run from there. ant setup-db always returns BUILD SUCESSFUL but the ant task prints all the sql statements together and says 0 of 2 statements executed sucessfully, the problem being a MySQLSyntaxErrorException thrown when torque is trying to create the OJB_HL_SEQ table. I have tried this in ojb-blank.jar also and the same problem happened from day one. I am running OJB 1.0.4 with mysql 5.0.51a and version 5.0.8 of the mysql JDBC driver. Java version is 1.5.0_16. If anyone out there is able to shed any light on this I would appreciate it, as I have been tearing my hair out for days on this now and I cannot think what is wrong. Obviously ojb-blank should just work out of the box with MySQL, and I think i have set everything up correctly (profile=mysql, edit the profile/mysql.profile, torque.database=mysql, dbmsName=MySQL). I have tested that the driver works with SQuirreL and mysql-query-browser is able to execute the generated SQL statements *individually* from build/database/project-schema.sql (but not if i simply paste the whole file). TIA -Brian Hai, I have a problem in doing an ant build The sql statements throw [torque-sql-exec] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds
Re: sql statements execution error
Hello All, I have searched the archives and not seen an answer to this, but I am having the same trouble with the torque insert-sql task, as called from the OJB build.xml. I have attached an old post that shows the exact same problem I am seeing here. My project is assembled from ojb-blank.jar and my settings are similar to what is reported below, except that I am not running inside of tomcat, simply trying to develop in eclipse at this stage and run from there. ant setup-db always returns BUILD SUCESSFUL but the ant task prints all the sql statements together and says 0 of 2 statements executed sucessfully, the problem being a MySQLSyntaxErrorException thrown when torque is trying to create the OJB_HL_SEQ table. I have tried this in ojb-blank.jar also and the same problem happened from day one. I am running OJB 1.0.4 with mysql 5.0.51a and version 5.0.8 of the mysql JDBC driver. Java version is 1.5.0_16. If anyone out there is able to shed any light on this I would appreciate it, as I have been tearing my hair out for days on this now and I cannot think what is wrong. Obviously ojb-blank should just work out of the box with MySQL, and I think i have set everything up correctly (profile=mysql, edit the profile/mysql.profile, torque.database=mysql, dbmsName=MySQL). I have tested that the driver works with SQuirreL and mysql-query-browser is able to execute the generated SQL statements *individually* from build/database/project-schema.sql (but not if i simply paste the whole file). TIA -Brian Hai, I have a problem in doing an ant build The sql statements throw [torque-sql-exec] com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 Product ( id INTEGER NOT NULL, name VARCHAR (100), price FLOAT, sto' at line 3 I want the ant script to create the database productmanager at runtime. I'm using MySQL Server version 5.1.6 Below shown is my build.properties file: jcdAlias=default databaseName=productmanager databaseUser=root databasePassword=root tomcat.home=${env.CATALINA_HOME} tomcat.url=http://localhost:8080 tomcat.manager.url=${tomcat.url}/manager # This user should be present in the $CATALINA_HOME/conf/tomcat-users.xml file with the role 'manager': tomcat.username=tomcat tomcat.password=tomcat embeddedDatabase=false dbmsName=MySQL jdbcLevel=3.0 jdbcRuntimeDriver=com.mysql.jdbc.Driver urlProtocol=jdbc urlSubprotocol=mysql urlDbalias=//localhost:3306/${databaseName} torque.database=mysql torque.database.createUrl=${urlProtocol}:${urlSubprotocol}://localhost:3306/${databaseName} torque.database.driver=${jdbcRuntimeDriver} torque.database.user=${databaseUser} torque.database.password=${databasePassword} torque.database.buildUrl=${torque.database.createUrl} 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 source.webapp.dir=${source.dir}/webapp build.dir=build lib.dir=lib lib.webapp.excludes=xdoclet*.jar,xjavadoc*.jar,torque*.jar,velocity*.jar target.dir=target servlet.lib=${tomcat.home}/common/lib/servlet-api.jar jsp.lib=${tomcat.home}/common/lib/jsp-api.jar deploy.dir=${tomcat.home}/webapps embedded.database.excludes=*schema.xml,*.sql,*.sql.generation,sqldb.map Below shown is the log details: (see the highlighted text in red color) C:\Users\karthiksg\Desktop\webapp-sample\webapp-sampleant Buildfile: build.xml compile: xdoclet: [ojbdoclet] 2008-11-09 17:51:00,188 [main] INFO xdoclet.XDocletMain.start - Run ning ojbrepository/ [ojbdoclet] 2008-11-09 17:51:00,783 [main] INFO xdoclet.XDocletMain.start - Run ning torqueschema/ war: compile: xdoclet: [ojbdoclet] 2008-11-09 17:51:02,105 [main] INFO xdoclet.XDocletMain.start - Run ning ojbrepository/ [ojbdoclet] 2008-11-09 17:51:02,604 [main] INFO xdoclet.XDocletMain.start - Run ning torqueschema/ setup-db: 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: C:\Users\karthiksg\Desktop\webapp-sam ple\webapp-sample\build.properties [torque-sql] Using classpath [torque-sql] Generating to file C:\Users\karthiksg\Desktop\webapp-sample\webapp- sample\build\database\report.productmanager.sql.generation [torque-sql] 2008-11-09 17:51:04,499 [main] INFO org.apache.torque.engine.datab ase.transform.XmlToAppData - Parsing file: 'ojbcore-schema.xml' [torque-sql] 2008-11-09 17:51:04,522 [main] INFO org.apache.torque.engine.datab ase.transform.DTDResolver - Resolver: