Reputation: 23
Has anyone had an experience with using SQL Server JDBC driver in Solaris? I downloaded the driver from this link: https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16
I then created a simple Java class to make a connection to the SQL Server database:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ExportToCSV {
public static void main(String[] args) {
String connectionUrl = "jdbc:sqlserver://Server1:4137;databaseName=db1;user=user1;password=secret";
try{
Connection con = DriverManager.getConnection(connectionUrl);
}catch(SQLException e){
e.printStackTrace();
}
}
}
I compiled the class with no issue.
This is how I called the class from the Unix command prompt:
java -classpath /app/user/lib/mssql-jdbc-12.8.1.jre8.jar -cp . ExportToCSV
It returned this following error:
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://Server1:4137;databaseName=db1;user=user1;password=secret
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at ExportToCSV.main(ExportToCSV.java:14)
What am I missing here?
Upvotes: 0
Views: 27