Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't my sqlite database created?
    primarykey
    data
    text
    <p>I have an issue using sqlite with Java. My application, on first launch, creates a folder in the folder where is the jar file, and in that folder places my sqlite db; the problem is that when I run my project from Netbeans, all works fine without any problem, but when I build the jar and try to do it from it, the application creates the folder but not the db inside, and the program crashes. Why? Here's the code from which I create the db and its folder:</p> <pre><code>public Db() { if (!checker()) { File f = new File("dbecprp"); f.mkdir(); try { String url = "jdbc:sqlite:dbecprp/dbecprp.db"; Class.forName("org.sqlite.JDBC"); conn = (Connection)DriverManager.getConnection(url); s = conn.createStatement(); s.executeUpdate("CREATE TABLE Utente (idUtente integer primary key autoincrement, nome varchar(45) not null, email varchar(45) not null, password varchar(15) not null);"); s.executeUpdate("CREATE TABLE Prodotto (idProdotto integer primary key autoincrement, tipologia varchar(3) not null, titolo varchar(45) not null, creatore varchar(45) not null, prezzo float not null, descrizione varchar(45), qta_magazzino int(3) not null);"); s.executeUpdate("CREATE TABLE Ordine (idOrdine integer primary key autoincrement, qta_prodotto int(3) not null, totale_ordine float not null, data_ordine long not null, nome_consegna varchar(45) not null, indirizzo_spedizione varchar(150) not null, idUtente int not null, idProdotto int not null, FOREIGN KEY (idUtente) REFERENCES Utente(idUtente), FOREIGN KEY (idProdotto) REFERENCES Prodotto(idProdotto));"); } catch (ClassNotFoundException | SQLException ex) { JOptionPane.showMessageDialog(null, "Db creation failed. Program will terminate."); System.exit(1); } filler(); } } public boolean checker() { File f = new File("dbecprp"); return f.isDirectory(); } </code></pre> <p>Here's the clean&amp;build output:</p> <pre><code> ant -f C:\\Users\\paolo2\\Documents\\NetBeansProjects\\Server clean jar init: deps-clean: Updating property file: C:\Users\paolo2\Documents\NetBeansProjects\Server\build\built-clean.properties Deleting directory C:\Users\paolo2\Documents\NetBeansProjects\Server\build clean: init: deps-jar: Created dir: C:\Users\paolo2\Documents\NetBeansProjects\Server\build Updating property file: C:\Users\paolo2\Documents\NetBeansProjects\Server\build\built-jar.properties Created dir: C:\Users\paolo2\Documents\NetBeansProjects\Server\build\classes Created dir: C:\Users\paolo2\Documents\NetBeansProjects\Server\build\empty Created dir: C:\Users\paolo2\Documents\NetBeansProjects\Server\build\generated-sources\ap-source-output Compiling 4 source files to C:\Users\paolo2\Documents\NetBeansProjects\Server\build\classes Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. compile: Created dir: C:\Users\paolo2\Documents\NetBeansProjects\Server\dist Copying 1 file to C:\Users\paolo2\Documents\NetBeansProjects\Server\build Not copying library C:\Users\paolo2\Documents\NetBeansProjects\Server\dist\lib\sqlite-jdbc-3.7.2.jar , it can't be read. Copy libraries to C:\Users\paolo2\Documents\NetBeansProjects\Server\dist\lib. Building jar: C:\Users\paolo2\Documents\NetBeansProjects\Server\dist\Server.jar To run this application from the command line without Ant, try: java -jar "C:\Users\paolo2\Documents\NetBeansProjects\Server\dist\Server.jar" jar: BUILD SUCCESSFUL (total time: 7 seconds) </code></pre> <p>Maybe the problem is the sqlite-jdbc-3.7.2.jar that is not included... I used to add it manually, but maybe it doesn't work because of it. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload