简体   繁体   English

连接 oracle 11g 与 java 8 (eclipse)

[英]connection oracle 11g with java 8 (eclipse)

I can't import java.sql.*;我无法导入 java.sql.*; because it said that this package is not accessible although I put ojdbc6 and also I tried ojdbc8 in the classpath but it isn't work;因为它说这个 package 是不可访问的,虽然我把 ojdbc6 并且我在类路径中尝试了 ojdbc8 但它不起作用; [ I mention that I have oracle 11g and jdk 10 & eclipse 4 ] [我提到我有 oracle 11g 和 jdk 10 & eclipse 4 ]

How did you add your ojdbc driver?您是如何添加 ojdbc 驱动程序的? A typical way is shown below:一种典型的方式如下图所示:

First you need to right click your project and go for "Build Path" and go for "Configure build Path"首先,您需要右键单击您的项目和 go 为“构建路径”和 go 为“配置构建路径”

找到配置构建路径

Then, in the "libraries" tab, click on the "Add External JARs" go to your ojdbc driver file to load it.然后,在“库”选项卡中,单击“添加外部 JAR”go 到您的 ojdbc 驱动程序文件以加载它。 添加 Ojdbc

This is the typical way to load your ojdbc driver.这是加载 ojdbc 驱动程序的典型方式。 Try first see whether it will help先试试看有没有用

If your IDE (Eclipse) gives error:如果您的 IDE (Eclipse) 给出错误:

The package java.sql is not accessible

Or if compiling using javac gives error:或者如果使用javac给出错误:

test\Test.java:3: error: package java.sql is not visible
import java.sql.*;
           ^
  (package java.sql is declared in module java.sql, but module Test does not read it)
1 error

Then it is because your Java 9+ project has a module-info.java file, ie your project is modular .那是因为你的Java 9+项目有一个module-info.java文件,即你的项目是模块化的。

You need to add the following line to the module-info.java file:您需要将以下行添加到module-info.java文件中:

    requires java.sql;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM