Im getting
I/O Error: DB server closed connection.
while connecting to MS SQL server 2008 from java code .
SQL server is in mixed mode and its in local machine.My connection string is
jTDS
jdbc:jtds:sqlserver://machineName:1433;databaseName=DB;integratedSecurity=true
stack trace is
java.sql.SQLException: I/O Error: DB server closed connection.
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2311)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:610)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:345)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.app.hibernate.test.(test.java:22)
at com.app.hibernate.test.main(test.java:53)
Caused by: java.io.IOException: DB server closed connection.
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:848)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:727)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2206)
... 8 more
Exception in thread "main" java.lang.NullPointerException
at com.app.hibernate.test.db(test.java:36)
at com.app.hibernate.test.main(test.java:54)
JDBC Driver
String url ="jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db";
stacktrace
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'username'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:156)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:240)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:78)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2636)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2046)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2034)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4003)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1550)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1207)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.app.hibernate.test.(test.java:22)
at com.app.hibernate.test.main(test.java:53)
Exception in thread "main" java.lang.NullPointerException
at com.app.hibernate.test.db(test.java:36)
at com.app.hibernate.test.main(test.java:54)
Your Connection String and authentication have errors. if it is mix mode don't use SQL authentication
Try this
PC Name : janaka-pc SQL User Name : sa SQL Password
: 1234 Database : Janak_DB
Code for sql Conncetion in JDBC
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://janaka-PC;user=sa;password=1234;database=Janak_DB");
You have problems in your connection strings
For jTDS:
jdbc:jtds:sqlserver://machineName:1433;databaseName=DB;useNTLMv2=true;domain=workgroup
You may read http://jtds.sourceforge.net/faq.html#windowsAuth for the required Single-Sign-On library for NTLM to work.
"integratedSecurity=true" that you supplied for jdts is valid when using the JDBC driver
jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db;integratedSecurity=true
You have an authentication error in on the MS SQL side.
If you're not in control of how to adquire the connection (ie, you're using a Datasource or a Connection Pool), the connection URL must contain the login and password to be used, like:
jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db;user=USERNAME;password=PASSWORD";
If the application is running on a Windows machine and you want to use the credentials of the logged user, then you can specify the domain parameter with or without useNTLMv2.
Finally, if you are on a windows machine but you want to authenticate the user against a domain, then you must supply the username, password and domain parameters. You can read all about it in the jtds FAQ, specially the URL Format section.
Related
I am trying to connect sql server 2008 r2 with my java code , But it is showing me this error .
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host DINESH-PC, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Main.main(Main.java:13)
my code is:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String dbURL = "jdbc:sqlserver://localhost:1433;user=sa;password=123456";
Connection conn = DriverManager.getConnection(dbURL);
if (conn != null) {
System.out.println("Connected");
}
i am using jre7 and sqljdbc4-3.0.jar is included in library.
Help me with ur suggesstions.
You have quite a lot of information from exception message. Just follow the hints. Check if all connection string are right. Check if DB server run. Check if there is no firewall blocking that port on server where DB is situated.
also must check wheather tcp/ip is enabled ..
to check
open sql server configration manager
select sql server network configration
then, select protocol for MSSQLSERVER
them check wheather tcp/ip is enabled or not. If not enable it.
I'm trying to connect to a MS SQL Server DB using JDBC and on this line:
String connectionUrl = "jdbc:" + url + ";user=dummy;password=dummy;";
conn = DriverManager.getConnection(connectionUrl);
I'm getting this massive wall-of-text of an error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.crypto.JceSecurityManager.<clinit>(JceSecurityManager.java:65)
at javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2543)
at javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2567)
at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:548)
at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:527)
at sun.security.ssl.CipherSuite.isAvailable(CipherSuite.java:194)
at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:350)
at sun.security.ssl.SSLContextImpl.getDefaultCipherSuiteList(SSLContextImpl.java:308)
at sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:607)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:549)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1606)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at BusinessManager.Session.<init>(Session.java:33)
at BusinessManager.BusinessManager.getSession(BusinessManager.java:172)
at example.Example.ConfigureEnvironment(Example.java:198)
at example.Example.main(Example.java:50)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:89)
... 22 more
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:254)
at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
at javax.crypto.JceSecurity$1.run(JceSecurity.java:81)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:78)
... 22 more
I've followed a couple of links, made sure both server and client are using the same JDK (1.8.0_20).
I've also downloaded the "JCE Unlimited Strength Jurisdiction Policy Files" and placed them in the JDK. I've also followed this link but I'm not sure whether I should be meddling with the JDK's "java.policy" files...
My guess based on the error is that you are attempting to connect to SQL with an SSL encrypted session but are using a self-signed certificate on the SQL Server. Per Connecting with SSL Encryption:
When the encrypt property is set to true and the
trustServerCertificate property is set to true, the Microsoft JDBC
Driver for SQL Server will not validate the SQL Server SSL
certificate. This is usually required for allowing connections in test
environments, such as where the SQL Server instance has only a self
signed certificate.
Try using:
String connectionUrl = "jdbc:" + url + ";user=dummy;password=dummy;encrypt=true;trustServerCertificate=true;";
Also, your url variable contents should start with sqlserver://.
This question already has answers here:
SqlServer: Login failed for user
(14 answers)
Closed 4 years ago.
I am trying to connect to a database that I created using SQL Server 2012, but I keep getting an error. This is the code for the connection:
Driver d = (Driver)Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
String DB_URL = "jdbc:sqlserver://localhost:1433;databaseName=Tema6;user=sa;password=123456";
java.sql.Connection con = DriverManager.getConnection(DB_URL);
And this is the error that I am getting:
Login failed for user 'sa'. ClientConnectionId:e6335e64-ca68-4d72-8939-5b7ded951424
I have enabled TCP/IP protocol from SQL Server Config, I am sure that the 'sa' account is enabled and that the password is correct. Can anyone help me, please?
EDIT: This is the entire stacktrace.
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:e6335e64-ca68-4d72-8939-5b7ded951424
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2908)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Connection.main(Connection.java:12)
EDIT2: After replacing the driver with jTDS:
java.sql.SQLException: Login failed for user 'sa'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2893)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2335)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:609)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:369)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:183)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Connection.main(Connection.java:19)
I don't think it's a driver issue, since the message indicates that it's tried and failed authentication, so at least managed to connect.
First (basic) question I'd ask is whether you're sure '123456' is the right password for the sa account? Test it by logging in with SQL Server Management Studio as 'sa'.
Next I'd try creating a user in SQL Server and supplying those credentials in the connection string (as suggested by Brandon)
Next (for fun) I'd enable mixed-mode authentication and try using my windows user account credentials in the connection string.
These are some instructions I wrote for configuring the networking in SQL Server in the past. Definitely worth double-checking the settings:
Configuring SQL Server Networking
Out of the box, SQL Server 2008 Express does not support TCP connections on a fixed port. To resolve this:
From the windows start menu open "SQL Server Configuration Manager"
Under "SQL Server Network Configuration" --> "Protocols for SQLEXPRESS"
open the TCP/IP properties
On the "Protocol" tab
set enabled to YES
On tab "IP Addresses" scroll to the bottom
Under "IP All"
change the TCP Port to 1433
ensure the TCP Dynamic Ports is empty, delete the zero
Click apply
In SQL Server Management Studio check:
From server instance right click and select properties
Under the Security option : ensure that "SQL Server and Windows Authentication mode" is checked
Click SQL --> click right mouse --> propretise --> Securiti -->tick SQL server and windows Authentication mode
90% success!
This database url is in wrong format
String DB_URL = "jdbc:sqlserver://localhost:1433;databaseName=Tema6;user=sa;password=123456";
instead of this try this
Connection connection = DriverManager
.getConnection("jdbc:sqlserver://localhost:1433;\\SQLEXPRESS;databaseName=Tema6","sa","123456");
I haven't really checked out your stack trace but it is very common for people to forget about allowing remote connections to server. Try right-click on server instance (Object Explorer) > Properties > Connections and check Allow remote connections to this server
Check the port on which sql server is configured. You get this weird error if the port is configured as "dynamic port" and you are trying to connect on the default port.
You could check if this is the issue or not by trying to connect to the sql server through sqlserver client.
Set the authentication mode to "sql server authentication"
Enter the servername and port in the format "servername,port" in the server field
Enter user name and password and click connect
If the connect didnt succeed and you get the exact error message "login failed for user xxx" then this is the issue
https://msdn.microsoft.com/en-IN/library/ms177440.aspx
Go to sql server, select user properties and change server roles to sysadmin solved the issue.
I'm writing a Java program that queries a PostgreSQL database. I'm following this example and have trouble here:
connection = DriverManager.getConnection(
"jdbc:postgresql://127.0.0.1:5432/testdb", "mkyong",
"123456");
According to the JavaDoc for DriverManager the first string is "a database url of the form jdbc:subprotocol:subname. When I connect to the server I type in psql -h dataserv.abc.company.com -d app -U emp24 and give the password qwe123 (for example sake). What should the first argument of getConnection be?
I've tried
connection = DriverManager.getConnection(
"jdbc:postgresql://dataserv.abc.company.com", "emp24",
"qwe123");
and get the run time error: no suitable driver found.
I've download JDBC4 Postgresql Driver, Version 9.2-1000.
After I fixed my program to load the driver with Class.forName("org.postgresql.Driver"); it recognises the JDBC URL but it still doesn't connect. I now have a new error.
When I run the program there is an error and here is the output with the stack trace:
-------- PostgreSQL JDBC Connection Testing ------------
PostgreSQL JDBC Driver Registered!
Connection Failed! Check output consoleorg.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:207)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:140)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:23)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DatabaseConnect.main(DatabaseConnect.java:32)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.postgresql.core.PGStream.<init>(PGStream.java:60)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:101)
... 11 more
I format the URL for the getConnection like this:
"jdbc:postgresql://dataserv.abc.company.com:5432/app"
Most likely you have failed to register the JDBC driver with the DriverManager, so JDBC doesn't know how to handle jdbc:postgresql:. Try Class.forName("org.postgresql.Driver"); before you try to use DriverManager.getConnection. That is shown in the example code you linked to (it's the very first line), is explained in the preamble of the DriverManager documentation, and is also explained in detail in the PgJDBC documentation linked below.
Alternately, maybe you've typo'd jdbc:postgresql: so the DriverManager is looking for a driver named postgrsql or Postgresql or something, which won't be registered.
Finally, you could be swallowing a class loading exception so the driver load fails and you don't see it, like this (extremely bad) code:
// Very bad code, never do this
try {
Class.forName("org.postgresql.Driver");
} catch (ClasNotFoundException ex) {}
Never do the above. Either wrap the exception in an unchecked runtime exception or just add throws ClasNotFoundException to your method definition.
As per the PgJDBC documentation and FAQ, to use the driver you must:
Download the JDBC driver;
Ensure that the JDBC driver is on your CLASSPATH;
Load/register the driver by passing a JVM parameter or using Class.forName("org.postgresql.Driver"); so it's registered with the DriverManager;
Connect to the database
These are all links to the manual.
For more on the CLASSPATH, see wikipedia
The JDBC DriverManager is discussed in the JavaDoc and the JDBC tutorial.
As for the JDBC URL format for PostgreSQL, that's in the documentation too.
With JDBC, a database is represented by a URL (Uniform Resource
Locator). With PostgreSQL™, this takes one of the following forms:
jdbc:postgresql:database
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database
The docs go on to explain what each parameter means and the optional connection parameters.
From this you can see, in answer to your comment on John Woo's answer, that you do not have to specify the port if your server is listening on the default PostgreSQL port, which it is if you don't have to specify the port when connecting with psql.
That makes your getConnection arguments correct, the problem is that you didn't register the driver first.
Make sure your pg_hba.conf file has an entry for local connections, something like this:
local mydatabasename myusername password
This question already has answers here:
SqlServer: Login failed for user
(14 answers)
Closed 4 years ago.
I am trying to set a JDBC connection to Sql Server 2008. I have created a database in Sql Server with this information:
CREATE LOGIN xtest WITH PASSWORD = 'berenjenas7(((';
GO
CREATE USER samxtest FOR LOGIN xtest;
GO
GRANT SELECT TO samxtest;
GO
GRANT INSERT TO samxtest;
GO
GRANT UPDATE TO samxtest;
GO
GRANT DELETE TO samxtest;
GO
I installed the JDBC driver from here: http://www.microsoft.com/en-us/download/details.aspx?id=11774
and I used the connectURL class from this link: http://msdn.microsoft.com/en-us/library/aa342339.aspx
in order to test the connection.
I left the default port 1433 in the code. The following picture should be proof that this is really the port:
And of course I changed the connection string to:
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=XTest;user=samxtest;password=berenjenas7(((";
I don't understand what is wrong?
The error I get is:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
'samxtest'. ClientConnectionId:2344af..... at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at
com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2908)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
at
com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source) at
java.sql.DriverManager.getConnection(Unknown Source) at
connectURL.main(connectURL.java:18)
Misread:
Make sure that Authentication Mode of the SQL server “Mixed Mode (Windows Authentication and SQL Server Authentication)”.
Run following script to change the authentication
LOGIN xtest ENABLE
ALTER LOGIN samxtest WITH PASSWORD = 'password'