Tomcat not able to find Microsoft SQL driver class - sql-server

Tomcat version - apache-tomcat-9.0.0.M19
I am trying to connect my spring application with microsoft sql database.
driverClassName=com.microsoft.sqlserver.jdbc.SQLserverDriver
Maven dependency -
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
This jar is available in the generated war file and i have also placed the jar in the lib folder of the tomcat but i'm still getting the following error when i try to deploy my application on Tomcat -
Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLserverDriver'
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLserverDriver
What am i missing?

You have a typo in your config. The driver class is named
com.microsoft.sqlserver.jdbc.SQLServerDriver
not
com.microsoft.sqlserver.jdbc.SQLserverDriver
................................^...........

Related

Apache Flink - ClassNotFoundException : org.apache.flink.configuration.DescribedEnum

When I run my Apache Flink app via Intellij, I see this error at runtime (at compile compile-time, there are no errors):
Caused by: java.lang.ClassNotFoundException: org.apache.flink.configuration.DescribedEnum
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
This is what I've listed in my pom.xml
<scala.version>2.12.8</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<flink.version>1.13.5</flink.version>
...
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
I I went to the following link for the source: https://flink.apache.org/downloads.html
wget https://archive.apache.org/dist/flink/flink-1.13.5/flink-1.13.5-src.tgz
The application (via Intellij) is unable to locate the DescribedEnum class.
I have tried adding some other dependencies, but I'm not sure which jar this is in.
Any thoughts?
You don't seem to have the basic dependency flink-streaming-java_${scala.binary.version} listed in your POM. See https://nightlies.apache.org/flink/flink-docs-release-1.13/docs/dev/datastream/project-configuration/ for more details.

jdk17 application not able to connect to sybase

This application runs without any error with jdk8.
jdk version jdk17
jConnect dependency
<dependency>
<groupId>com.sybase.jconnect</groupId>
<artifactId>jconn4</artifactId>
<version>7.07-27307</version>
</dependency>
oracle dependency
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8_g</artifactId>
<version>12.2.0.1</version>
</dependency>
Error : Could not load JDBC driver class [com.sybase.jdbc4.jdbc.SybDriver]
I tried by upgrading jConnect jar to 16.039-27463 and ojdbc to ojdbc10 version 19.3 but of no use.
Did anyone face this before and how got it fixed.

Mulesoft Anypoint Studio will not let me connect to SQL Server database

I continue to get a error saying:
Error trying to load driver: com.microsoft.sqlserver.jdbc.SQLServerDriver : Cannot load class 'com.microsoft.sqlserver.jdbc.SQLServerDriver':
Class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' has no package mapping for region 'domain/default/app/s-claims'
I have the dependency for it in my pom.xml:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.2.jre8</version>
</dependency>
I also have the shared library in the pom:
<sharedLibrary>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</sharedLibrary>
When trying to connect directly to SQL Server using the same credentials, I am successful.
I am fairly new to Mulesoft so It could be something simple I am missing. Does anyone have any ideas?
Apparently there was just a issue with the studio. I didn't change anything and tested my connection again and it worked after redeploying.

spring boot configuration with MS SQL Server 2016

I am trying to connect to Microsoft SQL Server 2016 from spring boot application. SQL server is configured using windows authentication.
Following are the configuration
application.properties file
spring.datasource.url=jdbc:sqlserver://K877DTRV:1433;databaseName=testdb;integratedSecurity=true
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.initialize=true
pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
java version is 1.8.spring boot version is 2.0.3.RELEASE
I am getting the below error while starting the tomcat
Cannot load driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
Should I do any additional configurations?
Note: I am using Windows Authentication.
Can anyone please help ?
Setting a version to the pom entry for mssql-jdbc worked like a charm
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version><!--$NO-MVN-MAN-VER$-->
</dependency>

Tomcat connection to SQL server

I connected a SQL server and its driver to my Dynamic Web project. I created a test class (not part of the website) that successfully connects to my database.
However, when I try to connect to my database in my website (in a java servlet actually) and run it on my server/Apache Tomcat I get the exception:
class not found
I don't understand why this is happening. My server is working, and the database connection works in a regular java class. Do I have to set up something else when using a SQL server on a (Tomcat) web server?
Any help would be much appreciated!
I suppose you are using a JDBC driver to connect to your SQLserver from the servlet.
Make sure you have copied the JDBC jar file into the Tomcat app you are actually running the servlet from. Ensure that you are accessing that servlet in particular from your front-end (web site) and not another servlet by mistake which does not have the JDBC classes in its class path:
Typically the jar file goes into webapps/your_app_name/WEB_INF/lib
can you share the stack trace, on which class is your code breaking?
If you are using Maven then you may need to remove the <scope> notation. I was using eClipse, Maven, MSSql. My pom.xml shows the dependancy was grey and marked as test. I removed the line and it worked great.
Change:
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.1.4.jre8-preview</version>
<scope>test</scope>
</dependency>
to:
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>7.1.4.jre8-preview</version>
</dependency>

Resources