Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I made a Java Project which fetches data from SQLite.db which I included in my project folder.
After creating Jar file I converted it to exe file using an app.
Now when i am running my exe file. It is not able to fetch data from database.
Please help me out.
My Java connection code to connect to db.
Java
<pre>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package operalogsapp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author absasahu
 */
public class databaseConnection {
    public static Connection con;
    public static Connection getDBConnection(String username, String password, Integer portNumber, String serviceName){	
        try {
            //Register the JDBC driver
           System.out.println("before className"); 
            Class.forName("org.sqlite.JDBC");
            System.out.println(con==null);
            System.out.println("Registered to the JDBC driver");
            
            //Open the connection
            if("V50700_HOTEL".equals(username) && "V50700_HOTEL".equals(password) && portNumber==1521 && "opera".equals(serviceName)){
//                con=DriverManager.getConnection("jdbc:sqlite:C:\\Users\\absasahu\\Documents\\db\\sqlite.db");
                   con=DriverManager.getConnection("jdbc:sqlite:C:\\Users\\absasahu\\Documents\\GitHub\\CollegeProject\\src\\operalogsapp\\sqlite.db");
                System.out.println("DriverManager connected to db");
            }

        } catch (ClassNotFoundException | SQLException ex) {
            System.out.println("Exception : "+ex);
            //Logger.getLogger(dbCoonectionCode.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("DFHUDSBFSDF");
        return con;  
    }

    
}



The project file GitHub link, I am attaching here. plz, help me.
https://github.com/rudraSahu7786/standaloneApplication/tree/tableView-setOnfullScreen

What I have tried:

I tried It many ways. But, didn't get any good way.
Posted
Comments
Richard MacCutchan 13-May-22 3:28am    
You need to explain exactly what happens when you run the code. We cannot help unless we know what the problem is.
rudraSahu7786 13-May-22 6:40am    
I have a SQLite.db file in my folder which I want to export. So, when I made exe file out of it, and the table is not getting loaded in the application. So , I have given the full github link of my project.
rudraSahu7786 13-May-22 6:41am    
Database connection file is shown above. You can get idea how the connection is being made.
Richard MacCutchan 13-May-22 12:38pm    
Your connection string refers to a specific file on your C: drive. Are you sure that is valid? I am guessing here since you have still not explained what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900