Retrieving file data from database

Course Queries Syllabus Queries 3 years ago

9.93K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


I am trying to get file data from database to HTML using a Java servlet. The file data is in binary format. I am converting binary format data to string format, but I am getting error as:

The column index is out of range: 1, number of columns: 0.

Can anyone please suggest me where I am going wrong?

Here is my Java code:

package fileretrieve;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;

import org.apache.tomcat.util.http.fileupload.IOUtils;

import dbConnection.Dbconn;

@MultipartConfig
public class FileRetrieve extends HttpServlet {



    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        String onelevel = request.getParameter("onelevel");
        String twolevel = request.getParameter("twolevel");
        String threelevel = request.
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum