日期:2014-05-18  浏览次数:20617 次

关于操作的问题-声音文件插入老是出现无效参数捆绑的问题?
声音文件插入数据库老是出现无效参数捆绑的问题?请问各位大侠!该如何解决啊   ?
我的代码如下:
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<%@   page   import= "java.sql.* "%>
<%@   page   import= "java.util.* "%>
<%@   page   import= "java.text.* "%>
<%@   page   import= "java.io.* "%>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>

<body>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String   url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Music_db ";
String   user= "sa ";
String   password= "sa ";
Connection   conn=DriverManager.getConnection(url,user,password);
FileInputStream   in=new   FileInputStream( "F:\\qq.mp3 ");

String   sql= "insert   into   music_table(Music_id,music_name)   value(1,?) ";
PreparedStatement   pstmt=conn.prepareStatement(sql);

pstmt.setBinaryStream(2,in,in.available());
pstmt.execute();
out.print( "Welcome   to   song! ");

%>
</body>
</html>

异常情况为java.sql.SQLException:   [Microsoft][SQLServer   2000   Driver   for   JDBC]Invalid   parameter   binding(s).

急求解决方法(
我试过
应该是这句话的问题
pstmt.setBinaryStream(2,in,in.available());




请多多指教!

------解决方案--------------------
这个不是很懂,帮顶
------解决方案--------------------
void setBinaryStream(int parameterIndex,InputStream x,int length);
这个方法第三个参数是:该输入流将拥有给定字节数,就是的qq.mp3文件的大小;