(高分)java中实现把word保存到oracle到的blob字段,请高手给出代码!
我写的方法,但是每次都报错:ORA-01006:绑定变量不存在错误在:pstmt.executeUpdate()请高手指点publicstaticvoidsaveFile...
我写的方法,但是每次都报错: ORA-01006: 绑定变量不存在
错误在:pstmt.executeUpdate()
请高手指点
public static void saveFile() {
Connection conn = null;
PreparedStatement pstmt = null;
String sql = "insert into EAIFILETABLE(FILECONTENT,FILENAME,FILETYPE,SOAID,SOSSYSID) values(?,'test','1','soaid','sossysid')";
try {
Class.forName("oracle.jdbc.OracleDriver");
conn = DriverManager.getConnection("**", "**", "**");
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, 1);
File file = new File("e:\\test.doc");
int length = (int) file.length();
InputStream fin = new FileInputStream(file);
pstmt.setString(1, "存word");
pstmt.setBinaryStream(2, fin, length);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
} 展开
错误在:pstmt.executeUpdate()
请高手指点
public static void saveFile() {
Connection conn = null;
PreparedStatement pstmt = null;
String sql = "insert into EAIFILETABLE(FILECONTENT,FILENAME,FILETYPE,SOAID,SOSSYSID) values(?,'test','1','soaid','sossysid')";
try {
Class.forName("oracle.jdbc.OracleDriver");
conn = DriverManager.getConnection("**", "**", "**");
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, 1);
File file = new File("e:\\test.doc");
int length = (int) file.length();
InputStream fin = new FileInputStream(file);
pstmt.setString(1, "存word");
pstmt.setBinaryStream(2, fin, length);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
} 展开
展开全部
你的sql语句只有一个问号,怎么set两个值?
sql = "insert into EAIFILETABLE(FILECONTENT,FILENAME,FILETYPE,SOAID,SOSSYSID) values(?,'test','1','soaid','sossysid')";
pstmt.setString(1, "存word");
pstmt.setBinaryStream(2, fin, length);
sql = "insert into EAIFILETABLE(FILECONTENT,FILENAME,FILETYPE,SOAID,SOSSYSID) values(?,'test','1','soaid','sossysid')";
pstmt.setString(1, "存word");
pstmt.setBinaryStream(2, fin, length);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询