每当我想将我的 oracle sql 数据库与 java 链接时,就会发生这种情况,我找不到解决我问题的解决方案
我正在使用 jcbd6
它用于明天到期的学校项目,因此将不胜感激任何帮助或建议
package bddProFinal;
import java.sql.*;
import javax.swing.*;
public class jbdc {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "ye", "13102001");
Statement stmt = connection.createStatement();
String sql = "select * from Etudiant";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2));
connection.close();
}
} catch (Exception e) {
System.out.println(e);
}
}
}