At current JTDS will not connect to an instance of LocalDB, which is useful as lightweight user-mode database engine for development. At current no JDBC Driver supports LocalDB connections.
The reason it won't connect is the named pipe configuration prepends MSSQL$ to the instanceName and the NAMED_PIPE_PATH_SQLSERVER is "/sql/query".
The LocalDB named pipe URL is:
- np:\.\pipe\LOCALDB#331AB26D\tsql\query
which has the obvious difference of not starting with MSSQL like a fully-fledged SQL Server instance, and uses a slightly different ending (tsql instead of sql).
My Unified Diff is attached, as I've not heavily dug into JTDS I'm uncertain but I don't think the changes to SharedNamePipe would be necessary. This allows me to connect to LOCALDB, using the JDBC URL: jdbc:jtds:sqlserver://./[DBName];instance=LOCALDB#331AB26D;namedPipe=true
I've raised this ticket in the hopes it would make it into a release to be able to do this out of the box. Apologies if this should be somewhere else, please let me know.
I ran into this, too. There is a new release on GitHub.
Last edit: Christian Bläul 2018-03-18