1

I am using sqlserver with Windows authentication, with a Windows server.

I am trying to connect to a remote MS SQLSERVER on my local network using java eclipse but keep getting this error:

Error : com.microsoft.sqlserver.jdbc.SQLServerException: The port number 64038 databaseName = Data is not valid.

Here is the code:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

System.out.println("# - driver loaded");

String server = "moddbs169d.network.local\\Moddbs169d\\SQL2008";

int port = 64038;

String database = "Data";

String jdbcUrl = "jdbc:sqlserver://"+server+":"+port+" databaseName = "+database+";integratedSecurity=true";

Connection con = DriverManager.getConnection(jdbcUrl);

System.out.println("# - Connection obtained");

If all is successful it should tell me connection obtained. The local connection and name of the database are both correct, so that is not the issue. The jdbc driver is also installed and working properly.

1 Answer 1

1

You are missing a semicolon before the "databaseName=xxx" property.

Without the semicolon, you are setting the port number to "64038 databaseName = Data". Admittedly, the error message could have used brackets to make it a bit clearer.

See (http://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) for the form of the connection URL.

Sign up to request clarification or add additional context in comments.

1 Comment

Semicolons will be my downfall. Thanks,It works now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.