数据库连接出现异常java.sql.SQLException: No suitable driver:
程序如下:
import java.sql.*;
public class SqlTest{
public static void main(String args[]) throws
SQLException,ClassNotFoundException{
String dburl="jdbc.odbc.MySql";
String name="caiyanying";
String password="awftifamd";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(dburl,name,password);
}catch(ClassNotFoundException e){
System.out.println("Class not found exception.");
e.printStackTrace();
System.exit(1);
}catch(SQLException e){
System.out.println("sqlexception.");
e.printStackTrace();
}
}
}
编译通过,可执行的时候出现异常.
sqlexception.
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)