dimanche 6 mars 2016

Maven Project after deploy won't establish a connection to the Database file

It works well when I start it from the IDE (as a Java Application), but when I deploy it (maven native command) and start it via .exe file, it writes me "null" in the text file. (meaning the connection c is null) Can somebody explain where could the problem hide?

Here is a part of my project's POM. Basically, it contains a dependency to SQLite (that is downloaded and works properly) and JavaFX plugin (that works properly as well)

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.2.0</version>
            <configuration>
                <mainClass>com.SeeYourUse.Main</mainClass>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.twdata.maven</groupId>
                    <artifactId>mojo-executor</artifactId>
                    <version>2.1.0</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.SeeYourUse.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>


</build>

<dependencies>

    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.7.2</version>
    </dependency>

</dependencies>


<url>http://ift.tt/1UK4IPl;

Here is the method that connects to the Database.

private void connect() {

        try {

            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:src/main/resources/DB/SeeYourUse.db");


        } catch (Exception e) {
            //System.err.println("Couldn't connect to the DB");
            e.printStackTrace();
        } finally {
            Logger log = new Logger();
            if (c==null)
                try {
                    log.log("null\n");
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            else {
                try {
                    log.log("OK\n");
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        // System.out.println("DB Opened successfully");
    }

Aucun commentaire:

Enregistrer un commentaire