| | | | | | | | | | DescriptionBefore creating a new PostgreSQL database, please make sure that a PostgreSQL user has been added for use as the Database Administrator (DBA).
The possible values for encoding may be found in the postgres_encodings table. AOSH Commands
add_postgres_database database_name database_server server dba_username encoding
Simple API
/**
* Adds a PostgresDatabase to a Server
*
* @param aoClient the SimpleAOClient to use
* @param name the name of the database to add
* @param postgresServer the name of the PostgreSQL server
* @param server the hostname of the server to add the database to
* @param datdba the username of the database administrator PostgresUser
* @param encoding the encoding to use
*/
public static void addPostgresDatabase(
SimpleAOClient aoClient,
String name,
String postgresServer,
String server,
String datdba,
String encoding
) throws IOException, SQLException {
aoClient.addPostgresDatabase(name, postgresServer, server, datdba, encoding);
}
Full API
/**
* Adds a PostgresDatabase to a Server
*
* @param conn the AOServConnector to use
* @param name the name of the database to add
* @param postgresServer the name of the PostgreSQL server
* @param server the hostname of the server to add the database to
* @param datdba the username of the database administrator PostgresUser
* @param encoding the encoding to use
*
* @return the new PostgresDatabase
*/
public static PostgresDatabase addPostgresDatabase(
AOServConnector conn,
String name,
String postgresServer,
String server,
String datdba,
String encoding
) throws IOException, SQLException {
// Resolve the Server
Server se=conn.getServerTable().getServer(server);
// Resolve the PostgresServer
PostgresServer ps=se.getPostgresServer(postgresServer);
// Resolve the datdba PostgresServerUser
PostgresServerUser psu=ps.getPostgresServerUser(datdba);
// Resolve the PostgresEncoding
PostgresEncoding pe=ps.getPostgresVersion().getPostgresEncoding(conn, encoding);
// Add the PostgresDatabase
int pdPKey=ps.addPostgresDatabase(name, psu, pe);
// Return the object
return conn.getPostgresDatabaseTable().getPostgresDatabase(pdPKey);
}
| | | | | Copyright © 2000-2024 AO Industries, Inc. |
|