我已将oracle 11g安装到我的系统中。我使用控制面板中的 ODBC数据源创建了自己的数据源。详细信息如下图所示:
我试图通过我的java代码尝试访问此数据源:
JdbcType1Test.java
package connectionTests;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcType1Test {
public static void main(String[] args)throws ClassNotFoundException,SQLException {
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:nithin_ds","system","manager");
System.out.println(con);
}
}
执行上述程序后,我收到这样的错误:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:odbc:nithin_ds
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at connectionTests.JdbcType1Test.main(JdbcType1Test.java:13)