database connectivity fails after creating jar file

前端 未结 1 1280
感情败类
感情败类 2021-01-27 13:29

I created a project with notepad.And running well in cmd with mysql server database.

But after creating a jar file of same project then jar file is not able to connect t

相关标签:
1条回答
  • 2021-01-27 14:14

    Here is the solution,
    following are the content of manifest.txt file

    Main-Class: filename
    Class-Path: . mysql-connector-java-5.1.33-bin.jar
    

    mysql-connector-java-5.1.33-bin.jar connector must be in the same directory so that the jar file include it.
    This connector can be easily downloaded or can be found in mysql folder under program files
    After that from the cmd, command must be executed

    jar -cvfm jarfilename.jar manifest.txt *.class
    

    A new jar file will be created based upon your class file and manifest,then it can be easily runnable with double click and the server will respond same as that of cmd mode.

    0 讨论(0)
提交回复
热议问题