My 1st JDBC and PostgreSQL

Поиск
Список
Период
Сортировка
От Amn Ojee Uw
Тема My 1st JDBC and PostgreSQL
Дата
Msg-id b7689ed5-773b-03ad-5f8c-5f18c97bafc3@gmail.com
обсуждение исходный текст
Ответы Re: My 1st JDBC and PostgreSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: My 1st JDBC and PostgreSQL  (Chuck Davis <cjgunzel@gmail.com>)
Re: My 1st JDBC and PostgreSQL  (Jeffrey Walton <noloader@gmail.com>)
Re: My 1st JDBC and PostgreSQL  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Following the example in :
https://www.tutorialspoint.com/postgresql/postgresql_java.htm
I wrote the bellow method :

public void connectToDatabase() throws ClassNotFoundException, 
SQLException {
         try {
             this.perr(this.getDatabaseClass()); // 
org.postgresql.Driver = Class
             this.perr(this.getDatabaseUrl());   // 
jdbc:postgresql://localhost:5432/sara.pgdb = url
             this.perr(this.getUserID());        // chispa = user
             this.perr(this.getUserPassword());  // 8UUKZW = password

             Class.forName(this.getDatabaseClass().toString());
             conn = 
DriverManager.getConnection(this.getDatabaseUrl().toString(),
                     this.getUserID().toString(),
                     this.getUserPassword().toString() );
         } catch (final SQLException | ClassNotFoundException e) {
             throw e;
         }
     }

However, it throws an exception that reads :
Exception in thread "main" org.postgresql.util.PSQLException: FATAL: 
database "sara.pgdb" does not exist

In reference to the above web page, it reads :
The following Java code shows how to connect to an existing database. If 
the database does not exist, then it will be created and finally a 
database object will be returned.

True, the database file does not exist, but isn't JDBC supposed to 
create it?


Any help would be much appreciated.




В списке pgsql-general по дате отправления:

Предыдущее
От: Amn Ojee Uw
Дата:
Сообщение: Nu-B here
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Nu-B here