• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to store a MessageDigest object in Oracle Database

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help us out by indicating what is throwing the exception!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic