Unknown column 'content' in 'field list'是什么问题?

spring100312 2011-11-26 10:17:28
我写了一个测试blob的程序,可是运行有问题,数据库id是自动增加的,主键,非空;name是varchar,content是mediumtext,image是blob类型。程序如下:
package org.bzc.jdbc;

import org.bzc.db.ConnectionFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
//import java.sql.ResultSet;
import java.sql.SQLException;
import org.bzc.db.*;
import java.io.*;

public class MyBlobTest {
Connection conn=ConnectionFactory.getConnection();//建立连接
private String sql = "INSERT INTO stuinfo(name,content,image) VALUES(?,?,?)";
BufferedReader br=null;
InputStream istxt=null;
InputStream isimg=null;
PreparedStatement pstmt=null;
public void selectStudent(String name) throws FileNotFoundException, SQLException{
try{

pstmt =conn.prepareStatement(sql);//执行环境
pstmt.setString(1, name);
//从文件中读取输入流——读取文本
//istxt=Thread.currentThread().getContextClassLoader().getResourceAsStream("text.txt");
//br=new BufferedReader(new InputStreamReader(istxt));
//int len1=(int)istxt.length();
File textfile = new File("D:/java/workspace/test_jdbc/src/text.txt");
int textfilelength = (int) textfile.length();
InputStream textstream = (InputStream) new FileInputStream(textfile);
//设置Clob
pstmt.setBinaryStream(2, textstream, textfilelength);

//pstmt.setCharacterStream(2, br,);

//从文件中获取输入流——读取图片
//isimg=Thread.currentThread().getContextClassLoader().getResourceAsStream("bzc.bmp");
//设置Blob
//pstmt.setCharacterStream(parameterIndex, reader, length)
//pstmt.setBinaryStream(3,isimg,isimg.length());
File imgfile = new File("D:/java/workspace/test_jdbc/src/bzc.bmp");
long imglength = imgfile.length();
Reader fileReader = (Reader) new BufferedReader(new FileReader(imgfile));
pstmt.setCharacterStream(3, fileReader, (int)imglength);

if(pstmt.executeUpdate()==1){
System.out.println("gong xi!");
}
else{
System.out.println("shi bai!");
}
}
catch(FileNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
DbClose.close(conn, pstmt);
}
public static void main(String args []) throws FileNotFoundException, SQLException{
MyBlobTest insert=new MyBlobTest();
insert.selectStudent("张三");
}

}

报错:com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'content' in 'field list'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
at org.bzc.jdbc.MyBlobTest.selectStudent(MyBlobTest.java:45)
at org.bzc.jdbc.MyBlobTest.main(MyBlobTest.java:62)

请问各位高手,这是什么问题?谢谢了
...全文
805 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
spring100312 2011-11-27
  • 打赏
  • 举报
回复
你是说数据库的表中么,是存在的。content是mediumtext型,拼写也没有错
LucEaspe 2011-11-26
  • 打赏
  • 举报
回复
content 这个字段在表中不存在。

58,454

社区成员

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

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