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

java.sql.SQLDataException: A truncation error was encountered trying to shrink VARCHAR #2

Closed
GoogleCodeExporter opened this issue Feb 13, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. 
http://code.google.com/p/gwtwiki/source/browse/trunk/info.bliki.wiki.test/bliki-
test/src/main/java/info/bliki/api/HTMLCreatorTest.java
2. Create a new class with main and cut'n'pastetestWikipediaENAPI(String title) 
and call in main  
testWikipediaENAPI("Tom Hanks");

What is the expected output? What do you see instead?
The HTML output. Several logged SQL exception:

java.sql.SQLDataException: A truncation error was encountered trying to shrink 
VARCHAR 
'Template:anchorencode:{{#if:Riggs
      |Riggs{{{surname2|{{&' to length 256.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
    at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
    at info.bliki.api.creator.WikiDB.insertTopic(WikiDB.java:140)
    at info.bliki.wiki.model.APIWikiModel.getRawWikiContent(APIWikiModel.java:93)
    at info.bliki.wiki.filter.TemplateParser.parseTemplate(TemplateParser.java:410)
    at 
info.bliki.wiki.filter.TemplateParser.parseTemplateOrTemplateParameter(TemplateP
arser.java:351
)
    at info.bliki.wiki.filter.TemplateParser.runParser(TemplateParser.java:152)
    at info.bliki.wiki.filter.TemplateParser.parseRecursive(TemplateParser.java:87)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:53)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:36)
    at 
info.bliki.wiki.template.AbstractTemplateFunction.parse(AbstractTemplateFunction
.java:40)
    at info.bliki.wiki.template.If.parseFunction(If.java:31)
    at info.bliki.wiki.filter.TemplateParser.parseTemplate(TemplateParser.java:393)
    at 
info.bliki.wiki.filter.TemplateParser.parseTemplateOrTemplateParameter(TemplateP
arser.java:351
)
    at info.bliki.wiki.filter.TemplateParser.runParser(TemplateParser.java:152)
    at info.bliki.wiki.filter.TemplateParser.parseRecursive(TemplateParser.java:87)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:53)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:36)
    at 
info.bliki.wiki.template.AbstractTemplateFunction.parse(AbstractTemplateFunction
.java:40)
    at info.bliki.wiki.template.If.parseFunction(If.java:35)
    at info.bliki.wiki.filter.TemplateParser.parseTemplate(TemplateParser.java:393)
    at 
info.bliki.wiki.filter.TemplateParser.parseTemplateOrTemplateParameter(TemplateP
arser.java:351
)
    at info.bliki.wiki.filter.TemplateParser.runParser(TemplateParser.java:152)
    at info.bliki.wiki.filter.TemplateParser.parseRecursive(TemplateParser.java:87)
    at info.bliki.wiki.filter.TemplateParser.parseTemplate(TemplateParser.java:415)
    at 
info.bliki.wiki.filter.TemplateParser.parseTemplateOrTemplateParameter(TemplateP
arser.java:351
)
    at info.bliki.wiki.filter.TemplateParser.runParser(TemplateParser.java:152)
    at info.bliki.wiki.filter.TemplateParser.parseRecursive(TemplateParser.java:87)
    at info.bliki.wiki.filter.TemplateParser.parseTemplate(TemplateParser.java:415)
    at 
info.bliki.wiki.filter.TemplateParser.parseTemplateOrTemplateParameter(TemplateP
arser.java:351
)
    at info.bliki.wiki.filter.TemplateParser.runParser(TemplateParser.java:152)
    at info.bliki.wiki.filter.TemplateParser.parseRecursive(TemplateParser.java:87)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:53)
    at info.bliki.wiki.filter.TemplateParser.parse(TemplateParser.java:36)
    at info.bliki.wiki.filter.WikipediaParser.parse(WikipediaParser.java:1388)
    at info.bliki.wiki.model.AbstractWikiModel.render(AbstractWikiModel.java:825)
    at info.bliki.api.creator.DocumentCreator.render(DocumentCreator.java:91)
    at info.bliki.api.creator.DocumentCreator.renderToFile(DocumentCreator.java:128)
    at info.bliki.api.creator.DocumentCreator.renderToFile(DocumentCreator.java:140)
    at name.davids.sebastian.example.xom.Main.main(Main.java:39)
Caused by: java.sql.SQLException: A truncation error was encountered trying to 
shrink VARCHAR 
'Template:anchorencode:{{#if:Riggs
      |Riggs{{{surname2|{{&' to length 256.
    at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
    at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(
Unknown 
Source)
    ... 47 more
Caused by: ERROR 22001: A truncation error was encountered trying to shrink 
VARCHAR 
'Template:anchorencode:{{#if:Riggs
      |Riggs{{{surname2|{{&' to length 256.
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.iapi.types.SQLChar.hasNonBlankChars(Unknown Source)
    at org.apache.derby.iapi.types.SQLVarchar.normalize(Unknown Source)
    at org.apache.derby.iapi.types.SQLVarchar.normalize(Unknown Source)
    at org.apache.derby.iapi.types.DataTypeDescriptor.normalize(Unknown Source)
    at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeRow(Unknown Source)
    at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(Unknown Source)
    at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source)
    at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
    at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
    ... 41 more

What version of the product are you using? On what operating system?

<bliki.version>3.0.10</bliki.version>
<derby.version>10.4.2.0</derby.version>

Please provide any additional information below.

http://code.google.com/p/gwtwiki/source/browse/trunk/info.bliki.wiki/bliki-
core/src/main/java/info/bliki/api/creator/WikiDB.java

        private void createTableIfItDoesntExist() throws Exception {
...
                        statement.execute("CREATE TABLE topic "
                                        + "(topic_id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START 
WITH 1, INCREMENT BY 1),"
                                        + " topic_name VARCHAR(256) NOT NULL, " + " version_content CLOB, " + 
" CONSTRAINT PK_Topic PRIMARY KEY (topic_id) "
                                        + " ) ");

...
                        statement.execute("CREATE TABLE image "
                                        + "(image_id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START 
WITH 1, INCREMENT BY 1),"
                                        + " image_name VARCHAR(256) NOT NULL, " + " image_url 
VARCHAR(1024) NOT NULL, "
                                        + " image_filename VARCHAR(1024) NOT NULL, " + " CONSTRAINT 
PK_Image PRIMARY KEY (image_id) " + " ) ");

The statements should either be configurable.

Original issue reported on code.google.com by sebastia...@gmail.com on 20 Mar 2009 at 11:56

@GoogleCodeExporter
Copy link
Author

The problem seems to be, that the Mediawiki parser function "anchorencode" 
isn't 
implemented yet in the Bliki engine:
http://en.wikipedia.org/wiki/Help:Parser_function#ANCHORENCODE

Could you please try, if these (currently untested) changes solve the problem:
http://code.google.com/p/gwtwiki/source/detail?r=72
http://code.google.com/p/gwtwiki/source/detail?r=73

Original comment by axelclk@gmail.com on 26 Mar 2009 at 9:34

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

Original comment by axelclk@gmail.com on 27 Mar 2009 at 11:01

  • Changed state: Fixed

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

No branches or pull requests

1 participant