Hello,
There is always the problem with "UTF8MB4". I have JWPL 0.8.0 and
mySQL 5.5.
My Wikipedia language is French. Any idea? Please help!!!
public class TestWiki implements WikiConstants {
public static void main(String[] args) throws WikiApiException {
// configure the database connection parameters
DatabaseConfiguration dbConfig = new DatabaseConfiguration();
dbConfig.setHost("localhost:3306");
dbConfig.setDatabase("wiki_fr");
dbConfig.setUser("root");
dbConfig.setPassword("...");
dbConfig.setLanguage(Language.french);
// Create a new German wikipedia.
Wikipedia wiki = new Wikipedia(dbConfig);
// Get the category "Towns in Germany"
String title = "Ville";
Category topCat;
try {
topCat = wiki.getCategory(title);
} catch (WikiPageNotFoundException e) {
throw new WikiApiException("Category " + title + " does
not exist");
}
// Add the pages categorized under "Towns in Germany".
Set<String> towns = new TreeSet<String>();
for (Page p : topCat.getArticles()) {
towns.add(p.getTitle().getPlainTitle());
}
// Get the pages categorized under each subcategory of "Towns
in Germany".
for (Category townCategory : topCat.getDescendants()) {
for (Page p : townCategory.getArticles()) {
towns.add(p.getTitle().getPlainTitle());
}
System.out.println("Number of towns: " + towns.size());
}
// Output the pages
for (String town : towns) {
System.out.println(town);
}
}
}
Exception in thread "main"
org.hibernate.exception.SQLGrammarException: could not execute query
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
90)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:
312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:
1723)
at
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:
165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at
org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:
835)
at
de.tudarmstadt.ukp.wikipedia.api.Category.createCategory(Category.java:
102)
at de.tudarmstadt.ukp.wikipedia.api.Category.<init>(Category.java:69)
at
de.tudarmstadt.ukp.wikipedia.api.Wikipedia.getCategory(Wikipedia.java:
396)
at com.softcust.client.TestWiki.main(TestWiki.java:35)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:
2113)
at
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:
2275)
at
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:
208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 11 more
Original issue reported on code.google.com by zhan.con...@gmail.com on 27 Jan 2012 at 1:38
Original issue reported on code.google.com by
zhan.con...@gmail.com
on 27 Jan 2012 at 1:38