mardi 24 février 2015

Where is the location for putting SQLite db file in JAVA project?

I am using eclipse for JAVA development in Windows 7 and I put my project in D:\workspace.


The following code is trying to connect to a SQLite database, While the jdbc address is jdbc:sqlite:sample.db, where is the location that JAVA is looking for sample.db ?



public class Sample{
public static void main(String[] args) throws ClassNotFoundException{

Class.forName("org.sqlite.JDBC");

Connection connection = null;
try{
connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
System.out.println("I got connection.");
}catch(SQLException e){
System.out.println(e.getMessage());
}
}
}


I have see there is example for using absolute paths, But I'd like to know where to put the DB file while I use Relative path.


Also, Does the file location be difference if I put the Class in some package ?


Aucun commentaire:

Enregistrer un commentaire