I have some questions about how to work with urls in java. Any help would much appreciated.

When I execute the following code from my app it executes just fine. But when I move my app to a different directory and change the url accordingly, it fails.

original code:
String url = "jdbc:mckoi:local://./db.conf";

modified code:
String url = "jdbc:mckoi:local://./mckoi1.0.3/db.conf";

Also, when I execute the a jar file from within same directory with the following command, it executes perfectly. But it fails if I try to run the jar from different directory because it fails to find the db.conf file. (the jar file and the db.conf are always in the same directory).

Original command:
java -jar mckoidb.jar -create "admin_user" "aupass00"

Modified command:
java -jar ./mckoi1.0.3/mckoidb.jar -create "admin_user" "aupass00"

What am I doing wrong? Am I supposed to treat relative url differently with Java?

9 Years
Discussion Span
Last Post by ryy705
Featured Replies
  • 1
    Ezzaral 2,714   9 Years Ago

    Ok, I think I know what is causing your issue. Check your db.conf file for the root_path property. If you left it set to the default 'jvm' then you need to change that to use "configuration" as below[code] # root_path - If this is set to 'jvm' then the root … Read More


Are you sure that you are on appropriate level from which give path is leading to mentioned files, or you in same directory as these files?


I am in /home/. the jar files and and db.conf is in /home/mckoi1.0.3/. My code runs if I run it from /home/mckoi1.0.03/ with String url = "jdbc:mckoi:local://./db.conf"; But it it does not run if I put my code in /home/ with String url = "jdbc:mckoi:local://./mckoi1.0.3/db.conf";

The jar command executes without error if its run from /home/mckoi1.0.03/ . But it does not run from /home. I am hoping that there are some trivial rules regarding urls that I don't know about.


Check permisions for your folder mckoi1.0.03 if they are setup properly (I asume you using Unix base system as you mentioned home directory).
Reconsider arrangement of path in your coding. If file and one and two are in same directory, file one need access to file two and you want to execet them from diferent directory. Then provide full path for execution for file one, but you do not need to do same for file two as it is called from same level.
If this doesn't help, I will have to ask you to provide parts of code to see what is going on...


I made mckoi1.0.03 fully executable.
The following is the code I am trying to execute:

import java.sql.*;

public class EmbeddedDatabaseDemo {

    public static void main(String[] args) {
    // Register the Mckoi JDBC Driver
    try {
    catch (Exception e) {
        "Unable to register the JDBC Driver.\n" +
        "Make sure the JDBC driver is in the\n" +
        "classpath.\n" + e);

    // This URL specifies we are connecting with a local database
    // within the file system.  './db.conf' is the path of the
    // configuration file of the database to embed.
    String url = "jdbc:mckoi:local://./mckoi1.0.3/db.conf";

    // The username / password to connect under.
    String username = "admin_user";
    String password = "aupass00";

    // Make a connection with the local database.
    Connection connection;
    try {
        connection = DriverManager.getConnection(url, username, password);
    catch (SQLException e) {
        "Unable to make a connection to the database.\n" +
        "The reason: " + e.getMessage());

    try {
        // .... Use 'connection' to talk to database ....

        // Close the connection when finished,

    catch (SQLException e) {
        "An error occured\n" +
        "The SQLException message is: " + e.getMessage());



The mckoi1.0.3 folder can be found here:
It is a portable java database. Just initilize the database with the following command before running the code above:
java -jar mckoidb.jar -create "admin_user" "aupass00"

Thank you very much.


Ok, I think I know what is causing your issue. Check your db.conf file for the root_path property. If you left it set to the default 'jvm' then you need to change that to use "configuration" as below

# root_path - If this is set to 'jvm' then the root
#   path of all database files is the root path of the
#   JVM (Java virtual machine) running the database
#   engine.  If this property is set to 'configuration'
#   or if it is not present then the root path is the
#   path of this configuration file.
#   This property is useful if you are deploying a
#   database and need this configuration file to be the
#   root of the directory tree of the database files.

spot on!

I don't know how you figured it out but thank you. It is working now.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.