Q:

NullPointerException when creating a database

I' m creating an SQL database via Java. The problem is that it always shows mistake when opening the whole project. Please help.Computer writes something like that: 
Exception in thread "main" java.lang.NullPointerException
    at Oceny.Sql.<init>(Sql.java:16)

Here is the code for class containing this mistake. 
   public class Sql {
   public static final String DRIVER="org.sqlite.JDBC";
   public static final String DB_URL ="jdbc:sqlite:sqlDB/szkola.db";       
   private Connection con;
   private Statement stat;
public Sql() {
    try{
        Class.forName(Sql.DRIVER);
         String sql = "CREATE DATABASE szkola";
         try {
            stat.executeUpdate(sql);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            System.out.println("jebut");
            e.printStackTrace();
        }
    }catch(ClassNotFoundException e){
        System.err.println("Brak sterownika JDBC");
        e.printStackTrace();
    }

        try {
            con = DriverManager.getConnection(DB_URL);
            stat = (Statement) con.createStatement();
        } catch (SQLException e) {
            System.err.println("Problem z otwarciem polaczenia");
            e.printStackTrace();
    }

}

public void createtable(){

    try{
        String przedmiot="CREATE TABLE IF NOT EXISTS przedmiot (id INTEGER PRIMARY KEY AUTOINCREMENT, nazwa varchar(20), sprawdziany int(6), kartkowy int(6), pd int(6))"; //prace = połączenie z inną tabelą prac dodatkowych
        String prace="CREATE TABLE IF NOT EXISTS prace (id INTEGER PRIMARY KEY AUTOINCREMENT, przedmiot varchar(20), praca(250), czas date(100))";
        String plan="CREATE TABLE IF NOT EXISTS plan (id INTEGER PRIMARY KEY AUTOINCREMENT, day varchar(20))";
        String godzina="CREATE TABLE IF NOT EXISTS godzina(id INTEGER PRIMARY KEY AUTOINCREMENT, day varchar(20), godzina varchar(5), przedmiot varchar(20))";//chodiz o godzinę lekcyjną
        stat.execute(przedmiot);
        stat.execute(prace);
        stat.execute(plan);
        stat.execute(godzina);

    }catch(SQLException e){
        System.out.print("problem z tworzeniem tabel");
    }
}
}

A:

The variable 
stat

is null in your case
Initialize it first.
Seems you first use it, then initialize it.

