No suitable driver for sqlserver - sql-server

I am working on an application that accesses to a miscrosoft database (mssql).
The application is running perfectly in local. But when I deploy it on the tomcat server in Unix I have this error:
Unable to get driver instance for jdbcUrl=jdbc:sqlserver://...
....
Caused by: java.sql.SQLException: No suitable driver
It is really strange cause I verified that the jar (sqljdbc42.jar) is located in the correct place.
Also the url "jdbcUrl=jdbc:sqlserver://..." is correct since it works fine in local.
Do you have any solution?
Thank you.

Related

SQL Server - Invalid Argument Supplied

So we have SQL Server 2008 R2 Express running on a local server, and a bunch of machines on the same LAN use a program I wrote in C# to access said server.
All the machines in the building except one can connect quite happily.
Connection string is:
Data Source=[IP address here],53535\SQLEXPRESS;Initial Catalog=EMS_Main;;User ID=EMSUser;Password=[password here];
Exact error message is:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An invalid argument was supplied.)"
Struggling to believe the 'invalid argument' bit, given that all other machines connect quite happily.
SQSL is definitely configured to accept remote connections, instance name is definitely correct.
The problem machine can connect using SQLSMS, but not via C#.
Disabling firewall on the problem machine makes no difference.
Everything seems to have been working fine on the problem machine up until a Windows 10 update a couple of days ago.
EDIT: An update on this: I now have two machines with this issue, and they both seem to have only developed it after Windows 10 updated to version 1803. All the pre-1803 machines still work fine.
Can anyone shed any more light on this please?
For anyone else hitting this issue, I discovered that this was happening because the client application was being run from a shared drive, and Windows 10 update 1803 must have some security update in it that causes this problem (only machines running 1803 were affected).
Running the application from the machine's hard drive solved the problem.
I'd still like to know a technical explanation for this, even though the problem is solved.
I have the same issue. A dig deeper and discovered that this happened after installing an update (May 8, 2018—KB4103721). Try to uninstall this update or use named pipes instead tcp.

No data connection after cloning ASP MVC project to different computer

I was working on an ASP.NET MVC5 application and pushed it to git. Someone else cloned the project to their computer.
When they try to run the app it works up until there is a database call. They get the error message:
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)'
In the Server Explorer we can see that the connection is closed. We also see no tables at all, like as if there was no database.
Does anyone know how we can approach this? I'd think that the connection string remains the same on each machine? The database was created code first, do we somehow have to recreate it? If so, how?
Thanks for your suggestions!
The connection string should be the same.
You should first disable Windows Firewall and antivirus programs (and similars), if they're present, and test again.
You should try a connection via another database client too, just to check if you are blocked someway.
If these attempts doesn't solve the problem, you can recreate the database for test pourposes, if you will. For Entity Framework, for example, search "migrations" term in Google.
The error is relevant. Obviously, from the computer hosting the cloned solution, the SQL server is not reachable.
If, in development, you used a local SQL Server (like SQL Express or Local DB), you must verify that on the computer hosting the clone solution you have the same setup. If you used a remote server, you must check that the server is available to the computer hosting the cloned solution.
In both cases, you can use Server Explorer to verify the db connection and access.
Unfortunately, there is no satisfying answer.
At first, we reinstalled Microsoft SQL Server. That alone did not help.
We did change the autentication from Windows Authentication to SQL, because the person working on that workstation still had the account details from the previous owner.
That alone did make the test connection successful. But then, we got another error when doing the "Update-Database" command in VS, which we solved by deleting a rogue migration that was there for some reason unknown.
Now it works - sorry for not offering a more concise solution.

How to connect to localdb in Rider?

Trying to connect to localdb using Database tab in Rider.
I adding SqlServer jTds and Rider shows this error
Connection to SunEngineDb1 failed. [08S01] Network error IOException:
.\pipe\MSSQL$LOCALDB#E65C6709\sql\query (Can not find the specified
file)
What am I missing, and how it can be solved?
It is ASP.NET Core 2.0 project with localdb database on development. If I run it it works perfectly including database connect.
Well, finally we discovered the problem. It is the mistake in the driver we provide. To have this issue fixed urgently, delete the file \config\jdbc-drivers\jdbc-drivers.xml and restart the IDE. Then, please, refresh your driver to 1.3.1.1 or just put [latest] there.

I/O Error: SSO Failed: SSPI Not Initialized

I am using pentaho data integration 4.1 (Kettle) to build an ETL system. My customer requires connecting to database (MS SQL Server) using window authentication, I knew that Kettle supported it . However when I run my Kettle job, it throws the exception
"I/O Error: SSO Failed: SSPI Not Initialized".
From an article on a forum, I copy library sqljdbc_auth.dll into jre/bin folder. The result is quite good, I can use window authentication to connect to SQL server. But this function is not stable, I mean sometimes it works well, sometimes it throws exception
"I/O Error: SSO Failed: SSPI Not Initialized".
Please tell me how to fix this error.
Thank you.
To connect to SQL Server 2008, I had to install the 'Microsoft JDBC Driver 4.0 for SQL Server' and then add the path to sqljdbc_auth.dll to Spoon.bat in %PENTAHO_DI_JAVA_OPTIONS%. Like this:
set OPT=%PENTAHO_DI_JAVA_OPTIONS% "-Djava.library.path=%LIBSPATH%;C:\PROGRA~1\MICROS~1.0FO\sqljdbc_4.0\enu\auth\x86;C:\PROGRA~1\IBM\SQLLIB\BIN" "-DKETTLE_HOME=%KETTLE_HOME%" "-DKETTLE_REPOSITORY=%KETTLE_REPOSITORY%" "-DKETTLE_USER=%KETTLE_USER%" "-DKETTLE_PASSWORD=%KETTLE_PASSWORD%" "-DKETTLE_PLUGIN_PACKAGES=%KETTLE_PLUGIN_PACKAGES%" "-DKETTLE_LOG_SIZE_LIMIT=%KETTLE_LOG_SIZE_LIMIT%"
Ugly, but that's Java under Windows for you. Works quite reliably now though.
Are you using the JTDS driver? Try that combined with the ntlmauth.dll - that works great for us when running PDI on Windows Server 2003 connecting to various remote sqlserver databases.
We place the DLL in this folder:
libswt\win64
I've had the same issue while using JDBC 1.2.2 with MSSQL 2008. It turns out that there is a bug in the driver, making it randomly crash if you initialize it with more than one connection.
If we used only one initial connection to the DB this error never presented itself.
The issue is fixed in a later versions of JDBC. We currently use 1.3.0 and I/O Error: SSO Failed: SSPI Not Initialized never comes up.

MS SQL driver issue with Struts 2 tomcat 7

I am developing web application using Tomcat 7 and connecting to a MSSQL 2008 DB.
While executing a DB operation from any Java console based application, it succeeds. Same code fails to execute while performing same operations from web application with the message "No suitable drivers found". We are using sqljdbc4
URL private String url = "jdbc:sqlserver://10.100.41.232;databaseName=iptvdb;";
Not able to understand the this strange behaviour. Any workarounds?
Also tried with : port 1433 but it's still not working.
That error means it cant find the JDBC driver on your classpath. Do you have the JDBC driver? You need to have the MySQL JDBC drivers. If you dont have it, it can be downloaded from the MySQL website.
If you do have the driver or have downloaded it, make sure it is in the correct place. It needs to be placed on your classpath. This usually means one of two places
With your Struts application under the WEB-INF/lib folder
With the application server. For tomcat this is usually in $CATALINA_HOME/lib

Resources