Re: My 1st JDBC and PostgreSQL - Mailing list pgsql-general

From Tom Lane
Subject Re: My 1st JDBC and PostgreSQL
Date
Msg-id 466555.1689814728@sss.pgh.pa.us
Whole thread Raw
In response to My 1st JDBC and PostgreSQL  (Amn Ojee Uw <amnojeeuw@gmail.com>)
List pgsql-general
Amn Ojee Uw <amnojeeuw@gmail.com> writes:
> https://www.tutorialspoint.com/postgresql/postgresql_java.htm
> 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?

I think that web page is lying to you.  JDBC cannot promise to
create a database for you, because (a) if the given database
doesn't exist, it would have to guess at some other database
to connect to, with no certainty of success; and (b) even if
it manages to connect to the server, there's no certainty
that you'd have permissions to create a new database.
So I don't believe any JDBC driver would even try.

            regards, tom lane



pgsql-general by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: Nu-B here
Next
From: Chuck Davis
Date:
Subject: Re: My 1st JDBC and PostgreSQL