执行此代码时出现以下错误
import java.sql.*;
public class DatabaseConnectivityTest {
public static void main(String args[]) throws ClassNotFoundException
{
Connection conn=null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Trying to connect to database");
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");
System.out.println("Connected");
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
我得到的错误是
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at DatabaseConnectivityTest.main(DatabaseConnectivityTest.java:10)