R
R
Romario212018-07-27 12:47:44
Java
Romario21, 2018-07-27 12:47:44

Java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver?

Hello everyone, I ask for help.
I am writing a project on vaadin flow.
Java 1.8
I'm trying to connect to MSSQL, I get a message like:
"java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver"
I connected mssql-jdbc both via maven and as a regular library.
Here is the code:

.......
  Driver d = (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
            con = DriverManager.getConnection(connectionUrl,"login","pass");
            stmt = con.createStatement();

.......

The application server is running on my PC, before that the application was written in JavaFX, but there were no connection problems.
Idea normally connects to the database.
The database is spinning on the server, maybe something needs to be done on it, what should be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-07-27
@Romario21

When IDEA runs your program, it ensures that the dependencies it needs are in the CLASSPATH. When the application server launches it, it does not and the program crashes because it cannot find the jdbc driver jar file. Read the instructions for your server, find out where to put the dependency jar files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question