向数据库中插入数据,出现如下错误:(mysql 4.0)
WedJun1517:21:01CST2011WARN:Invalidvalue{1}forservervariablenamed{0},fallingbacktosan...
Wed Jun 15 17:21:01 CST 2011 WARN: Invalid value {1} for server variable named {0}, falling back to sane default of {2}
代码:StringBuffer sql = new StringBuffer();
sql.append("insert into t_message(m_name,m_sex,m_depart,m_qq,")
.append("m_content,m_email,m_state,m_time)")
.append("values(?,?,?,?,?,?,?,?)");
Object args[] = new Object[]{msg.getName(),msg.getSex(),
msg.getDepart(),msg.getQq(),msg.getContent(),msg.getEmail(),msg.getState(),msg.getTime(),"","",""};
for(Object o : args)
System.out.println(o);
Connection conn = null;
PreparedStatement ps = null;
try {
conn = JdbcUtils4DBCP.getConnection();
System.out.println(sql.toString());
ps = conn.prepareStatement(sql.toString());
for(int i =0 ; i<args.length ; i++){
ps.setObject(i+1, args[i]);
}
ps.executeUpdate();
} catch (SQLException e) {
logger.error(e.getMessage());
e.printStackTrace();
} finally {
JdbcUtils4DBCP.free(conn, ps, null);
args = null;
sql = null;
} 展开
代码:StringBuffer sql = new StringBuffer();
sql.append("insert into t_message(m_name,m_sex,m_depart,m_qq,")
.append("m_content,m_email,m_state,m_time)")
.append("values(?,?,?,?,?,?,?,?)");
Object args[] = new Object[]{msg.getName(),msg.getSex(),
msg.getDepart(),msg.getQq(),msg.getContent(),msg.getEmail(),msg.getState(),msg.getTime(),"","",""};
for(Object o : args)
System.out.println(o);
Connection conn = null;
PreparedStatement ps = null;
try {
conn = JdbcUtils4DBCP.getConnection();
System.out.println(sql.toString());
ps = conn.prepareStatement(sql.toString());
for(int i =0 ; i<args.length ; i++){
ps.setObject(i+1, args[i]);
}
ps.executeUpdate();
} catch (SQLException e) {
logger.error(e.getMessage());
e.printStackTrace();
} finally {
JdbcUtils4DBCP.free(conn, ps, null);
args = null;
sql = null;
} 展开
2个回答
2011-06-15
展开全部
呃,好复杂,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询