You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/configure-language-java-data-sources.md
+5-85Lines changed: 5 additions & 85 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,98 +386,18 @@ There are three core steps when [registering a data source with JBoss EAP](https
386
386
1. Add the JDBC driver as a module.
387
387
1. Add a data source with the module.
388
388
389
-
App Service is a stateless hosting service, so you must put these steps into a startup script and run it each time the JBoss container starts. Using PostgreSQL as an example:
389
+
App Service is a stateless hosting service, so you must put these steps into a startup script and run it each time the JBoss container starts. Using PostgreSQL and MySQL as an examples:
390
390
391
-
1. Create an XML module definition file for the JDBC driver. The following example shows a module definition for PostgreSQL called *postgresql-module.xml*.
1. Put your JBoss CLI commands into a file named *jboss-cli-commands.cli*. The JBoss commands must add the module and register it as a data source. The following example shows the JBoss CLI commands for creating a PostgreSQL data source with the JNDI name `java:jboss/datasources/postgresDS`.
Note that the `module add` command uses three environment variables (`DB_HOST`, `DB_USERNAME`, and `DB_PASSWORD`), which you must add in App Service as app settings.
417
-
418
-
1. Create a startup script, *startup.sh*, that calls the JBoss CLI commands. The following example shows how to call your `jboss-cli-commands.cli`. Later, you'll configure App Service to run this script when the container starts.
1. Using a deployment option of your choice, upload your JDBC driver, *postgresql-module.xml*, *jboss-cli-commands.cli*, and *startup.sh* to the paths specified in the respective scripts. Especially, upload *startup.sh* as a startup file. For example:
395
+
# [MySQL](#tab/jboss_mysql)
425
396
426
-
# [Azure CLI](#tab/cli)
427
-
428
-
```azurecli-interactive
429
-
export RESOURCE_GROUP_NAME=<resource-group-name>
430
-
export APP_NAME=<app-name>
431
-
432
-
# The lib type uploads to /home/site/libs by default
To confirm that the datasource was added to the JBoss server, SSH into your webapp and run `$JBOSS_HOME/bin/jboss-cli.sh --connect`. Once you're connected to JBoss, run the `/subsystem=datasources:read-resource` to print a list of the data sources.
1. Put your JBoss CLI commands into a file named *jboss-cli-commands.cli*. The JBoss commands must add the module and register it as a data source. The following example shows the JBoss CLI commands for creating a MySQL data source with the JNDI name `java:jboss/datasources/mysqlDS`.
Note that the `module add`command uses three environment variables (`DB_HOST`, `DB_USERNAME`, and `DB_PASSWORD`), which you must add in App Service as app settings. The script adds them without the `--resolve-parameter-values` flag so that JBoss doesn't save their values in plaintext.
20
+
21
+
1. Create a startup script, *startup.sh*, that calls the JBoss CLI commands. The following example shows how to call your `jboss-cli-commands.cli`. Later, you'll configure App Service to run this script when the container starts.
1. Using a deployment option of your choice, upload your JDBC driver, *jboss-cli-commands.cli*, and *startup.sh* to the paths specified in the respective scripts. Especially, upload *startup.sh* as a startup file. For example:
28
+
29
+
# [Azure CLI](#tab/cli)
30
+
31
+
```azurecli-interactive
32
+
export RESOURCE_GROUP_NAME=<resource-group-name>
33
+
export APP_NAME=<app-name>
34
+
35
+
# The lib type uploads to /home/site/libs by default
For more information, see [Deploy files to App Service](deploy-zip.md).
43
+
44
+
# [Azure Maven Plugin](#tab/maven)
45
+
46
+
```xml
47
+
<deployment>
48
+
<resources>
49
+
<resource>
50
+
<!-- The lib type uploads to /home/site/libs by default. -->
51
+
<type>lib</type>
52
+
<directory>${project.build.directory}/${project.artifactId}/META-INF/lib</directory><!-- Assume driver is part of POM dependencies. -->
53
+
<includes>
54
+
<include>mysql-connector-j-9.1.0.jar</include>
55
+
</includes>
56
+
</resource>
57
+
<resource>
58
+
<!-- The script type uploads to /home/site/scripts by default. -->
59
+
<type>script</type>
60
+
<directory>${project.scriptSourceDirectory}</directory><!-- scriptSourceDirectory is src/main/scripts by default. -->
61
+
<includes>
62
+
<include>jboss_cli_commands.cli</include>
63
+
</includes>
64
+
</resource>
65
+
<resource>
66
+
<!-- The startup type uploads to /home/site/scripts/startup.sh by default -->
67
+
<type>startup</type>
68
+
<directory>${project.scriptSourceDirectory}</directory><!-- scriptSourceDirectory is src/main/scripts by default. -->
69
+
<includes>
70
+
<include>startup.sh</include>
71
+
</includes>
72
+
</resource>
73
+
...
74
+
</resources>
75
+
</deployment>
76
+
```
77
+
78
+
---
79
+
80
+
To confirm that the datasource was added to the JBoss server, SSH into your webapp and run `$JBOSS_HOME/bin/jboss-cli.sh --connect`. Once you're connected to JBoss, run the `/subsystem=datasources:read-resource` to print a list of the data sources.
81
+
82
+
As defined by *jboss-cli-commands.cli* previously, you can access the MySQL connection using the JNDI name `java:jboss/datasources/mysqlDS`.
1. Put your JBoss CLI commands into a file named *jboss-cli-commands.cli*. The JBoss commands must add the module and register it as a data source. The following example shows the JBoss CLI commands for creating a PostgreSQL data source with the JNDI name `java:jboss/datasources/postgresDS`.
Note that the `module add`command uses three environment variables (`DB_HOST`, `DB_USERNAME`, and `DB_PASSWORD`), which you must add in App Service as app settings. The script adds them without the `--resolve-parameter-values` flag so that JBoss doesn't save their values in plaintext.
20
+
21
+
1. Create a startup script, *startup.sh*, that calls the JBoss CLI commands. The following example shows how to call your `jboss-cli-commands.cli`. Later, you'll configure App Service to run this script when the container starts.
1. Using a deployment option of your choice, upload your JDBC driver, *jboss-cli-commands.cli*, and *startup.sh* to the paths specified in the respective scripts. Especially, upload *startup.sh* as a startup file. For example:
28
+
29
+
# [Azure CLI](#tab/cli)
30
+
31
+
```azurecli-interactive
32
+
export RESOURCE_GROUP_NAME=<resource-group-name>
33
+
export APP_NAME=<app-name>
34
+
35
+
# The lib type uploads to /home/site/libs by default
For more information, see [Deploy files to App Service](deploy-zip.md).
43
+
44
+
# [Azure Maven Plugin](#tab/maven)
45
+
46
+
```xml
47
+
<deployment>
48
+
<resources>
49
+
<resource>
50
+
<!-- The lib type uploads to /home/site/libs by default. -->
51
+
<type>lib</type>
52
+
<directory>${project.build.directory}/${project.artifactId}/META-INF/lib</directory><!-- Assume driver is part of POM dependencies. -->
53
+
<includes>
54
+
<include>postgresql-42.7.1.jar</include>
55
+
</includes>
56
+
</resource>
57
+
<resource>
58
+
<!-- The script type uploads to /home/site/scripts by default. -->
59
+
<type>script</type>
60
+
<directory>${project.scriptSourceDirectory}</directory><!-- scriptSourceDirectory is src/main/scripts by default. -->
61
+
<includes>
62
+
<include>jboss_cli_commands.cli</include>
63
+
</includes>
64
+
</resource>
65
+
<resource>
66
+
<!-- The startup type uploads to /home/site/scripts by default. -->
67
+
<type>startup</type>
68
+
<directory>${project.scriptSourceDirectory}</directory><!-- scriptSourceDirectory is src/main/scripts by default. -->
69
+
<includes>
70
+
<include>startup.sh</include>
71
+
</includes>
72
+
</resource>
73
+
...
74
+
</resources>
75
+
</deployment>
76
+
```
77
+
78
+
---
79
+
80
+
To confirm that the datasource was added to the JBoss server, SSH into your webapp and run `$JBOSS_HOME/bin/jboss-cli.sh --connect`. Once you're connected to JBoss, run the `/subsystem=datasources:read-resource` to print a list of the data sources.
81
+
82
+
As defined by *jboss-cli-commands.cli* previously, you can access the PostgreSQL connection using the JNDI name `java:jboss/datasources/postgresDS`.
0 commit comments