Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.sh: MySQLSyntaxErrorException - DROP DATABASE ${database} #282

Closed
gallardo opened this issue Oct 1, 2014 · 3 comments
Closed

setup.sh: MySQLSyntaxErrorException - DROP DATABASE ${database} #282

gallardo opened this issue Oct 1, 2014 · 3 comments

Comments

@gallardo
Copy link
Contributor

gallardo commented Oct 1, 2014

The provided webapps/opencms/WEB-INF/setup.sh aborts with a com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException.

From the mysql logs I could find that OpenCms is actually executing the following SQL (sic!):

DROP DATABASE ${database}

Output and stacktrace follows:

$webapps/opencms/WEB-INF/setup.sh -path setup.properties

-------------------------------------------------
Setup started at: (Wed Oct 01 14:07:11 CEST 2014)
-------------------------------------------------

Using config file: setup.properties:
dbWorkPwd = opencmsuser
templateDb = null
dbDefaultTablespace = null
jdbcDriver = org.gjt.mm.mysql.Driver
dbCreateConStr = jdbc:mysql://localhost:3306/
submit = true
dbProduct = mysql
dbCreateUser = opencmsroot
dbTemporaryTablespace = null
dbName = opencms
servletMapping = null
dbIndexTablespace = null
dbWorkUser = opencmsuser
dbCreatePwd = opencmsroot
createTables = true
dbProvider = sql
dropDb = true
createDb = true
db = opencms

System requirements tested successfully.
log4j:WARN No appenders could be found for logger (org.opencms.init).
log4j:WARN Please initialize the log4j system properly.
Setup-Bean initialized successfully.
DB connection tested successfully.
Error executing SQL statement:  



 DROP DATABASE ${database}

-------------------------------------------

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 '{database}' at line 1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894)
    at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732)
    at org.opencms.setup.CmsSetupDb.executeStatement(CmsSetupDb.java:729)
    at org.opencms.setup.CmsSetupDb.executeSql(CmsSetupDb.java:644)
    at org.opencms.setup.CmsSetupDb.executeSql(CmsSetupDb.java:707)
    at org.opencms.setup.CmsSetupDb.dropDatabase(CmsSetupDb.java:248)
    at org.opencms.setup.CmsAutoSetup.run(CmsAutoSetup.java:269)
    at org.opencms.setup.CmsAutoSetup.main(CmsAutoSetup.java:108)


-------------------------------------------

An error occurred during the setup process with the following error message:
Error ocurred while dropping the DB!
Please have a look into the opencms log file for detailed information.
@gallardo
Copy link
Contributor Author

I found the root of the problem: a wrong setup.properties. I've written mine on the basis of the provided https://github.com/alkacon/opencms-core/blob/branch_9_5_x/src-setup/org/opencms/setup/setup.properties.example, that configures db.provider=sql.

After a few more tests, I'll push tomorrow a PR to provide a more sensible error than the You have an error in your SQL syntax;... referring to that DROP DATABASE ${database} statement.

@gallardo
Copy link
Contributor Author

Published PR #346 to deal with this issue.

@aKandzior
Copy link
Member

Closing as the PR has been merged into 9.5.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants