-3
Class.forName("org.hsqldb.jdbcDriver");
    conn = DriverManager.getConnection("jdbc:hsqldb:file:Pokemondaten","sa","");
    getData = conn.createStatement();
    ResultSet rs = getData.executeQuery
    ("SELECT HP FROM PKMN WHERE ID = " + basicnumber); 
    int hpp = rs.getInt(1);
    System.out.println(hpp);

all I get is

java.sql.SQLException: Table not found in statement [SELECT HP FROM PKMN]
    at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
    at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
    at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
    at pokeWpRechner.Main.main(Main.java:46)

My Databased is called Pokemondatenand my table is called PKMN, also my table is inherited in the programm.

So what did i do wrong? i dont get it.

Eveli
  • 498
  • 1
  • 6
  • 27

2 Answers2

1

Try the following

conn = DriverManager.getConnection("jdbc:hsqldb:file:Pokemondaten;shutdown=true","sa","")

This should prevent the table definition to being lost

coding-dude.com
  • 758
  • 1
  • 8
  • 27
0

I think you need to provide the full path to your database file in the JDBC URL:

DriverManager.getConnection("jdbc:hsqldb:file:c:\mydir\Pokemondaten","sa","");

rohitvats
  • 1,811
  • 13
  • 11
  • thats what i tried to avoid :( i want the location of the DB top be flexible (where the program is) but i will try to get it running anyways – Eveli Aug 28 '16 at 10:29
  • 1
    @Ekonion you should be able to get the current path from where your program is running like this: `Paths.get(".").toAbsolutePath().normalize().toString()` and then you can use this string to create an absolute path to your database file. – rohitvats Aug 28 '16 at 10:32
  • `java.sql.SQLException: No data is available` still – Eveli Aug 28 '16 at 10:36