|
1 | 1 | { |
2 | 2 | "cells": [ |
| 3 | + { |
| 4 | + "metadata": {}, |
| 5 | + "cell_type": "markdown", |
| 6 | + "source": [ |
| 7 | + "### Custom SQL Database support\n", |
| 8 | + "\n", |
| 9 | + "Our JDBC-based SQL integration for DataFrame has become extensible!\n", |
| 10 | + "\n", |
| 11 | + "This means that if you have an SQL database that we currently don't support, you can\n", |
| 12 | + "create your own `DbType` instance and read from your database to a dataframe.\n", |
| 13 | + "\n", |
| 14 | + "Remember that we already support quite a few databases: MariaDB, PostgreSQL, MySQL, SQLite, MS SQL, and H2 (with dialects).\n", |
| 15 | + "\n", |
| 16 | + "To get started, we need a custom `DbType`.\n", |
| 17 | + "\n", |
| 18 | + "For the sake of example, we'll create a custom DbType based on the `HSQLDB` Database. Ordinarily, you'd extend `DbType(\"jdbc name of your database\")`." |
| 19 | + ] |
| 20 | + }, |
3 | 21 | { |
4 | 22 | "metadata": { |
5 | 23 | "ExecuteTime": { |
6 | | - "end_time": "2024-12-04T17:46:53.418314100Z", |
7 | | - "start_time": "2024-12-04T17:46:53.364458100Z" |
| 24 | + "end_time": "2025-07-22T13:49:18.414126600Z", |
| 25 | + "start_time": "2025-07-22T13:49:18.336050100Z" |
8 | 26 | } |
9 | 27 | }, |
10 | 28 | "cell_type": "code", |
|
22 | 40 | "import org.jetbrains.kotlinx.dataframe.examples.jdbc.customdb.*\n" |
23 | 41 | ], |
24 | 42 | "outputs": [], |
25 | | - "execution_count": 2 |
| 43 | + "execution_count": 5 |
26 | 44 | }, |
27 | 45 | { |
28 | 46 | "metadata": { |
29 | 47 | "ExecuteTime": { |
30 | | - "end_time": "2024-12-04T17:47:06.170038800Z", |
31 | | - "start_time": "2024-12-04T17:47:05.442284600Z" |
| 48 | + "end_time": "2025-07-22T13:48:19.970421Z", |
| 49 | + "start_time": "2025-07-22T13:48:19.744436800Z" |
32 | 50 | } |
33 | 51 | }, |
34 | 52 | "cell_type": "code", |
|
38 | 56 | "}" |
39 | 57 | ], |
40 | 58 | "outputs": [], |
41 | | - "execution_count": 3 |
| 59 | + "execution_count": 2 |
42 | 60 | }, |
43 | 61 | { |
44 | 62 | "metadata": { |
45 | 63 | "ExecuteTime": { |
46 | | - "end_time": "2024-12-04T17:47:07.681928Z", |
47 | | - "start_time": "2024-12-04T17:47:06.877080900Z" |
| 64 | + "end_time": "2025-07-22T13:49:25.151594800Z", |
| 65 | + "start_time": "2025-07-22T13:49:23.792372900Z" |
48 | 66 | } |
49 | 67 | }, |
50 | 68 | "cell_type": "code", |
|
53 | 71 | " createAndPopulateTable(con)\n", |
54 | 72 | "}" |
55 | 73 | ], |
56 | | - "outputs": [], |
57 | | - "execution_count": 4 |
| 74 | + "outputs": [ |
| 75 | + { |
| 76 | + "ename": "java.sql.SQLTransientConnectionException", |
| 77 | + "evalue": "java.net.ConnectException: Connection refused: connect", |
| 78 | + "output_type": "error", |
| 79 | + "traceback": [ |
| 80 | + "java.sql.SQLTransientConnectionException: java.net.ConnectException: Connection refused: connect", |
| 81 | + "\tat org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)", |
| 82 | + "\tat org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)", |
| 83 | + "\tat org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)", |
| 84 | + "\tat org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)", |
| 85 | + "\tat org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)", |
| 86 | + "\tat java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)", |
| 87 | + "\tat java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)", |
| 88 | + "\tat Line_15_jupyter.<init>(Line_15.jupyter.kts:1) at Cell In[6], line 1", |
| 89 | + "\tat java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)", |
| 90 | + "\tat java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)", |
| 91 | + "\tat java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)", |
| 92 | + "\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)", |
| 93 | + "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:122)", |
| 94 | + "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:48)", |
| 95 | + "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)", |
| 96 | + "\tat kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)", |
| 97 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:137)", |
| 98 | + "\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)", |
| 99 | + "\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)", |
| 100 | + "\tat kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)", |
| 101 | + "\tat kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)", |
| 102 | + "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)", |
| 103 | + "\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)", |
| 104 | + "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)", |
| 105 | + "\tat kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)", |
| 106 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:137)", |
| 107 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:80)", |
| 108 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:78)", |
| 109 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withHost(ReplForJupyterImpl.kt:779)", |
| 110 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute-L4Nmkdk(CellExecutorImpl.kt:78)", |
| 111 | + "\tat org.jetbrains.kotlinx.jupyter.repl.execution.CellExecutor$DefaultImpls.execute-L4Nmkdk$default(CellExecutor.kt:13)", |
| 112 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evaluateUserCode-wNURfNM(ReplForJupyterImpl.kt:601)", |
| 113 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evalExImpl(ReplForJupyterImpl.kt:459)", |
| 114 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.access$evalExImpl(ReplForJupyterImpl.kt:140)", |
| 115 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl$evalEx$1.invoke(ReplForJupyterImpl.kt:452)", |
| 116 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl$evalEx$1.invoke(ReplForJupyterImpl.kt:451)", |
| 117 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withEvalContext(ReplForJupyterImpl.kt:432)", |
| 118 | + "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evalEx(ReplForJupyterImpl.kt:451)", |
| 119 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:160)", |
| 120 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:159)", |
| 121 | + "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", |
| 122 | + "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", |
| 123 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedIn(IdeCompatibleMessageRequestProcessor.kt:355)", |
| 124 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.access$withForkedIn(IdeCompatibleMessageRequestProcessor.kt:55)", |
| 125 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$evalWithIO$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:369)", |
| 126 | + "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", |
| 127 | + "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", |
| 128 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedErr(IdeCompatibleMessageRequestProcessor.kt:344)", |
| 129 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.access$withForkedErr(IdeCompatibleMessageRequestProcessor.kt:55)", |
| 130 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$evalWithIO$1.invoke(IdeCompatibleMessageRequestProcessor.kt:368)", |
| 131 | + "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", |
| 132 | + "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", |
| 133 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedOut(IdeCompatibleMessageRequestProcessor.kt:336)", |
| 134 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.evalWithIO(IdeCompatibleMessageRequestProcessor.kt:367)", |
| 135 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1.invoke(IdeCompatibleMessageRequestProcessor.kt:159)", |
| 136 | + "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1.invoke(IdeCompatibleMessageRequestProcessor.kt:158)", |
| 137 | + "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$Task.execute(JupyterExecutorImpl.kt:41)", |
| 138 | + "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$executorThread$1.invoke(JupyterExecutorImpl.kt:83)", |
| 139 | + "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$executorThread$1.invoke(JupyterExecutorImpl.kt:80)", |
| 140 | + "\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)", |
| 141 | + "Caused by: org.hsqldb.HsqlException: java.net.ConnectException: Connection refused: connect", |
| 142 | + "\tat org.hsqldb.ClientConnection.openConnection(Unknown Source)", |
| 143 | + "\tat org.hsqldb.ClientConnection.initConnection(Unknown Source)", |
| 144 | + "\tat org.hsqldb.ClientConnection.<init>(Unknown Source)", |
| 145 | + "\t... 58 more", |
| 146 | + "Caused by: java.net.ConnectException: Connection refused: connect", |
| 147 | + "\tat java.base/java.net.PlainSocketImpl.connect0(Native Method)", |
| 148 | + "\tat java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101)", |
| 149 | + "\tat java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)", |
| 150 | + "\tat java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)", |
| 151 | + "\tat java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)", |
| 152 | + "\tat java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)", |
| 153 | + "\tat java.base/java.net.Socket.connect(Socket.java:609)", |
| 154 | + "\tat java.base/java.net.Socket.connect(Socket.java:558)", |
| 155 | + "\tat java.base/java.net.Socket.<init>(Socket.java:454)", |
| 156 | + "\tat java.base/java.net.Socket.<init>(Socket.java:231)", |
| 157 | + "\tat org.hsqldb.server.HsqlSocketFactory.createSocket(Unknown Source)", |
| 158 | + "\t... 61 more", |
| 159 | + "", |
| 160 | + "java.sql.SQLTransientConnectionException: java.net.ConnectException: Connection refused: connect", |
| 161 | + "at Cell In[6], line 1", |
| 162 | + "" |
| 163 | + ] |
| 164 | + } |
| 165 | + ], |
| 166 | + "execution_count": 6 |
58 | 167 | }, |
59 | 168 | { |
60 | 169 | "cell_type": "markdown", |
|
0 commit comments