Skip to content

Commit 85c0c40

Browse files
committed
FIX #716 No Support for LocalDB http://sourceforge.net/p/jtds/bugs/716/
1 parent 41fb9b9 commit 85c0c40

File tree

8 files changed

+54
-17
lines changed

8 files changed

+54
-17
lines changed

.classpath

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src/main"/>
4-
<classpathentry kind="src" path="src/test"/>
5-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6-
<classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
7-
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
8-
<classpathentry kind="output" path="bin"/>
9-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main"/>
4+
<classpathentry kind="src" path="src/test"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
6+
<classpathentry kind="lib" path="lib/jcifs-1.3.17.jar"/>
7+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
8+
<classpathentry kind="output" path="bin"/>
9+
</classpath>

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.class
2+
3+
# Mobile Tools for Java (J2ME)
4+
.mtj.tmp/
5+
6+
# Package Files #
7+
*.jar
8+
*.war
9+
*.ear
10+
11+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12+
hs_err_pid*
13+
14+
# Mac desktop service store files
15+
.DS_Store

.settings/org.eclipse.jdt.core.prefs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
#Sun Jul 08 10:42:43 MDT 2007
21
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.compliance=1.7
35
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
46
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
7+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
58
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
69
org.eclipse.jdt.core.compiler.problem.deprecation=ignore
710
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
811
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
912
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
1013
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
14+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
1115
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
1216
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
1317
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
@@ -62,3 +66,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
6266
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
6367
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
6468
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
69+
org.eclipse.jdt.core.compiler.source=1.7

README renamed to README.md

File renamed without changes.

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<property name="dist" value="dist"/>
2323
<property name="test" value="test"/>
2424

25-
<property name="version" value="1.3.1"/>
25+
<property name="version" value="1.3.2"/>
2626
</target>
2727

2828
<target name="clean" depends="init">

src/main/net/sourceforge/jtds/jdbc/DefaultProperties.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public final class DefaultProperties {
8989
public static final String NAMED_PIPE = "false";
9090
/** Default <code>namedPipePath</code> property for SQL Server. */
9191
public static final String NAMED_PIPE_PATH_SQLSERVER = "/sql/query";
92+
/** Default <code>namedPipePath</code> property for LocalDB. */
93+
public static final String NAMED_PIPE_PATH_LOCALDB = "/tsql/query";
9294
/** Default <code>namedPipePath</code> property for Sybase. */
9395
public static final String NAMED_PIPE_PATH_SYBASE = "/sybase/query";
9496
/** Default <code>packetSize</code> property for TDS 4.2. */
@@ -326,6 +328,15 @@ else if (serverType == Driver.SYBASE) {
326328
throw new IllegalArgumentException("Unknown serverType: " + serverType);
327329
}
328330

331+
public static String getNamedPipePath(int serverType, String instanceName) {
332+
if (serverType == 0 || serverType == Driver.SQLSERVER) {
333+
if(instanceName.startsWith("LOCALDB"))
334+
return NAMED_PIPE_PATH_LOCALDB;
335+
else
336+
return NAMED_PIPE_PATH_SQLSERVER;
337+
}
338+
throw new IllegalArgumentException("Unknown serverType: " + serverType);
339+
}
329340
/**
330341
* Converts an integer server type to its string representation.
331342
*

src/main/net/sourceforge/jtds/jdbc/SharedLocalNamedPipe.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ public SharedLocalNamedPipe(JtdsConnection connection) throws IOException {
5656
}
5757
pipeName.append("\\pipe");
5858
if (instanceName != null && instanceName.length() != 0) {
59-
pipeName.append("\\MSSQL$").append(instanceName);
60-
}
61-
String namedPipePath = DefaultProperties.getNamedPipePath(connection.getServerType());
59+
if(!instanceName.startsWith("LOCALDB"))
60+
pipeName.append("\\MSSQL$");
61+
else
62+
pipeName.append("\\");
63+
pipeName.append(instanceName);
64+
}
65+
String namedPipePath = DefaultProperties.getNamedPipePath(connection.getServerType(), instanceName);
6266
pipeName.append(namedPipePath.replace('/', '\\'));
6367

6468
pipe = new RandomAccessFile(pipeName.toString(), "rw");

src/main/net/sourceforge/jtds/jdbc/SharedNamedPipe.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ public SharedNamedPipe(JtdsConnection connection) throws IOException {
7474

7575
final String instanceName = connection.getInstanceName();
7676
if (instanceName != null && instanceName.length() != 0) {
77-
url.append("/MSSQL$");
77+
if(!instanceName.startsWith("LOCALDB"))
78+
url.append("/MSSQL$");
79+
else
80+
url.append("/");
7881
url.append(instanceName);
7982
}
80-
81-
String namedPipePath = DefaultProperties.getNamedPipePath(connection.getServerType());
83+
String namedPipePath = DefaultProperties.getNamedPipePath(connection.getServerType(), instanceName);
8284
url.append(namedPipePath);
8385

8486
setPipe(new SmbNamedPipe(url.toString(), SmbNamedPipe.PIPE_TYPE_RDWR, auth));

0 commit comments

Comments
 (0)