Manish Tiwari

Greenhorn
+ Follow
since May 19, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Manish Tiwari

Friends here is my code it runs succesfully but when i try to see the image
stored in the file it gives me windows error saying bmp is not a valid file .
can i get the code for saving and retriving the image in BLOB column of database .
PLZ help .
package test;
import java.sql.*;
import java.io.*;
public class GetImage
{
public static void main(String args[])
{
Blob blob = null;
try{
Connection1DB cdb = new Connection1DB();
Connection conn = (Connection)(cdb.getConnection());
System.out.println("Got the connection");
FileOutputStream fos= new FileOutputStream("E:/javatest/dbimage.bmp");
String sql1= "select IMAGE1 from IMAGE ";
Statement stmts = conn.createStatement();
ResultSet rs = stmts.executeQuery(sql1);
InputStream ims=null;
while(rs.next())
{
blob=rs.getBlob(1);
}

long len= blob.length();
byte collect[]= blob.getBytes(1l,(int)len);
System.out.println(""+ collect);
fos.write(collect);
}
catch(Exception e)
{
e.printStackTrace();

}

}

}
I got the solution friends .
It was error in my Connection to database.

Thanks
Friends
This is my code:

import java.sql.*;
public class callDatabaseProcedures
{

public static void main(String args[])
{
Connection conn=null;
CallableStatement cstmt=null;
ResultSet rs=null ;
try
{
//Connection1DB class gives me connection to database.
Connection1DB db = new Connection1DB();
conn=(Connection)(db.getConnection());
System.out.println("Conection is established 1");
cstmt = conn.prepareCall("{call TESTINPARAM(?,?)}");
System.out.println("Conection "+ cstmt.toString());
cstmt.setInt(1,25);
cstmt.setString(2,"xyz");
System.out.println("Trying to Executed successfully");
cstmt.execute();
System.out.println("Executed successfully");
}
catch(Exception e)
{
e.printStackTrace();
}


}

}

Console is printing till my first System.out.println . and there is null pointer exception like this .

Conection is established 1
java.lang.NullPointerException
at callDatabaseProcedures.main(callDatabaseProcedures.java:17)

My procedure is running successfully from backend .

Can any body tell me what is the problem .

Thanks
Manish
Hi ,

It is because of implicit object "session" which is present automatically in jsp.
20 years ago
JSP
Dear Friends

Can any body tell me how to upload scaned document in server and than save it in database.
It is very urgent my job may go if i could not do it this weekend.

I am using tomcat 4.0 , JSP and oracle database .

Pleasssssssssssss help me fast.
20 years ago
JSP