Reyes Carlos Reyes Carlos - 28 days ago 15
Android Question

java.sql.SQLException Path to ´C:user/Usuario/Documents/javafolders.school.sqlite does not exist

I am writing because I created a computer base application that simple store data in a sqlite database, I used java through eclipse, the problem is that the application works fine on the pc that it was built on as a jar file, but when I distribute the application to my people I get this message on their computer
java.sql.SQLException path to c:user//usuario/documents/school.sqlite does not exist

The question is . How to change the code tomake the application also work in other computers as well and not only on the pc that it was built on?

here is the code I used

import java.sql.*;
import javax.swing.*;


public class sqlConnection {

Connection conn=null;

public static Connection dbConnector()
{
try{
Class.forName("org.sqlite.JDBC");
Connection conn=DriverManager.getConnection("jdbc:sqlite:C:\\Users\\USUARIO\\Documents\\workspace\\School2015.sqlite");
JOptionPane.showMessageDialog(null, "BIENVENIDO! Estás Conectado");
return conn;
}catch (Exception e)
{
JOptionPane.showMessageDialog(null, e);
return null;
}

}
}

Answer

Do not use 'C:\Users\USUARIO\Documents\workspace\School2015.sqlite' Use relative path instead like ..\..\..\workspace\ or if you need to set up path on runtime use it as String which should be given as input parameter to your program

Comments