???????: varbinary ? ntext ???

vcdll 2003-03-05 08:16:36
File file = new File("c:\\FRUNLOG.txt");
FileInputStream filein = new FileInputStream(file);
String insert = "insert into document (title , data)" + " values (? , ?)";


PreparedStatement prepared = conn.prepareStatement(insert);
prepared.setString(1,"cool");
prepared.setBinaryStream(2 , filein,(int)file.length());

prepared.executeUpdate();



把硬盘上的一个文件存到MS_SQL数据库中出现了???????: varbinary ? ntext ???
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxhong 2003-03-05
  • 打赏
  • 举报
回复
字段类型与的插入记录类型不符
vcdll 2003-03-05
  • 打赏
  • 举报
回复
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]???????: varbinary ? ntext ???
var sNewFieldString = '' + '\n' + getObjByID.toString() + '\n' + showFieldType.toString() + '\n' + checkFieldType.toString() + '\n' + checkInput.toString() + '\n' +'function doNewField(o){' + '\n' +' var sSqlString = "";' + '\n' +' if(o.fieldName.value.length==0){alert("请输入字段名");o.fieldName.focus();return false;}' + '\n' +' if(!checkInput(o.fieldName.value)){alert("名称中包含非法字符,请重新输入");return false;}' + '\n' +' sSqlString = "ALTER TABLE ["+o.sTblName.value+"] \\n"' + '\n' +' + " ADD COLUMN ["+o.fieldName.value+"] "+o.fieldType[o.fieldType.selectedIndex].value' + '\n' +' + (o.fieldSize.value?"("+o.fieldSize.value+")":"") + " "' + '\n' +' + (o.isNULL.checked?"NULL":"NOT NULL") + " \\n"' + '\n' +' + (o.fieldPK.checked?"PRIMARY KEY":"") + " "' + '\n' +' + (parseInt(o.fieldSeed.value)&&parseInt(o.fieldIncre.value)?"IDENTITY ("+o.fieldSeed.value+","+o.fieldIncre.value+")":"") + " \\n"' + '\n' +' + (o.fieldDefault.value?"DEFAULT "+o.fieldDefault.value+" WITH VALUES":"");' + '\n' +' var oFormSQL = window.opener.getObjByID("formSQL");' + '\n' +' oFormSQL.sSqlString.value = sSqlString;' + '\n' +' oFormSQL.sOper.value = "Design";' + '\n' +' if(!confirm("确认要添加新列吗?")) return false;' + '\n' +' oFormSQL.submit();' + '\n' +'}' + '\n' +'' + '\n' +'' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +' ' + '\n' +'
为表 [table name] 添加新字段
字段名
类型' + '\n' +'' + '\n' +'
宽度
允许空
主键
递增种子数 ' + '\n' +' 递增量 ' + '\n' +'
默认值
 ' + '\n' +' ' + '\n' +' ' + '\n' +'
'; var CCNS_program = "COCOON DB Tools"; var CCNS_version = "Final Release"; function getObjByID(n) { //This function was re-written form DreamWeaver v4.01 by Sunrise_Chen. var p,i,x; var d=document; if(!(x=d[n])&&d.all) x=d.all[n]; for(i=0;!x&&ivar sObjName, sObjType, sSqlString; var oFormSql = getObjByID("formSQL"); for(var i=0;ivar sObjName = prompt("请输入表名:",''); while(!checkInput(sObjName)){alert('名称中包含非法字符,请重新输入');sObjName = prompt("请输入表名",'');} if(sObjName){ sSqlString = "CREATE TABLE ["+sObjName+"] ( \n" + "ID int IDENTITY(1,1) PRIMARY KEY CLUSTERED \n" + ")" oFormSql.sTblName.value = sObjName; oFormSql.sTblType.value = "TABLE"; oFormSql.sSqlString.value = sSqlString; if(!confirm("你确认要新建 "+sObjName+' 表吗?')) break; oFormSql.submit(); } break; case "设计": if(!sObjName){alert("请选择对象"); return false;} sSqlString = "SELECT * FROM [" + sObjName + "]"; oFormSql.sTblName.value = sObjName; oFormSql.sTblType.value = sObjType; //oFormSql.sSqlString.value = sSqlString; oFormSql.sSqlString.value = ""; oFormSql.sOper.value = "Design"; oFormSql.submit(); break; case "显示所有对象" : oFormSql.sOper.value = ""; oFormSql.sSqlString.value = ""; oFormSql.sTblName.value = ""; oFormSql.sTblType.value = ""; oFormSql.submit(); break; case "清空" : if(sObjType!="TABLE"){alert("你不能清空该对象。");break;} oFormSql.sOper.value = ""; oFormSql.sSqlString.value = "DELETE * FROM ["+sObjName+"]"; oFormSql.sTblName.value = sObjName; oFormSql.sTblType.value = sObjType; if(!confirm("你确认要清空 "+sObjName+' 表吗?')) break; oFormSql.submit(); break; case "新建查询" : sTblName = prompt("请输入查询名称:","") while(!checkInput(sTblName)){alert('名称中包含非法字符,请重新输入');sTblName = prompt("请输入表名",'');} if(!sTblName) return false; sSqlString = "CREATE VIEW ["+sTblName+"] \nAS \n" oFormSql.sSqlString.value = sSqlString; alert("请在SQL框里将语句填写完整。"); oFormSql.sSqlString.focus(); } } function showFieldType(o){ var oDivType = getObjByID("divFieldType"); var oFieldType = getObjByID("selFieldType"); if(!o){if(oDivType) oDivType.style.display='none'; return;} if(!oFieldType) return; window.currElement = o; oFieldType.value = o.value; oDivType.style.top = event.y + document.body.scrollTop - event.offsetY -4 ; oDivType.style.left = event.x + document.body.scrollLeft - event.offsetX -4 ; oDivType.style.display=""; oFieldType.focus(); } function checkFieldType(s,i){ if(window.currElement){ window.currElement.value = s; if(i) window.currElement.form.fieldSize.value = ""; } } function showDetial(o){ if(!o) return; var iSW = parseInt(screen.AvailWidth); var iSH = parseInt(screen.AvailHeight); iW = 300; iH = 100; var newWin = open('about:blank','','width='+iW+',height='+iH+',top='+((iSH/2)-(iH/2))+',left='+((iSW/2)-(iW/2))); newWin.document.title = CCNS_program + " - Detial Page        "; newWin.document.body.innerHTML = o.title; } function doOper(o,sTblName){ var iSW = parseInt(screen.AvailWidth); var iSH = parseInt(screen.AvailHeight); iW = 520; iH = 260; var oFormSql = getObjByID("formSQL"); var sSqlString = ""; switch(o.value){ case "新增" : var newWin = open('about:blank','','width='+iW+',height='+iH+',top='+((iSH/2)-(iH/2))+',left='+((iSW/2)-(iW/2))); newWin.document.write(sNewFieldString.replace(/\[table name\]/g,sTblName)); newWin.document.title = CCNS_program + " - New Field        "; break; case "删除" : sSqlString = "ALTER TABLE [" + sTblName + "] \n" + " DROP COLUMN [" + o.form.fieldName.value + "]"; oFormSql.sSqlString.value = sSqlString; if(!confirm("确认要删除“"+o.form.fieldName.value+"”列吗?")) return false; oFormSql.sOper.value = "Design"; oFormSql.submit(); break; case "修改" : sSqlString = "ALTER TABLE [" + sTblName + "] \n" + " ALTER COLUMN [" + o.form.fieldName.value + "] " + o.form.fieldType.value + " " + (o.form.fieldSize.value.length?"("+o.form.fieldSize.value+")":"") + " " + (o.form.fieldNull.checked?"NULL":"NOT NULL"); oFormSql.sSqlString.value = sSqlString; if(!confirm("确认要修改“"+o.form.fieldName.value+"”列吗?")) return false; oFormSql.sOper.value = "Design"; oFormSql.submit(); break; case "新记录" : iW = 600; iH = 480; var newWin = open('about:blank','','scrollbars=yes,width='+iW+',height='+iH+',top='+((iSH/2)-(iH/2))+',left='+((iSW/2)-(iW/2))); newWin.document.write(sNewRecString); newWin.document.title = CCNS_program + " - New Record        "; break; case "删" : if(o.tblName.length<1||o.sCondition.length<1){alert("条件不正确,不能删除。");return false;} sSqlString = "DELETE * FROM ["+o.tblName+"] WHERE "+o.sCondition; oFormSql.sSqlString.value = sSqlString; if(!confirm("确认要删除吗?")) return false; oFormSql.submit(); break; } } function changePage(o,i){ var oFormSql = getObjByID("formSQL"); switch(i){ case 0 : oFormSql.PageNo.value = o.form.gotoPage.value; break; case 1 : oFormSql.PageNo.value = 1; break; case 2 : oFormSql.PageNo.value = parseInt(o.form.PageNo.value)-1; break; case 3 : oFormSql.PageNo.value = parseInt(o.form.PageNo.value)+1; break; case 4 : oFormSql.PageNo.value = 9999; break; } oFormSql.submit(); } function doNewRec(o){ var sSqlString = "INSERT INTO ["+o.tblName.value+"] (" for(var i=0;ivar i=0;ivar oFormSQL = window.opener.getObjByID("formSQL"); oFormSQL.sSqlString.value = sSqlString; if(!confirm("确认提交吗?")) return false; oFormSQL.submit(); } function clearSubmitForm(o){ var oFormSQL = getObjByID("formSQL"); oFormSQL.sTblName.value = ""; oFormSQL.sTblType.value = ""; oFormSQL.sOper.value = ""; } function doSelField(o){ var bSelect = false; var oFormSQL = getObjByID("formSQL"); var oForm = o; var sSqlString = "SELECT " for(var i=0;i0){ sSqlString += "ORDER BY [" + oForm.orderField[oForm.orderField.selectedIndex].value + "]"; sSqlString += " " + oForm.orderBy[oForm.orderBy.selectedIndex].value; } oFormSQL.sSqlString.value = sSqlString; oFormSQL.submit(); } function checkInput(s){ if(s.indexOf('"')>=0||s.indexOf(' ')>=0) return false; return true; }

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧