0
我正在使用jdk1.8,我試圖在oracle 8i上手動執行jdbc程序。我的代碼編譯沒有任何錯誤,但在運行時顯示錯誤 - no suitable driver found for jdbc:oracle:thin:@localhost:1521:orcl
。我已經設置了jar文件的類路徑。我正在使用ojdbc7.jar
文件。 我的代碼是:顯示錯誤 - 找不到合適的驅動程序jdbc:oracle:thin:@localhost:1521:orcl
import java.sql.*;
class Database
{
public static void main(String arg[])
{
try
{
String url="jdbc:orcl:thin:@localhost:1521:orcl";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url,"scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from aj1");
while(rs.next())
{
System.out.println("\n"+rs.getInt(1)+" "+rs.getString(2));
}
}
catch(Exception e){e.printStackTrace();}
}
}
請給出這方面的解決方案: