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: README.md
+34-2
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,49 @@
4
4
5
5
This repository contains examples on how to connect to [MariaDB](https://mariadb.com) databases using a combination of different Java libraries and frameworks.
6
6
7
+
## Before you run the examples
8
+
9
+
1. Make sure you have a MariaDB Server ([Enterprise](https://mariadb.com/products/enterprise/) or [Community](https://mariadb.com/products/community-server/)) running. If you don't have a MariaDB server running, you can easily run one using [Docker](https://hub.docker.com/u/mariadb):
10
+
11
+
```Shell
12
+
docker run --name mariadb --detach --publish 3306:3306 --env MARIADB_ROOT_PASSWORD='RootPassword123!' mariadb
13
+
```
14
+
15
+
Alternatively, you can [Download](https://mariadb.com/downloads/) and install the server directly on your OS.
16
+
17
+
2. Connect to the database using [MariaDB Shell](https://mariadb.com/downloads/tools/shell/):
-[MariaDB Connector/J](https://mariadb.com/downloads/connectors/connectors-data-access/java8-connector) 3.2.0 or later
75
75
- An SQL client tool like [MariaDB Shell](https://mariadb.com/downloads/tools/), DBeaver, or an [SQL integration](https://www.youtube.com/watch?v=rJYUTxD-2-M) for your IDE
76
76
- MariaDB server ([Enterprise](https://mariadb.com/products/enterprise/) or [Community](https://mariadb.com/products/community-server/))
77
-
## Preparing the database
78
-
79
-
If you don't have a MariaDB server running, you can easily run using [Docker](https://hub.docker.com/u/mariadb):
80
-
81
-
```shell
82
-
docker run --name mariadb -d -p 3306:3306 -e MARIADB_ROOT_PASSWORD='RootPassword123!' mariadb
83
-
```
84
-
85
-
Alternatively, you can [Download](https://mariadb.com/downloads/) and install the server directly on your OS.
Alternatively, you can use any database client compatible with MariaDB.
94
-
95
-
Execute the following SQL statements to create a user for the JakartaEE application, a database (or schema) and a table:
96
-
97
-
```sql
98
-
CREATEDATABASEdemo;
99
-
CREATEUSER 'user'@'%' IDENTIFIED BY 'Password123!';
100
-
GRANTSELECT, INSERT, UPDATE, DELETE, DROP ON demo.* TO 'user'@'%';
78
+
## Preparing the database
101
79
102
-
USE demo;
103
-
CREATETABLEprogramming_language(
104
-
pl_id INTPRIMARY KEY AUTO_INCREMENT,
105
-
pl_name VARCHAR(50) NOT NULL UNIQUE,
106
-
pl_rating INT
107
-
);
108
-
```
80
+
See the instructions [here](../README.md).
109
81
110
82
## Configuring Glassfish
111
83
@@ -138,10 +110,6 @@ In the JDBC Connection Pool list, click on **MariaDB**, select the **Additional
138
110
***user**: `user`
139
111
***password**: `Password123!`
140
112
141
-
> If you are using [MariaDB SkySQL](https://mariadb.com/products/skysql/), enable SSL and specify the path to the CA chain file that you can download from the [SkySQL Portal](https://cloud.mariadb.com):
Go to **Resources > JDBC > JDBC Resources**. Click **New** and fill in the following details:
146
114
147
115
***JNDI Name**: `mariadb-database`
@@ -163,9 +131,9 @@ To deploy the WAR file to GlassFish using the Administration Console, go to **Ap
163
131
164
132
## Check the output
165
133
166
-
Go to **Monitoring Data > server** and click either the **View Log Files** or **View Raw Log** button. You should be able to see log messages confirming that data was deleted, created, and read. You can also connect to the database and see the data in the `programming_language` table.
134
+
Go to **Monitoring Data > server** and click either the **View Log Files** or **View Raw Log** button. You should be able to see log messages confirming that data was deleted, created, and read.
167
135
168
-
Connect to the database:
136
+
You can also connect to the database and see the data in the `programming_language` table:
> If you are using [MariaDB SkySQL](https://mariadb.com/products/skysql/), enable SSL and specify the path to the CA chain file that you can download from the [SkySQL Portal](https://cloud.mariadb.com):
Read the [tutorial](https://dzone.com/articles/jdbc-tutorial-part-2-running-sql-queries) or watch the video for detailed steps on how to implement this example from scratch:
Copy file name to clipboardExpand all lines: jdbc/part3/README.md
+20-24
Original file line number
Diff line number
Diff line change
@@ -23,10 +23,6 @@ dataSource.username=user
23
23
dataSource.password=Password123!
24
24
```
25
25
26
-
> If you are using [MariaDB SkySQL](https://mariadb.com/products/skysql/), enable SSL and specify the path to the CA chain file that you can download from the [SkySQL Portal](https://cloud.mariadb.com):
0 commit comments