伙计们。 下面的代码不起作用。指责错误。
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class Main {
public static void main(String[] args) throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XEPDB1","hr","hr");
Statement st = con.createStatement();
st.executeUpdate("CREATE TABLE student(rno number, name varchar(20),branch varchar2 (20))");
st.close();
con.close();
}
}
错误:
"C:\Program Files\Java\jdk-17\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.1\lib\idea_rt.jar=53331:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Eclipse\Intellij\CRUDPuro\out\production\CRUDPuro Main
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at Main.main(Main.java:8)
Process finished with exit code 1
安装在此路径中的驱动程序 ojdbc11.jar
感谢您的帮助