Reputation: 3
I have been storing my wallet inside my project's resources folder, and am able to access it using the following string just fine inside eclipse
final static String DB_URL = "jdbc:oracle:thin:@db_high?TNS_ADMIN="
+ (Database.class.getClassLoader().getResource("Wallet_DB")
.getPath().replaceFirst("/",""));
However, when I compile it into a jar, and then run it from command line I get the following error:
Exception in thread "main" java.nio.file.InvalidPathException: Illegal
char <:> at index 4:
file:C:/Users/Me/Documents/test.jar!/Wallet_DB\ojdbc.properties
I know I could fix this by just moving the wallet to be right next to my jar file, outside the project, and accessing it with a relative file path, but is there anyway to fix this so I can keep the wallet inside the jar?
Upvotes: 0
Views: 734
Reputation: 1338
The TNS_ADMIN property is for capturing the absolute path of tnsnames.ora file. So, try to use the absolute path. Also, note the file separators for both windows and linux. Use the DataSourceSample.java for reference.
Upvotes: 0
Reputation: 36
JDBC can only accept a path which is accessible by new File(path)
. So here the path starts with "file:..." is invalid.
Upvotes: 2