Organizational Research By

Surprising Reserch Topic

connect to sql server localdb jdbc


connect to sql server localdb jdbc  using -'I,installed,Microsoft,SQL,Server,2012,Express,localdb,on,my,system.

After,I,created,(and,started),a,Instance,(Test),with,an,database,(db1),I,tried,to,connect,with,my,java-Applikation.

The,driver,ist,"com.microsoft.sqlserver.jdbc.SQLServerDriver".

My,connection-string,is,"jdbc:sqlserver://(localdb)\Test;databaseName=db1;schema=db1;"

Error,(truncated):
java.net.UnknownHostException:,'(localdb)',named,instance,'Test',
Check,UDP,Port,1434
Check,if,SQL,Server,browser-Service,is,started

My,.NET,Framework,Version,is,4.0.2

'SQLCMD.EXE,-S(localdb)\Test',works,fine.

asked Oct 19, 2015 by mca.agarwal
edited Oct 19, 2015 by rajesh
0 votes
26 views



Related Hot Questions

2 Answers

0 votes

The Microsoft SQL Server JDBC driver does not support localDB. See the comment http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx#10250447

answered Oct 19, 2015 by sachin wagh
edited Oct 19, 2015 by rajesh
0 votes

You should change the host to localhost and also your url is not correct:

 jdbc:sqlserver://localhost;instance=TEST;databaseName=db1;schema=db1;

Please note that you might also need to add a port after the host, for example:

jdbc:sqlserver://localhost:1143;instance=TEST;databaseName=db1;schema=db1;

UPDATE

Seems like this DB is not supported by JDBC: http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/259f11e2-e740-40f8-9b6c-64d015ab4b74/

answered Oct 19, 2015 by mannar kande

...