A code below returns me an error and it won't connect to a SQlite db.
public class CardDatabase {
private String dataBaseName;
public CardDatabase(String dataBaseName) {
this.dataBaseName = dataBaseName;
}
String databaseUrl = "jdbc:sqlite:./" + dataBaseName; // Value 'dataBaseName' is always 'null'
SQLiteDataSource dataSource = new SQLiteDataSource();
Although the code below works great.
public class CardDatabase {
private String dataBaseName;
public CardDatabase(String dataBaseName) {
this.dataBaseName = dataBaseName;
}
SQLiteDataSource dataSource = new SQLiteDataSource();
String databaseUrl = "jdbc:sqlite:./" + dataBaseName; // swaped two lines
Can you help me realize what's the difference between those two codes and why the first one won't compile?