Table Not Found

977 views
Skip to first unread message

Marving Jr

unread,
Jul 28, 2018, 9:23:14 AM7/28/18
to H2 Database
Hi
I'm trying to use explicit relative path url, but I get error Table Not Found

Project Netbeans
 AppDatabase
    build
    dist
    nbproject
    res
      db
        ENTERPRISE.mv.db
    src

===================================
DaoFactoryAbs df = DaoFactoryAbs.getInstance("jdbc", "h2", "ENTERPRISE");
CustomerDaoAbs customerDao = df.getCustomerDao();
customerDao.findAll().forEach(System.out::println);
===================================

connection = DriverManager.getConnection(url, user, password); 


    if url is  "jdbc:h2:~/Code/project/nb/AppDatabase/res/db/ENTERPRISE";
      All is ok
      
    but
    if url is  "jdbc:h2:./res/db/ENTERPRISE";
      connection is ok
      but get error 
Caused by: appdatabase.dao.exception.DaoException: org.h2.jdbc.JdbcSQLException: Tabla "CUSTOMER" no encontrada
        Table "CUSTOMER" not found; SQL statement:
SELECT * FROM CUSTOMER [42102-197]

Can someone tell me the reason for this error?


Andrei Tokar

unread,
Jul 28, 2018, 2:44:54 PM7/28/18
to H2 Database
Make sure your current directory on JVM startup is AppDatabase.
Connection is "Ok", because it probably creates a new empty database somwhere else under ./res/db/, whatever it is.

Marving Jr

unread,
Jul 28, 2018, 2:59:19 PM7/28/18
to H2 Database


El sábado, 28 de julio de 2018, 20:44:54 (UTC+2), Andrei Tokar escribió:
Make sure your current directory on JVM startup is AppDatabase.
Connection is "Ok", because it probably creates a new empty database somwhere else under ./res/db/, whatever it is.

Hi Andrei
I am sorry. I apologize for my mistake. I did not want to waste your time
I just found the solution and at the same time I saw your answer .
You are right
I've created the database  in ~/Code/project/nb/AppDatabase/res/db/ENTERPRISE
and my netbeans project in ~/Code/projects/nb/AppDatabase/res/db/ENTERPRISE      --- projects--- with s
in netbeans project exist database ENTERPRISE but without table CUSTOMER
in ~/Code/project/nb/AppDatabase/res/db/ENTERPRISE exist DATABASE with table CUSTOMER.
Many hours in front of the computer. I need glasses. :)

Apologize again
Many Thanks Andrei
Regards


 

 

witerat

unread,
Jul 29, 2018, 8:03:20 PM7/29/18
to H2 Database
It is best practice to include ";IFEXISTS=true" in the url to avoid this sort of confusion and other problems.

Marving Jr

unread,
Jul 30, 2018, 5:26:16 AM7/30/18
to H2 Database
Ok witerat. 
Take note
Only open if it already existsjdbc:h2:<url>;IFEXISTS=TRUE
jdbc:h2:file:~/sample;IFEXISTS=TRUE

Thanks
Regards



Reply all
Reply to author
Forward
0 new messages