• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

How to store a MessageDigest object in Oracle Database

 
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
 
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!
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic