关于在IntelliJ中连接MySQL连接器的问题。

huangapple 未分类评论50阅读模式
英文:

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!!

huangapple
  • 本文由 发表于 2020年4月7日 09:36:30
  • 转载请务必保留本文链接:https://java.coder-hub.com/61071468.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定