When run executable jar file i have and SQLException: No suitable driver found for jdbc:mysql://localhost:3306/DENTAL

huangapple go评论89阅读模式
英文:

When run executable jar file i have and SQLException: No suitable driver found for jdbc:mysql://localhost:3306/DENTAL

问题

我正在进行一个项目,我的项目应该与“数据库”连接,当我在“NetBeans”上运行它时,它完美运行。但是当我尝试运行可执行的jar文件时,我遇到了以下错误,

"找不到适用于jdbc:mysql://localhost:3306/DENTAL的合适的驱动程序"

请注意,我已经将“mysql-connector.jar”添加到库中。

谢谢

英文:

I am working on a project, my project should be connected with Database, When I run it on NetBeans it works perfectly, But when I am try to run the executable jar file i have an error like this,

"No suitable driver found for jdbc:mysql://localhost:3306/DENTAL"

please note that I added the mysql-connecter.jar to libraries.

Thank you

答案1

得分: 0

请使用以下内容生成jar文件:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>edu.learn.App</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-runnable-jar</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

然后运行 mvn clean package
英文:

Please use the following to generate jar file:

&lt;build&gt;
  &lt;plugins&gt;
    &lt;plugin&gt;
  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
  &lt;configuration&gt;
    &lt;archive&gt;
      &lt;manifest&gt;
        &lt;mainClass&gt;edu.learn.App&lt;/mainClass&gt;
      &lt;/manifest&gt;
    &lt;/archive&gt;
    &lt;descriptorRefs&gt;
      &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
    &lt;/descriptorRefs&gt;
  &lt;/configuration&gt;
  &lt;executions&gt;
    &lt;execution&gt;
      &lt;id&gt;make-runnable-jar&lt;/id&gt; 
      &lt;phase&gt;package&lt;/phase&gt; 
      &lt;goals&gt;
        &lt;goal&gt;single&lt;/goal&gt;
      &lt;/goals&gt;
    &lt;/execution&gt;
  &lt;/executions&gt;
&lt;/plugin&gt;
  &lt;/plugins&gt;
&lt;/build&gt;

then run mvn clean package

huangapple
  • 本文由 发表于 2020年4月10日 17:16:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/61137277.html
匿名

发表评论

匿名网友

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

确定