navin rajpandey

Greenhorn
+ Follow
since Oct 12, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by navin rajpandey

I have created a simple POJO Class Person and two comparators 'compareByValue' and 'compareByIndex' to sort the ArrayList. I start by sorting the ArrayList 'persons' and do a little filtering operation inside the loop of some other array for the first pass it's okay but in the second pass of the loop immediately the order of Arraylist 'persons' is lost.
what's wrong with my code? the only operation done using ArrayList 'persons' is the subArray call does it destroy the ordering of the list?

4 years ago
I am trying to post image and text together thorough my android app but the share dialog appears with post link disabled and even the window disappears itself after few seconds with error: Failed to generate preview for user.. something wrong in my code?

SharePhoto photo1 = new SharePhoto.Builder()
.setBitmap(bi)
.setImageUrl(Uri.parse(recUrl))
.build();

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "healthsynergy.photo")
.putString("og:title", "food")
.putString("og:description", "This is a wonderful food.")
.putPhoto("og:image",photo1)
.build();


ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("healthsynergy.publish_actions")
.putObject("photo", object)
.build();
ShareOpenGraphContent content1 = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("photo")
.setAction(action)
.build();


shareDialog.show(content1);
8 years ago
I am trying to add an Image as BLOB in HSQLDB. But in the table I find something like
":hsqll:jdbc:client@f3t5h". Is anything wrong with my Java code below?

My retrieving code is like this that i usually do for other databases. Why doesn't it work for HSQLDB?

Statement stmt = conn.createStatement();

ResultSet results =stmt.executeQuery ("SELECT * from productdetails");

while (results.next()) {
String code = (String) results.getObject(1);
String name = (String) results.getObjeenter code herect(2);

String price = Double.toString((Double) results.getObject(3));
int quantity = (Integer) results.getObject(4);
Boolean featured = (Boolean) results.getObject(5);
String desc = (String) results.getObject(6);
String imgPath = (String) results.getObject(7);

// the line below is throwing class cast exception as i have mentionde below
Blob aBlob = (Blob) results.getBlob(10);
byte[] allBytesInBlob = aBlob.getBytes(1, (int) aBlob.length());

try {
FileOutputStream fis =
(FileOutputStream) getOutputStream(allBytesInBlob);

} catch (IOException ex) {
Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
}
}

public OutputStream getOutputStream(byte[] _data) throws IOException
{
OutputStream out = new ByteArrayOutputStream();
out.write(_data);
return out;
}

This is my inserting code.

Connection conn = db.getConnection();
PreparedStatement pstmt;
String sql = "INSERT INTO PRODUCTDETAILS"
( PRODUCTCODE, NAME, PRICE, QUANTITY, FEATURED, DESCRPTION, IMAGEPATH,IMAGE )
VALUES ( ?, ?,? ,? ,? , ?, ?,?)";
pstmt = conn.prepareStatement(sql);
FileInputStream fis;


File image = new File(values.getImgPath());
fis = new FileInputStream(image);
pstmt.setBinaryStream(8, (InputStream) fis, (int) (image.length()));
pstmt.execute();

The image column is of type BLOB, obviously.
while retriving blob i am getting following error:
Exception in thread "main" java.lang.ClassCastException:
org.hsqldb.jdbc.JDBCBlobClient cannot be cast to com.mysql.jdbc.Blob