以下是源代码:问题描述如题。
import java.sql.*;
import java.io.*;
public class myJdata2
{
public static void main(String args[])
{
String DriverName="sun.jdbc.odbc.JdbcOdbcDriver";
String DBURL="jdbc:odbc:Student";
Connection conn=null;
Statement stmt;
try{
Class.forName(DriverName);
}
catch(ClassNotFoundException e)
{
System.out.println("无法加载JDBC驱动程序"+e);
return ;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return;
}
try{
conn=DriverManager.getConnection(DBURL,"sa","");
stmt=conn.createStatement();
String sql;
FileInputStream str=new FileInputStream("C++.doc");
sql="insert into student (gongshi) values(?)";
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setBinaryStream(1,str,str.available());
System.out.print("1111111111");
pstmt.executeUpdate();
}
catch(SQLException e){System.out.println(e.getMessage());}
catch(Exception e){System.out.println(e.getMessage());}
finally{
if(conn!=null)
{
try{conn.close();}
catch(Exception e) {e.printStackTrace();}
}
}
}
}