Fehler SQL Query im Programm

Hallo zusammen,

ich habe folgendes Problem. Wenn ich mein Java Programm ausführe erscheint immer ein Fehler in der eingebetten SQL Abfragen.

private static List<Object[]> getWordAnalyse(String word){
return DatabaseAccess
.getSqlStatementResult(
"SELECT coocTable.corpusDate, coocTable.word, aFreq AS H?ñufigkeitY, aCooc AS SatzcoocY, bfreq as H?ñufigkeitX, value" +
"FROM(" +
"SELECT word, DATE(createDate) AS corpusDate, cooc AS aCooc" +
"FROM ("+
"SELECT createDate, word, count(DISTINCT sentence.id) AS cooc" +
"FROM" +
"     corpus " +
"INNER JOIN " +
"     article ON corpus.id = article.corpusId " +
"INNER JOIN " +
"     sentence ON article.id = sentence.articleId " +
"INNER JOIN " +
"     term ON sentence.id = term.sentenceId " +
"WHERE " +
"     sentence.id IN ( " +
"SELECT sentence.id" +
"FROM " +
"     corpus " +
"INNER JOIN " +
"     article ON corpus.id = article.corpusId " +
"INNER JOIN " +
"     sentence ON article.id = sentence.articleId " +
"INNER JOIN " +
"     term ON sentence.id = term.sentenceId" +
"WHERE corpus.id = " + currentCorpus.getId() +
" 'AND " +
"word = '" + word + "' " +
") " +
"GROUP BY createDate, word" +
") AS tempTable1 " +
"GROUP BY corpusDate, word " +
") " +
"AS coocTable " +
"INNER JOIN ( " +
"SELECT word, corpusDate, freq AS bFreq " +
"FROM ( " +
"SELECT word,  DATE(createDate) AS corpusDate, " +
"     count(DISTINCT sentence.id) AS freq" +
"FROM " +
"     corpus " +
"INNER JOIN " +
"     article ON corpus.id = article.corpusId " +
"INNER JOIN " +
"     sentence ON article.id = sentence.articleId " +
"INNER JOIN " +
"     term ON sentence.id = term.sentenceId " +
"where corpus.id = " + currentCorpus.getId() +
"'AND " +
"word ='" + word + "'  " +
"GROUP BY createDate, word) AS tempTable " +
"GROUP BY corpusDate, word)" +
"AS freqTables " +
"INNER JOIN ( " +
"SELECT word, corpusDate, freq AS aFreq " +
"FROM ( " +
"SELECT word,  DATE(createDate) AS corpusDate, " +
"count(DISTINCT sentence.id) AS freq" +
"FROM " +
"     corpus " +
"INNER JOIN " +
"     article ON corpus.id = article.corpusId " +
"INNER JOIN " +
"     sentence ON article.id = sentence.articleId " +
"INNER JOIN " +
"     term ON sentence.id = term.sentenceId "+
"GROUP BY createDate, word) AS tempTable2 " +
"GROUP BY corpusDate, word)" +
"AS freqTable ON coocTable.corpusDate = freqTable.corpusDate " +
"INNER JOIN sentiws on coocTable.word = sentiws.word" +
"WHERE coocTable.word = freqTable.word " +
"ORDER BY coocTable.word, coocTable.corpusDate;"
);

Die SQL Abfrage funktioniert aber einwandfrei.

[SQL]
SELECT coocTable.corpusDate, coocTable.word, aFreq AS H?§ufigkeitY, aCooc AS SatzcoocY, bfreq as H?§ufigkeitX, value
FROM(
SELECT word, DATE(createDate) AS corpusDate, cooc AS aCooc
FROM (
SELECT createDate, word, count(DISTINCT sentence.id) AS cooc
FROM
corpus
INNER JOIN
article ON corpus.id = article.corpusId
INNER JOIN
sentence ON article.id = sentence.articleId
INNER JOIN
term ON sentence.id = term.sentenceId
WHERE
sentence.id IN (
SELECT sentence.id
FROM
corpus
INNER JOIN
article ON corpus.id = article.corpusId
INNER JOIN
sentence ON article.id = sentence.articleId
INNER JOIN
term ON sentence.id = term.sentenceId
WHERE corpus.id = 1 AND word = ‘Schalke’
)
GROUP BY createDate, word
) AS tempTable1
GROUP BY corpusDate, word
)
AS coocTable
INNER JOIN (
SELECT word, corpusDate, freq AS bFreq
FROM (
SELECT word, DATE(createDate) AS corpusDate,
count(DISTINCT sentence.id) AS freq
FROM
corpus
INNER JOIN
article ON corpus.id = article.corpusId
INNER JOIN
sentence ON article.id = sentence.articleId
INNER JOIN
term ON sentence.id = term.sentenceId
where corpus.id = 1 AND word =‘Schalke’

GROUP BY createDate, word) AS tempTable
GROUP BY corpusDate, word
)
AS freqTables
INNER JOIN (
SELECT word, corpusDate, freq AS aFreq
FROM (
SELECT word, DATE(createDate) AS corpusDate,
count(DISTINCT sentence.id) AS freq
FROM
corpus
INNER JOIN
article ON corpus.id = article.corpusId
INNER JOIN
sentence ON article.id = sentence.articleId
INNER JOIN
term ON sentence.id = term.sentenceId
GROUP BY createDate, word) AS tempTable2
GROUP BY corpusDate, word
)
AS freqTable ON coocTable.corpusDate = freqTable.corpusDate
INNER JOIN sentiws on coocTable.word = sentiws.word
WHERE coocTable.word = freqTable.word
ORDER BY coocTable.word, coocTable.corpusDate

[/SQL]

Könnt ihr erkennen was ich im oberen Teil falsche gemacht habe?

Vielen dank

Was denn für ein Fehler?

Das mit der SQL Abfrage etwas nicht stimmt. Obwohl die, wenn ich sie in der My SQl Workbench eingebe funktioniert

Normalerweise sind Fehlermeldungen etwas aussagekräftiger als “Mit der Abfrage stimmt etwas nicht”. Natürlich könnte man versuchen, das nachzustellen - aber warum? Dir liegt doch die konkrete Fehlermeldung vor; warum stellst Du die hier nicht ein (noch nichtmal auf Nachfrage)?

das ist ganz einfach du hast alle Zeilenumbrüche/Leerzeichen entfernt, mach dein Query als ein String und er läuft

ganz wichtig:
am Ende jeder Zeile muss im String ein Leerzeichen stehen oder
.

byt
TT

Und ganz wichtig, benutz bitte keine Umlaute im Spaltennamen!