英文:
A Problem regarding connecting mysql connecter with intellij
问题
好的,以下是翻译好的内容:
好的,我想将MySQL连接器连接到IntelliJ IDEA。我已将jar文件添加到模块中(还在module.info文件中编写了requires mysql.connecter.java),并且还将该jar文件添加到库中。
以下是相关的代码,下面我会说明我遇到的问题:
package sample;
import java.lang.Class;
import java.sql // 当我尝试导入java.sql时,它显示无法导入
public class DBConnection {
public static void main(String[] args) throws ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
// 我无法导入Connection类和DriverManager类
}
}
我做错了什么?任何帮助将不胜感激。谢谢!!
英文:
Ok, so I wanted to connect the MySQL connecter to intellij idea. I added the jar file to the module (also wrote requires mysql.connecter.java in the module.info file) and also added that jar file to the library.
Here's the following code and under it, I wrote the issue I am having:
package sample;
import java.lang.Class;
import java.sql // And when I try to import java.sql, it shows me that I can't import it
public class DBConnection {
public static void main(String[] args) throws ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
// I can't import the Connection class and the DriverManager class
}
}
What am I doing wrong? Any help would be appreciated. Thank You!!
专注分享java语言的经验与见解,让所有开发者获益!
评论