With JDBC, a database is represented by a URL (Uniform Resource Locator). With Postgres, this takes one of the following forms:
JDBC を使用する場合、データベースは URL(Uniform Resource Locator)で表されます。Postgres では、これは下の形式のどれか1つになります。
jdbc:postgresql:database
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database
The hostname of the server. Defaults to "localhost".
サーバのホスト名。デフォルトは "localhost" です。
The port number the server is listening on. Defaults to the Postgres standard port number (5432).
サーバが監視しているポート番号。デフォルトは Postgres の標準的な ポート番号(5432)です。
The database name.
データベース名。
To connect, you need to get a Connection instance from JDBC. To do this, you would use the DriverManager.getConnection() method:
接続するために、JDBC から Connection インスタ ンスを入手します。これには、下のように DriverManager.getConnection() メソッドを使います。
Connection db = DriverManager.getConnection(url,user,pwd);