| | |
Plz help!!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2008
Posts: 34
Reputation:
Solved Threads: 0
In following code ,I have initialized column to empty blob. But when I try to retrieve the blob,i get an exception.Can anybody help me out??
_____________________________________________________
_____________________________________________________
Java Syntax (Toggle Plain Text)
import java.sql.*; class test { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn= DriverManager.getConnection ("jdbc:odbc:dixit","scott","tiger"); PreparedStatement st=conn.prepareStatement("insert into survey values (?,EMPTY_BLOB())"); st.setInt(1,1); int count=st.executeUpdate(); Statement st1=conn.createStatement(); System.out.println("Hi"); ResultSet rs=st1.executeQuery("Select name from survey"); while(rs.next()) { //int i=rs.getInt(1); //System.out.println("Hi"+i); try { // Get as a BLOB Blob aBlob = rs.getBlob(1); byte[] allBytesInBlob = aBlob.getBytes(1, (int) aBlob.length()); } catch(Exception ex) { // The driver could not handle this as a BLOB... // Fallback to default (and slower) byte[] handling byte[] bytes = rs.getBytes(1); } } } catch(Exception e) { System.out.println("Error"); } } }
Last edited by ~s.o.s~; Jan 8th, 2009 at 10:15 am. Reason: Added code tags, learn to use them.
What exception? The full stack trace, please.
And add a stacktrace to that first catch block, as well. Besides, getting one exception may close the resultset which would lead to the catch block simply throwing another exception.
And add a stacktrace to that first catch block, as well. Besides, getting one exception may close the resultset which would lead to the catch block simply throwing another exception.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- can someone plz help me with this? (Visual Basic 4 / 5 / 6)
- I NEED SUPPORT **"IMPORTANT"** PLZ HELP (Windows NT / 2000 / XP)
- Windows media player (Windows NT / 2000 / XP)
- Bridge.dll...Make it go away, Plz (Viruses, Spyware and other Nasties)
- can sum1 look @ dis plz (Viruses, Spyware and other Nasties)
- Hijackthis log file - plz help (Viruses, Spyware and other Nasties)
- IE not working...PLZ help :cry: (Web Browsers)
- PLZ help it's urgent! (Web Browsers)
- plz help ppl...... (Computer Science)
Other Threads in the Java Forum
- Previous Thread: multiple stack in one dimentional array using node/ linked list
- Next Thread: does java support Multiple inheritence via interfaces
Views: 251 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
6 @param android api apple applet application arc arguments array arrays automation binary bluetooth bold c++ chat class classes client code compare component coordinates database doctype draw eclipse educational error event exception file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework html ide ideas image ingres input integer internet intersect ip j2me java javaexcel javaprojects jmf jni jpanel jtextarea julia linux list loop map method methods mobile netbeans newbie nextline number object oracle print problem program programming project recursion recursive scanner screen sell server set size sms socket sort sql string swing test threads time tree user web websites windows






