• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store a MessageDigest object in Oracle Database

 
visu Nekk
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
import java.security.*;
import sun.misc.BASE64Encoder;
import java.sql.*;
import java.sql.Blob;
import javax.servlet.*;
import javax.servlet.http.*;

public class administratorLogin extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
PrintWriter out = res.getWriter();
try{
String s1 = req.getParameter("uname");
String s2 = req.getParameter("pwd");

String s3 = s2;

MessageDigest md = MessageDigest.getInstance("SHA","SUN");
md.update(s3.getBytes());

BASE64Encoder encoder = new BASE64Encoder();
String encoded = encoder.encode(md.digest());

System.out.println(encoded);

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc racle:thin:@10.11.32.86:1521:Resumedb","scott","tiger");
Statement stmt = con.createStatement();
stmt.execute("insert into userlogin values('"+s1+"','"+encoded+"')");

}catch(Exception e)
{
out.println("Error in process " + e);
}
}
}


Using this code i tried to store a MessageDigest object in Oracle database but it's giving me an invalid hex error Plz help me out.
Thanx in advance
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help us out by indicating what is throwing the exception!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic