babashka / babashka-sql-pods

Babashka pods for SQL databases
Eclipse Public License 1.0
85 stars 17 forks source link

add minimal support for mysql unix domain sockets. #54

Open mknoszlig opened 2 years ago

mknoszlig commented 2 years ago

This is a minimal request for comments implementation for #53

i've tested so far using the following code (using a vanilla mysql install):

(ns pod.babashka.test
  (:require [next.jdbc :as jdbc])
  (:gen-class))

(def uri "jdbc:mysql:///mysql?user=root&socketFactory=pod.babashka.mysql.UnixSocketFactory")
(defn get-connection [db-spec]
  (jdbc/get-connection {:jdbcUrl db-spec
                        "pod.babashka.mysql.file" "/tmp/mysql.sock"}))

(defn -main []
  (try
    (with-open [c (get-connection uri)]
      (println (jdbc/execute! c ["select version();"])))
    (catch Throwable t
      (.printStackTrace t))))
> POD_DB_TYPE=mysql lein do compile, clean, with-profiles +feature/mysql run -m pod.babashka.test
Compiling 2 source files to /Users/mknoszlig/work/babashka-sql-pods/target/classes
connecting to socket:/tmp/mysql.sock
class: Socket[addr=null,port=0,localport=0]
[{:version() 8.0.28}]

Is there anything I need to consider for the native build (aside from using the correct graalvm version)? Will the java classes get picked up correctly?

mknoszlig commented 2 years ago

Note: build uses the older graalvm version

curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/graalvm-ce-java11-linux-amd64-21.3.0.tar.gz
borkdude commented 2 years ago

Don't know. You can try this locally first with GraalVM 17?

borkdude commented 2 years ago

Also, upgrade to 22.0.0.2 while you're at it :)

mknoszlig commented 2 years ago

classes appear to get picked up correctly, I'm still tracking a NPE that I'm just seeing running on GraalVM but not when running on JVM as described above. will also update generate_circleci.clj to 22.0.0.2.