I have this piece of code below that throws a null-pointer exception on the line of
stmt = conn.createStatement();
I have school projects from last semester that use this very statement and they don't get null-pointer exceptions when run.
So I am wondering if you can tell me what's going on behind the scenes.
public class Commands {
private Connection conn;
private Statement stmt;
private ResultSet results;
/**
* Create a Table to which the user has chosen to imput
* information.
*/
public void createTable()
{
try
{
stmt = conn.createStatement();
String table = JOptionPane.showInputDialog("Enter in the table and values for that table: ");
String query = table;
//it is assumed the user will type in CREATE tabel_name{value varchar2(9)} <- sample tabel.
}
catch (SQLException e)
{
e.printStackTrace();
}
}