Hi all:
Plaese, if somebody can help me.
I wnt to insert one rocord in a DB2 table with a BLOB field. But when I
execute this code, the third executeUpdate (insert into...) give me this
message:
CLI0125E Function sequence error.
What is wrong wit this Java code?
import java.io.*;
import java.sql.*;
public class db2SONDAframe
{
static String[] asImages =
{
"photo.jpeg"
};
public static void main(String[] args)
{
Connection con = null;
File fImage;
InputStream isImage;
int iRowCount = 0;
PreparedStatement pstmt = null;
Statement stmt = null;
String sDriver =
"COM.ibm.db2.jdbc.app.DB2Driver";
String sURL =
"jdbc:db2:sframe";
String sUsername = "administrator";
String sPassword = "sbs";
try
{
Class.forName( sDriver ).newInstance();
}
catch( Exception e )
{
System.err.println(
"Failed to load current driver.");
return;
}
try
{
con = DriverManager.getConnection ( sURL,
sUsername,
sPassword);
stmt = con.createStatement();
}
catch ( Exception e)
{
System.err.println( "problems connecting to " +
sURL + ":" );
System.err.println( e.getMessage() );
if( con != null)
{
try { con.close(); }
catch( Exception e2 ) {}
}
return;
}
try
{
stmt.executeUpdate( "delete from turbine_group;" );
try { stmt.close();}
catch (Exception e) {}
stmt = null;
pstmt = con.prepareStatement(
"INSERT INTO TURBINE_GROUP VALUES( ?, ?, ? )" );
pstmt.setInt( 1, 1 );
pstmt.setString( 2, "GLOBAL" );
fImage = new File( asImages[0] );
isImage = new FileInputStream( fImage );
pstmt.setBinaryStream( 3, isImage, (int)( fImage.length() ) );
pstmt.executeUpdate();
}
catch ( Exception e )
{
System.err.println(
"problem with SQL sent to " + sURL + ":" );
System.err.println( e.getMessage() );
}
finally
{
if( stmt != null)
{
try { pstmt.close(); }
catch( Exception e2 ) {}
}
try { pstmt.close(); }
catch( Exception e ) {}
try { con.close(); }
catch( Exception e ) {}
}
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html