当我尝试运行此代码时,出现一个错误,表示我错过了正确的驱动程序,但是当我下载驱动程序时,错误仍然存在。试图将java程序连接到mySQL服务器
public static void main(String[] args)
{
try {
Connection con = DriverManager.getConnection("108.167.137.42" ,"********", "********");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
}
}
您需要使用'class.forName()'加载jdbc驱动程序。参考本教程https://www.javatpoint.com/example-to-connect-to-the-mysql-database – Rohan
您需要驱动程序mySql,请加载驱动程序。如果您遇到困难,可以在谷歌上找到大量的样板代码来做到这一点。 –
如果要远程连接到数据库,请确保使用提供的参数从外部访问它。 – dosdebug