ADD RESOURCE

Description

The ADD RESOURCE syntax is used to add resources for the currently selected database.

Syntax

  1. AddResource ::=
  2. 'ADD' 'RESOURCE' resourceDefinition (',' resourceDefinition)*
  3. resourceDefinition ::=
  4. resourceName '(' ( 'HOST' '=' hostName ',' 'PORT' '=' port ',' 'DB' '=' dbName | 'URL' '=' url ) ',' 'USER' '=' user (',' 'PASSWORD' '=' password )? (',' proerties)?')'
  5. resourceName ::=
  6. identifier
  7. hostname ::=
  8. string
  9. port ::=
  10. int
  11. dbName ::=
  12. string
  13. url ::=
  14. string
  15. user ::=
  16. string
  17. password ::=
  18. string
  19. proerties ::=
  20. PROPERTIES '(' property ( ',' property )* ')'
  21. property ::=
  22. key '=' value
  23. key ::=
  24. string
  25. value ::=
  26. string

Supplement

  • Before adding resources, please confirm that a database has been created in Proxy, and execute the use command to successfully select a database;
  • Confirm that the added resource can be connected normally, otherwise it will not be added successfully;
  • resourceName is case-sensitive;
  • resourceName needs to be unique within the current database;
  • resourceName name only allows letters, numbers and _, and must start with a letter;
  • poolProperty is used to customize connection pool parameters, key must be the same as the connection pool parameter name, value supports int and String types;
  • When password contains special characters, it is recommended to use the string form; For example, the string form of password@123 is "password@123".

Example

  • Add resource using standard mode
  1. ADD RESOURCE ds_0 (
  2. HOST=127.0.0.1,
  3. PORT=3306,
  4. DB=db_0,
  5. USER=root,
  6. PASSWORD=root
  7. );
  • Add resource and set connection pool parameters using standard mode
  1. ADD RESOURCE ds_1 (
  2. HOST=127.0.0.1,
  3. PORT=3306,
  4. DB=db_1,
  5. USER=root,
  6. PASSWORD=root,
  7. PROPERTIES("maximumPoolSize"=10)
  8. );
  • Add resource and set connection pool parameters using URL patterns
  1. ADD RESOURCE ds_2 (
  2. URL="jdbc:mysql://127.0.0.1:3306/db_2?serverTimezone=UTC&useSSL=false",
  3. USER=root,
  4. PASSWORD=root,
  5. PROPERTIES("maximumPoolSize"=10,"idleTimeout"="30000")
  6. );

Reserved word

ADD, RESOURCE, HOST, PORT, DB, USER, PASSWORD, PROPERTIES, URL