I have created project want to deploy it using Jenkins and Git. I created maven project and added all the dependencies required. My one of class contains following code-
try {
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
} catch(Exception e) {
System.out.println("Problem registering JDBC driver");
}
and indicates error at com.microsoft.jdbc.sqlserver.SQLServerDriver() this line like not able to find com.microsoft package.
I have added maven dependency for Microsoft server driver in POM file-
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>test</scope>
</dependency>
Now when i try to run that project with clean install it gives error as:
package com.microsoft.jdbc.sqlserver does not exist
and fails the build.
What should I do to remove this error and run my project successfully?
DriverManager.registerDriveris not for applications to be called, it is only for JDBC drivers to register themselves when loaded. If you need to load, then useClass.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")and the driver will register itself.