I tried through java, compilation no error, while running time iam getting errors please help me to solve the problem.
My inserting file code is:
My Sql Database is:
Compilation: javac SaveImageToDatabase.java
Run : java SaveImageToDatabase
In thread "main: java.lang.NoClassDefFoundError: SaveImageToDatabase
caused by: java.lang.ClassNotFoundException:SaveImageToDatabase
at java.security.AccessController.doPrivileges(Native Method)
Could not find the main class:SaveImageToDatabase.
Please UseCodeTags. Don't forget to keep your indentation. I've added both for you this time.
You have a class path issue. You've probably set the class path and forgot to include the current directory (.).
I also see two quick improvements:
1) You don't need to cast fis to InputStream. It's a FileInputStream and therefore already an InputStream.
2) You should close the connection after closing the statement. Once the connection is closed its statements are already invalid.
Thanks for guide i have solved the class path issue, i run the program its showing Uploaded successfully !. but if i went and saw in MySQL Workbench in image column its blank and its showing blob only the datatype.
I tried to retrieve the fie its showing java.Lang.NullPointerException.
I have find out how to upload and download a file through java. now i need to get the upload path from jsp page and then the path want to store in variable, by using variable the file wants to save in MySQL database. iam using Eclipse and i created one jsp page and one class file for java, by using request.getParameter()
Iam getting the values from jsp page. but iam getting error. My java program separately running successfully, but i need to connect with jsp.
Please Help Me, iam new to developing field, please Guide me.
My MySql Creation:
My JSP Code :
My Java Code :
I have coded perfectly or not i don't know please check my code and help me.
I have change my code into servlet please help me iam getting error. iam using Eclipse for development.
My jsp page:
My servlet Code
My code is for i need to upload one file its wants to save in MySQL and and the copy of the file wants to download as C:\\ filename it is working in java perfect if i gave the path as manually,but i need to upload a file path by using jsp page
My web.xml code :
I have copy and pasted the class file in class folder and the jar files are commons-fileupload-1.2.2.jar,commons-io-1.3.2.jar, mysql-connector-java-3.0.17-ga-bin.jar,servlet-api.jar in lib folder.
while iam running the program iam getting error as
it is handy you are using eclipse, then you can debug the server, the line that must be going wrong is:
I always found it handy to get all of the parameters and loop through printing them out, as looking at the variables in the debug/variables tab is horrible.
but from experience it is usually the passing form, isn't doing what you expect.