Beiträge von CJ-Super

    Ich spreche die Datenbank in Java über den jdbcDriver an. Folgender Code läuft auch ohne Probleme:

    Code
    [size=10]ResultSet resultSet = [/SIZE][B][size=10][COLOR=#7f0055][size=10][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][size=10].[/SIZE][size=10][COLOR=#0000c0][size=10][COLOR=#0000c0]verbindung[/COLOR][/SIZE][/COLOR][/SIZE][size=10].executeQuery[/SIZE]
     [size=10]([/SIZE][size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"SELECT Mann, Benutzername, Passwort, Gewicht, "[/COLOR][/SIZE][/COLOR][/SIZE][size=10] +[/SIZE]
    
    
    [align=left][size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"Erstellzeit From (Nutzer INNER JOIN Programmressourcen "[/COLOR][/SIZE][/COLOR][/SIZE][size=10] +[/SIZE] 
    [size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"ON Nutzer.ID = Programmressourcen.ID)"[/COLOR][/SIZE][/COLOR][/SIZE][size=10]);[/SIZE][/align]


    Wenn ich aber eine Bedingung anhänge bekomme ich eine Exception geworfen. Die lokale Variable ID,. die angehängt wird, ist dabei die ID die gesucht ist.


    Code
    [align=left][size=10][size=10]ResultSet resultSet2 = [/SIZE][/SIZE][size=10][B][size=10][COLOR=#7f0055][size=10][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][size=10].[/SIZE][size=10][COLOR=#0000c0][size=10][COLOR=#0000c0]verbindung[/COLOR][/SIZE][/COLOR][/SIZE][size=10].executeQuery[/SIZE][/SIZE][size=10] 
    [size=10]([/SIZE][size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"SELECT Mann, Benutzername, Passwort, Gewicht, "[/COLOR][/SIZE][/COLOR][/SIZE][size=10] +[/SIZE]
    
    
    [size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"Erstellzeit From (Nutzer INNER JOIN Programmressourcen "[/COLOR][/SIZE][/COLOR][/SIZE][size=10] +[/SIZE] 
    [size=10][COLOR=#2a00ff][size=10][COLOR=#2a00ff]"ON Nutzer.ID = Programmressourcen.ID) WHERE Nutzer.ID = "[/COLOR][/SIZE][/COLOR][/SIZE][size=10] + ID);[/SIZE][/align]
    [/SIZE]


    Lasse ich den Code mit resultSet2 durchlaufen bekomme ich folgende Exception:


    Code
    [align=left][U][size=10][COLOR=#000080][size=10][COLOR=#000080]java.sql.SQLException[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]: user lacks privilege or object not found: NUTZER.ID[/COLOR][/SIZE][/COLOR][/SIZE] [size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at org.hsqldb.jdbc.Util.sqlException(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)[/COLOR][/SIZE][align=left][size=10][COLOR=#ff0000]at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at cocktail_2_0.datenbank.Datenbankverbindung.executeQuery([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]Datenbankverbindung.java:50[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE] [/align][align=left][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.datenbank.Datenbank.getNutzer([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]Datenbank.java:593[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][/align][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.system.CocktailSystem.loadCocktailprogramm([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]CocktailSystem.java:36[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.system.CocktailSystem.<init>([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]CocktailSystem.java:31[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.gui.Hauptbildschirm.cocktailSystemErzeugen([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]Hauptbildschirm.java:190[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.gui.Hauptbildschirm.<init>([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]Hauptbildschirm.java:47[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at cocktail_2_0.gui.Hauptbildschirm.main([/COLOR][/SIZE][/COLOR][/SIZE][U][size=10][COLOR=#000080][size=10][COLOR=#000080]Hauptbildschirm.java:43[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000])[/COLOR][/SIZE][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]Caused by: [/COLOR][/SIZE][/COLOR][/SIZE][align=left][U][size=10][COLOR=#000080][size=10][COLOR=#000080]org.hsqldb.HsqlException[/COLOR][/SIZE][/COLOR][/SIZE][/U][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]: user lacks privilege or object not found: NUTZER.ID[/COLOR][/SIZE][/COLOR][/SIZE][/align][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]at org.hsqldb.error.Error.error(Unknown Source)[/COLOR][/SIZE][align=left][size=10][COLOR=#ff0000]at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)[/COLOR][/SIZE][align=left][size=10][COLOR=#ff0000]at org.hsqldb.QueryExpression.resolve(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.ParserCommand.compilePart(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.ParserCommand.compileStatements(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.Session.executeDirectStatement(Unknown Source)[/COLOR][/SIZE][size=10][COLOR=#ff0000]at org.hsqldb.Session.execute(Unknown Source)[/COLOR][/SIZE][/align][/align][/COLOR][/SIZE][size=10][COLOR=#ff0000][size=10][COLOR=#ff0000]... 9 more[/COLOR][/SIZE][/COLOR][/SIZE]


    [/SIZE]
    [/align]

    sry, fehler beim Kopieren, im Quelltext hab ich natürlich "INNER JOIN". Und wenn ich die gleiche Abfrage bei MYSQL eingebe funktioniert sie dort auch, warum also nicht bei HSQL obwohl doch die Version 2.0.0 SQL-92 unterstützt... Bin halt im Moment etwas ratlos, hab es im Moment so gelöst, das ich die Tabellen nicht verknüpfe, sondern einfach zwei SQL-Anfragen sende, eine zu der Tabelle Nutzer und eine zu der Tabelle Programmressourcen:

    "SELECT Mann, Benutzername, Passwort, Gewicht FROM Nutzer

    WHERE ID = 0"



    "SELECT Erstellzeit FROM Programmressourcen WHERE ID = 0"

    Und dann besorge ich mir meine Daten halt aus beiden ResultSet´s, ist aber jetzt nicht die beste Lösung und wüsste halt schon gerne was ich falsch mache. Braucht ihr noch Informationen, z.B. die Create-Anweisungen oder sonst irgendetwas oder könnt ihr euch auch keinen Reim darauf machen?

    Hi,

    ich hoffe das ist der richtige Bereich dafür.

    Ich versuche mich gerade daran Java mit einer Datenbank zu verbinden. Als Datenbank habe ich HSQLDB in der Version 2.0.0 genommen. Ich habe mein Programm auch schon mit HSQL verbunden und kann auch schon Select-Anweisungen durchführen, allerdings habe ich bei einer Select-Anweisung ein Problem und ich weiß nicht warum und wie ich es lösen kann.

    Wenn ich

    "SELECT Mann, Benutzername, Passwort, Gewicht, Erstellzeit From (Nutzer INNER JOIN Programmressourcen ON Nutzer.ID = Programmressourcen.ID);"

    Benutze funktioniert das Problemlos, möchte ich allerdings ein

    "WHERE
    Nutzer.ID = 0;"

    hinten anhängen, bekomme ich auf einmal eine SQL-Exception geworfen:

    user lacks privilege or object not found: NUTZER.ID

    obwohl er diese Spalte für den JOIN ja auch findet...:coolgrim: Den gleichen Fehler bekommt er auch wenn ich

    "SELECT Nutzer.ID, Mann, Benutzername, Passwort, Gewicht, Erstellzeit From (Nutzer INNER JOIN Programmressourcen ON Nutzer.ID = Programmressourcen.ID);"

    schreibe, aber nicht bei

    "SELECT Nutzer.ID, Mann, Benutzername, Passwort, Gewicht FROM Nutzer;"


    Ich hoffe ich hab mein Problem einigermaßen verständlich dargelegt:engel:

    Ach ja, ich benutze eine Standalone HSQLDB falls es etwas nützt...