I'm pretty new to Java development and I'm starting to learn about connecting to sql servers. I've read tonnes of tutorials and I am currently running into a problem with my application, the error I am currently facing is:
No suitable driver found for jdbc:sqlserver://192.168.*.***:1433;Database=STC
What I would like to know is what exactly do I have to do to the server to allow for the connection to be fully made? Please note as well that the database and server is not on my desktop but in a different location. All help is appreciated.
Here is my code too.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class SecondTest
{
public static void main(String[] argv)
{
System.out.println("-------- MySQL JDBC Connection Testing ------------");
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
return;
}
System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;
try
{
String url = "jdbc:sqlserver://192.168.***.***:1433;Database=STC";
String username = "*****";
String password = "******";
connection = DriverManager.getConnection(url, username, password);
}
catch (SQLException e)
{
System.out.println("Connection Failed!");
e.printStackTrace();
return;
}
if (connection != null)
{
System.out.println("Fully connected.");
}
else
{
System.out.println("Failed to make connection!");
}
}
}
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");