Any One Please help me i want to store my image to oracle am using JSP.
Here is my code. But this code was return NULL Pointer Error..
Whta is the problem..Am Using Html form to browse and submit image purpose.
Here is my code. But this code was return NULL Pointer Error..
Whta is the problem..Am Using Html form to browse and submit image purpose.
Code:
<html>
<body>
<%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
<%@ page import="java.io.FileWriter,java.io.IOException" %>
<%@ page import ="java.sql.*,java.io.*,java.util.*" %>
<%
String name=request.getParameter("fname");
%>
<%
String DomainName ="jdbc:oracle:thin:@192.168.251.28:1521:ms";
String UserName="mmm";
String PassWord="xxx";
try
{
Class.forName("oracle.jdbc.OracleDriver");
Connection cn=DriverManager.getConnection(DomainName,UserName,PassWord);
PreparedStatement pst = cn.prepareStatement("insert into image(simage) values(?)");
FileInputStream fis=new FileInputStream(name );
System.out.println("File Name" +fis);
byte[] b= new byte[fis.available()];
fis.read(b);
pst.setBytes(1,b);
pst.executeUpdate();
pst.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
</body>
</html>