Is it possible to connect to a SQL Server LocalDB using JDBC? It appears that (as of Dec 2011) it was not possible.
Do you know of a workaround or change in status?
Is it possible to connect to a SQL Server LocalDB using JDBC? It appears that (as of Dec 2011) it was not possible.
Do you know of a workaround or change in status?
Is it possible to connect to a SQL Server LocalDB using JDBC?
Not with Microsoft's JDBC Driver.
The jTDS JDBC driver supports named pipes.
Executing SqlLocalDB.exe info MyInstance will get you (along with other info) the instance pipe name such as "np:\.\pipe\LOCALDB#F365A78E\tsql\query".
Do you know of a workaround or change in status?
Possible workarounds are using alternative JDBC drivers or switching to SQL Server 2012 Express instead of LocalDB.
Details:
The Microsoft JDBC Driver is not compatible with LocalDB.
"Unfortunately, the Microsoft JDBC Driver does not support connecting to LocalDB. This happens because LocalDB only supports Named Pipes connections and our current JDBC implementation does not support Named Pipes. One possible work around for your developers is to download and install SQL Express, which and enable its TCP/IP support."
Luiz Fernando Santos (MSFT) July 06, 2012
"Unfortunately JDBC driver doesn't support LocalDB at this moment and there is no easy workaround. The team is aware of this missing feature, but filing a connect item is always helpful for DCR tracking and prioritization."
Krzysztof Kozielczyk - MSFT 22 Dec 2011
"Do you use SQL Server Express today for local development? Are you working on Windows or another platform? It would be great to hear more about how you would like to use LocalDB with your Java app."
Yes, it is possible.
The connection string for a LocalDB instance using jTDS looks like this:
jdbc:jtds:sqlserver://./DatabaseName;instance=LOCALDB#88893A09;namedPipe=true
This works as of jTDS 1.3.2. You can download a release here:
https://github.com/milesibastos/jTDS/releases/download/v1.3.2/jtds-1.3.2-dist.zip
To find the named pipe for your desired LocalDB, run
SqlLocalDb info NameOfTheLocalDBInstance
which will give you something like np:\\.\pipe\LOCALDB#88893A09\tsql\query
It's probably best to connect with a specific username/password, so create a login and user for your database in that LocalDB instance as well (if you haven't already):
sqlcmd -S np:\\.\pipe\LOCALDB#88893A09\tsql\query
CREATE LOGIN dbuser WITH PASSWORD = 'dbpassword'
GO
CREATE USER dbuser
GO
ALTER AUTHORIZATION ON DATABASE::DatabaseName TO dbuser
GO
Is it possible to connect to a SQL Server LocalDB using JDBC?
Not with Microsoft's JDBC Driver.
The jTDS JDBC driver supports named pipes.
Executing SqlLocalDB.exe info MyInstance will get you (along with other info) the instance pipe name such as "np:\.\pipe\LOCALDB#F365A78E\tsql\query".
Do you know of a workaround or change in status?
Possible workarounds are using alternative JDBC drivers or switching to SQL Server 2012 Express instead of LocalDB.
Details:
The Microsoft JDBC Driver is not compatible with LocalDB.
"Unfortunately, the Microsoft JDBC Driver does not support connecting to LocalDB. This happens because LocalDB only supports Named Pipes connections and our current JDBC implementation does not support Named Pipes. One possible work around for your developers is to download and install SQL Express, which and enable its TCP/IP support."
Luiz Fernando Santos (MSFT) July 06, 2012
"Unfortunately JDBC driver doesn't support LocalDB at this moment and there is no easy workaround. The team is aware of this missing feature, but filing a connect item is always helpful for DCR tracking and prioritization."
Krzysztof Kozielczyk - MSFT 22 Dec 2011
"Do you use SQL Server Express today for local development? Are you working on Windows or another platform? It would be great to hear more about how you would like to use LocalDB with your Java app."
I did my research today to setup connection using jTDS and named pipes.
The state at today is: IMPOSSIBLE! There is not possible to build connect string to localDB using jTDS due to its pipe name limitations. See open issue here: http://sourceforge.net/p/jtds/bugs/716/
As mentioned localDB does not supports other connection but namedPipes, so it looks like mission impossible so far...
rgds
Edit: As mentioned in comment there is patch in issue linked above and you can use this to fix the problem. Sorry I can not check this for myself.
To Know LocalDb & Instance :
© 2022 - 2024 — McMap. All rights reserved.