This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to store a MessageDigest object in Oracle Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to store a MessageDigest object in Oracle Database" Watch "How to store a MessageDigest object in Oracle Database" New topic
Author

How to store a MessageDigest object in Oracle Database

visu Nekk
Ranch Hand

Joined: Sep 06, 2005
Posts: 122
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

Joined: Sep 16, 2005
Posts: 1780
Help us out by indicating what is throwing the exception!


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to store a MessageDigest object in Oracle Database