I'm posting this as a solution, and not as a comment, because i think it is a larger explanation, and not a comment in itself
psmnt = con.prepareStatement("insert into INSTRUCTOR(INAME, ISURNAME, IMAGE, ITITLE) "+ "values(DEFAULT)");
PreparedStatements don't work that way. You need to bind the same number of parameters as specified by the columns in the insert statement. (Even if they are default values for the column, which is what the
key word is).
In your specific case, the insert statement would be:
psmnt = con.prepareStatement("insert into INSTRUCTOR(INAME, ISURNAME, IMAGE, ITITLE) "+ "values(DEFAULT, DEFAULT, DEFAULT, DEFAULT)");
You need to have the same number of placeholder values (
) as the number of columns specified. This is why it's throwing you an error.
As for defining a path inside your code, let's start here:
File image = new File("C:\\Documents and Settings\\temre\\Desktop\\IMAGE\\image.jpg");
So, you have defined a path to where is picture is. BUT, what if someone else (I, for instance) get the application and want to run it? I don't have that path in my computer and defining it would be a hassle, and the closest corresponding path (for my computer) would be
File image = new File("C:\\Users\\Andrei-PC\\Desktop\\IMAGE\\image.jpg");
Defining a path means specifying a default file/folder path, which is likely to work on most computers, on most operating systems, be it Linux, Mac, or Windows.
You have an API in Java to do that, and you can start with the System Properties API. For instance, you can issue this, and it will work under both Linux and Windows (haven't tested it with MAC):
Under Windows, this will return
, while under Linux it will return
Now, having that path, you can start from there, and create a folder where to store your files.