java - JAVA Runnable .JAR File incomplete execution. Eclipse IDE Runs to completion
问题描述
Running into an issue with a JAVA application that I'm hoping someone can provide some clarity to. I have a simple Java Application which is being built in the Eclipse IDE. I have JRE 1.8.0_251 installed on PATH.
My application at a basic level performs the following:
- Load a properties file
- Connect to a MSSQL Database based on that SQL File (using java.sql.Connection)
- Queries some data.
- Updates some data.
This all works without issue in Eclipse. However, when I export my file to a runnable .JAR file, it appears to stop after attempting to initialize the database connection. However, it does not throw a SQLException and never returns from the method. I checked my .jar file in 7ZIP to make sure that the SQLJDBC42.jar was packaged in the folder and it was.
The last log line I see when my runnable JAR executes is: Log.info("Connecting to Database...") however, all items run / and are logged in Eclipse execution.
Any ideas? Code below:
public void ConnectDatabase() {
Log.info("Connecting to Database...");
try {
//Connect to Database and Log success.
ConnectionInstance = DriverManager.getConnection(connectionURL);
Log.info("Database Connection Successful.");
} catch (Exception e) {
Log.info(String.format("ERROR | DATABASE: %s", e));
//System.exit(0);
}
Log.info("Leaving Database Method.");
}
解决方案
推荐阅读
- asp.net-mvc - 将请求参数名称映射到具有不同名称的操作参数
- javascript - 如何在反应中使用钩子传递 this.props.children
- python - 在 EagerTensor 中使用不同的数据类型
- redis - 在 StartUp.cs 中通过 ConnectionMultiplexer 和 AddStackExchangeRedisCache(IDistributedCache) 使用 Redis 缓存的主要区别是什么?
- c++ - 如何使用 C++ 中的指针从数组中删除最后一个元素?
- dialogflow-es - 列出会话的上下文并更新上下文参数的值
- ios - 开关允许两个相同的情况?
- asp.net - 如何打包和部署asp.net web应用程序
- java - 如何让我的 jComboBox 从 netbeans 中的数据库中获取数据
- git - git pull 不合并某些文件