-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
395 lines (349 loc) · 16.6 KB
/
index.html
File metadata and controls
395 lines (349 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.23">
<meta name="description" content="The modular micro web framework for Java">
<meta name="keywords" content="Java, Modern, Micro, Web, Framework, Reactive, Lightweight, Microservices">
<link rel="icon" type="image/png" href="../../images/favicon96.png">
<title>jooby: vertx pg client module</title>
<link rel="stylesheet" href="../../js/styles/theme.css">
<link rel="stylesheet" href="../../js/styles/atom-one-dark.min.css">
<meta name="algolia-site-verification" content="B92EF92B303805F4">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<script>
// This MUST be in the <head>. It runs before the body is rendered, preventing the white flash.
(function() {
const savedTheme = localStorage.getItem('jooby-theme');
if (savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.setAttribute('data-theme', 'dark');
}
})();
</script>
</head>
<body class="book toc2 toc-left">
<div class="mobile-nav-bar">
<span style="font-weight: 700; color: var(--heading-color);">Jooby</span>
<button id="menu-toggle" class="hamburger" aria-label="Toggle Menu">
<span></span><span></span><span></span>
</button>
</div>
<div id="header">
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#sql-client">Sql Client</a>
<ul class="sectlevel2">
<li><a href="#sql-client-postgres">Postgres</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div class="sect1">
<h2 id="sql-client"><a class="anchor" href="#sql-client"></a><a class="link" href="#sql-client">Sql Client</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>A <a href="https://github.com/eclipse-vertx/vertx-sql-client" target="_blank">reactive SQL Client</a>. Supported databases:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>PostgreSQL</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These modules require a Vertx instance available in the service registry.</p>
</div>
<div class="sect2">
<h3 id="sql-client-postgres"><a class="anchor" href="#sql-client-postgres"></a><a class="link" href="#sql-client-postgres">Postgres</a></h3>
<div class="paragraph">
<p>1) Add the dependency:</p>
</div>
<div class="listingblock primary">
<div class="switch"><div class="switch--item option-1 selected">Maven</div><div class="switch--item option-2">Gradle</div></div><div class="content option-1">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml" id="x5aa9578940a9447c"><!-- Vertx Module-->
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby-vertx</artifactId>
<version>4.4.0</version>
</dependency>
<!-- Postgres Client-->
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby-vertx-pg-client</artifactId>
<version>4.4.0</version>
</dependency></code><button class="clipboard" data-clipboard-target="#x5aa9578940a9447c"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div><div class="content hidden option-2">
<pre class="highlightjs highlight"><code class="language-gradle hljs" data-lang="gradle" id="xcc61e8b9e5e84694">// Vertx Module
implementation 'io.jooby:jooby-vertx:4.4.0'
// Postgres Client
implementation 'io.jooby:jooby-vertx-pg-client:4.4.0'</code><button class="clipboard" data-clipboard-target="#xcc61e8b9e5e84694"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div></div>
<div class="paragraph">
<p>2) Define connection string or key/value pairs details:</p>
</div>
<div class="listingblock">
<div class="title">application.conf</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-properties hljs" data-lang="properties" id="x156e360c09aa48cb">db = Postgres//dbuser:secretpassword@localhost:{{port}}/mydb</code><button class="clipboard" data-clipboard-target="#x156e360c09aa48cb"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div>
</div>
<div class="listingblock">
<div class="title">application.conf</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-properties hljs" data-lang="properties" id="x9e8ab6a2081a4cef">db.host = localhost
db.port = {{port}}
db.database = mydb
db.user = dbuser
db.password = secretpassword</code><button class="clipboard" data-clipboard-target="#x9e8ab6a2081a4cef"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div>
</div>
<div class="paragraph">
<p>3) Install</p>
</div>
<div class="listingblock primary">
<div class="switch"><div class="switch--item option-1 selected">Java</div><div class="switch--item option-2">Kotlin</div></div><div class="content option-1">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java" id="x61d3cd925080466f">import io.jooby.vertx.VertxModule;
import io.jooby.vertx.VertxPgModule;
import static io.jooby.vertx.VertxHandler.vertx;
{
install(new VertxModule()); <b class="conum">(1)</b>
install(new VertxPgModule()); <b class="conum">(2)</b>
use(vertx()); <b class="conum">(3)</b>
get("/{id}", ctx -> {
var db = require(SqlClient.class); <b class="conum">(4)</b>
return db.preparedQuery("SELECT id, name from World where id=$1") <b class="conum">(5)</b>
.execute(Tuple.of(ctx.path("id").longValue()))
.map(result -> {
var row = result.iterator().next();
return new World(row.getInteger(0), row.getInteger(1));
});
});
}</code><button class="clipboard" data-clipboard-target="#x61d3cd925080466f"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div><div class="content hidden option-2">
<pre class="highlightjs highlight"><code class="language-kt hljs" data-lang="kt" id="xf5d23a6a6f6d48d0">import io.jooby.vertx.VertxModule
import io.jooby.vertx.VertxPgModule
import static io.jooby.vertx.VertxHandler.vertx
{
install(VertxModule()) <b class="conum">(1)</b>
install(VertxPgModule()); <b class="conum">(2)</b>
use(vertx()) <b class="conum">(3)</b>
get("/{id}") {
val db = require(SqlClient::class) <b class="conum">(4)</b>
db.preparedQuery("SELECT id, name from World where id=$1") <b class="conum">(5)</b>
.execute(Tuple.of(ctx.path("id").longValue()))
.map({ result ->
val row = result.iterator().next()
World(row.getInteger(0), row.getInteger(1))
})
}
}</code><button class="clipboard" data-clipboard-target="#xf5d23a6a6f6d48d0"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div></div>
<div class="colist arabic">
<ol>
<li>
<p>Install Vertx</p>
</li>
<li>
<p>Install Sql Client: {{sqlClient}</p>
</li>
<li>
<p>Install vertx handler. Render future, promise and buffer</p>
</li>
<li>
<p>Get SQL client instance</p>
</li>
<li>
<p>Run a database query</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>To use the client version of the driver:</p>
</div>
<div class="listingblock">
<div class="title">Client</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java" id="x2f1925af1c5d4c98">{
...
install(new VertxPgModule(PgBuilder::client));
...
}</code><button class="clipboard" data-clipboard-target="#x2f1925af1c5d4c98"><img src="/../../images/clippy.svg" class="clippy" width="13" alt="Copy to clipboard"></button></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../../js/highlight.min.js"></script>
<script>
if (!hljs.initHighlighting.called) {
hljs.configure({ignoreUnescapedHTML: true});hljs.initHighlighting.called = true
;[].slice.call(document.querySelectorAll('pre.highlight > code[data-lang]')).forEach(function (el) { hljs.highlightElement(el) })
}
</script>
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle Dark Mode">
<svg class="sun-icon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18.75a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75zM6.166 18.894a.75.75 0 01-1.06-1.06l1.59-1.591a.75.75 0 111.061 1.06l-1.59 1.591zM2.25 12a.75.75 0 01.75-.75h2.25a.75.75 0 010 1.5H3a.75.75 0 01-.75-.75zM5.106 6.166a.75.75 0 011.06-1.06l1.591 1.59a.75.75 0 11-1.06 1.061l-1.591-1.59z" /></svg>
<svg class="moon-icon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path fill-rule="evenodd" d="M9.528 1.718a.75.75 0 01.162.819A8.97 8.97 0 009 6a9 9 0 009 9 8.97 8.97 0 003.463-.69.75.75 0 01.981.98 10.503 10.503 0 01-9.694 6.46c-5.799 0-10.5-4.701-10.5-10.5 0-4.368 2.667-8.112 6.46-9.694a.75.75 0 01.818.162z" clip-rule="evenodd" /></svg>
</button>
<script src="/../../js/clipboard.min.js"></script>
<script src="/../../js/toc.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
/** 1. Theme Switcher Logic */
const themeToggle = document.getElementById('theme-toggle');
const htmlElement = document.documentElement;
const hljsThemeLink = document.getElementById('hljs-theme'); // Grab the CSS link
if (themeToggle) {
themeToggle.addEventListener('click', () => {
if (htmlElement.getAttribute('data-theme') === 'dark') {
// Switch to Light Mode
htmlElement.removeAttribute('data-theme');
localStorage.setItem('jooby-theme', 'light');
// Switch code block to Agate
if (hljsThemeLink) hljsThemeLink.href = '../../js/styles/agate.min.css';
} else {
// Switch to Dark Mode
htmlElement.setAttribute('data-theme', 'dark');
localStorage.setItem('jooby-theme', 'dark');
// Switch code block to Atom One Dark
if (hljsThemeLink) hljsThemeLink.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.../../js/11.9.0/styles/atom-one-dark.min.css';
}
});
}
/** 2. Tabs Logic */
const tabButtons = document.querySelectorAll('.primary .switch .switch--item');
const contents = document.querySelectorAll('.primary .content');
tabButtons.forEach(button => {
button.addEventListener('click', function () {
const match = this.className.match(/option-(\d+)/);
if (!match) return;
const option = match[1];
// Reset states
tabButtons.forEach(btn => btn.classList.remove('selected'));
contents.forEach(content => content.classList.add('hidden'));
// Set active states
document.querySelectorAll(`.primary .switch .switch--item.option-${option}`)
.forEach(el => el.classList.add('selected'));
document.querySelectorAll(`.primary .content.option-${option}`)
.forEach(el => el.classList.remove('hidden'));
});
});
/** 3. Clipboard.js Initialization */
const clipboard = new ClipboardJS('.clipboard');
clipboard.on('success', (e) => {
e.clearSelection();
const btn = e.trigger;
const originalHTML = btn.innerHTML;
// Temporarily change background and insert a checkmark SVG
btn.style.backgroundColor = '#10b981'; // Tailwind emerald-500
btn.style.borderColor = '#059669';
btn.innerHTML = `<svg fill="none" stroke="white" stroke-width="2.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg>`;
// Revert back after 2 seconds
setTimeout(() => {
btn.style.backgroundColor = '';
btn.style.borderColor = '';
btn.innerHTML = originalHTML;
}, 2000);
});
});
/** 4. Code Callout Badges (Zero-Flash & Auto-Format) */
document.querySelectorAll('pre.highlightjs').forEach(pre => {
// Check every 10ms if highlight.js has finished formatting this block
const checkInterval = setInterval(() => {
if (pre.dataset.highlighted === "yes" || pre.querySelector('.hljs')) {
clearInterval(checkInterval);
const codeEl = pre.querySelector('code');
if (codeEl) {
// Upgraded regex to handle consecutive callouts like: // (1) (2)
// The "Lookahead" (?= ... ) now checks if the rest of the line
// is empty OR contains subsequent (N) callout numbers.
const calloutRegex = /(\/\/\s*|\s+)\(\s*(?:<[^>]+>\s*)*(\d+)\s*(?:<[^>]+>\s*)*\)(?=\s*(?:<[^>]+>\s*)*(?:\(\s*(?:<[^>]+>\s*)*\d+\s*(?:<[^>]+>\s*)*\)\s*(?:<[^>]+>\s*)*)*(\n|<|$))/g;
codeEl.innerHTML = codeEl.innerHTML.replace(
calloutRegex,
(match, prefix, num) => {
// Injects a hidden "//" before EVERY badge so that
// multiple badges paste safely as "// 1 // 2"
return ` <span class="visually-hidden">//</span> <span class="conum-badge">${num}</span>`;
}
);
}
// Reveal the block smoothly
pre.classList.add('badges-loaded');
}
}, 10);
// Fallback: Reveal the block anyway after 500ms
setTimeout(() => {
pre.classList.add('badges-loaded');
clearInterval(checkInterval);
}, 500);
});
/** 5. Copy Header Anchor Links to Clipboard */
document.querySelectorAll('a.anchor').forEach(anchor => {
anchor.addEventListener('click', function(e) {
// We do NOT prevent default, so the browser still scrolls to the header naturally
// Construct the full absolute URL for the clipboard
const fullUrl = window.location.origin + window.location.pathname + window.location.search + this.getAttribute('href');
// Use native clipboard API
navigator.clipboard.writeText(fullUrl).then(() => {
// Add the 'copied' class for visual feedback
this.classList.add('copied');
// Remove the checkmark after 2 seconds
setTimeout(() => {
this.classList.remove('copied');
}, 2000);
}).catch(err => console.error('Failed to copy anchor:', err));
});
});
/** 6. Hamburger Menu */
document.addEventListener('DOMContentLoaded', function() {
const menuToggle = document.getElementById('menu-toggle');
// Try to find the Toc (Table of Contents) or the Navigation Container
const sidebar = document.getElementById('toc') ||
document.querySelector('.nav-container') ||
document.getElementById('sidebar');
if (menuToggle && sidebar) {
menuToggle.addEventListener('click', function() {
sidebar.classList.toggle('active');
menuToggle.classList.toggle('open');
// Optional: Prevent body scrolling when menu is open
document.body.classList.toggle('menu-open');
});
} else {
console.warn("Hamburger menu: Could not find the navigation element to toggle.");
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// 1. Find Asciidoctor's auto-generated TOC
const toc = document.getElementById('toc');
if (toc) {
// 2. Create the search container dynamically
const searchContainer = document.createElement('div');
searchContainer.id = 'docsearch';
// 3. Inject it at the very top of the TOC, above the title
toc.insertBefore(searchContainer, toc.firstChild);
// 4. Initialize Algolia into that new container
docsearch({
appId: '9U2WK2CSJ7',
apiKey: '113e159f5c587fdac629948dd80dd993',
indexName: 'jooby',
container: '#docsearch'
});
} else {
console.warn("Could not find the #toc element to inject the search bar.");
}
});
</script>
</body>
</html>