0

I am getting the exception in the following code

PreparedStatement pstmt;
Connection conn = DriverManager.getConnection(
   "jdbc:jtds:sqlserver://Irfan:1433/Pictures", "sa", "ent@");      

java.sql.Blob bl=GetBolbDataFromDB();
InputStream fs = bl.getBinaryStream();
len = bl.length() ;

query = ("insert into NewPics2 VALUES(?,?,?,?)");
pstmt = conn.prepareStatement(query);
pstmt.setString(1, model);
pstmt.setString(2, catid);
pstmt.setString(3, ornid);
**pstmt.setBinaryStream(4, fs);**

The full Stack Trace is as follows

Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
at jewelleryerpapplication.GUI.Orders.CheckPrice.GetPicInfo(CheckPrice.java:1157)
at jewelleryerpapplication.GUI.Orders.CheckPrice.txtModelNoKeyPressed(CheckPrice.java:2300)
at jewelleryerpapplication.GUI.Orders.CheckPrice.access$1500(CheckPrice.java:37)
at jewelleryerpapplication.GUI.Orders.CheckPrice$18.keyPressed(CheckPrice.java:702)
at java.awt.Component.processKeyEvent(Component.java:6463)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2829)
at java.awt.Component.processEvent(Component.java:6282)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1908)

3 Answers 3

1

Simply put your jdbc driver does not implement the newest version of jdbc: it has no method setBinaryStream(). That means you cannot use it. You might try setBlob() with the fully read image.

Sign up to request clarification or add additional context in comments.

1 Comment

the other answers might be alternatives. You can try them as well (for different versions of jdbc support different overloads of that method)
1

From the stack trace, it appears the method you have called is abstract. According to the documentation, JtdsPreparedStatement.setBinaryStream() takes three arguments: the index, the stream, and the length.

Try adding an int as the length parameter in: pstmt.setBinaryStream(4, fs);

Comments

0

Try converting

java.sql.Blob bl=GetBlobDataFromDB();
String fs = bl.getBytes();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.