eclipse插入数据插入失败还不报错 5
packagecom.neuedu.dao;importjava.sql.Connection;importjava.sql.PreparedStatement;impo...
package com.neuedu.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.neuedu.entity.JbTopic;
import com.neuedu.util.DBUtils;
public class djdao {
//插入举报onn
public boolean dojbtopic(JbTopic j) {
Connection conn=null;
PreparedStatement ps=null;
boolean flag=false;
try {
conn=DBUtils.getConnection();
String sql="insert into jbtopic values(?,?,?,?,sysdate)";
ps=conn.prepareStatement(sql);
ps.setInt(1, j.getJbtopicid());
ps.setString(2,j.getJbtopictitle() );
ps.setString(3, j.getJbname());
ps.setString(4, j.getJbbecause());
int i = ps.executeUpdate();
if(i>0) {
flag=true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return flag;
}
} 展开
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.neuedu.entity.JbTopic;
import com.neuedu.util.DBUtils;
public class djdao {
//插入举报onn
public boolean dojbtopic(JbTopic j) {
Connection conn=null;
PreparedStatement ps=null;
boolean flag=false;
try {
conn=DBUtils.getConnection();
String sql="insert into jbtopic values(?,?,?,?,sysdate)";
ps=conn.prepareStatement(sql);
ps.setInt(1, j.getJbtopicid());
ps.setString(2,j.getJbtopictitle() );
ps.setString(3, j.getJbname());
ps.setString(4, j.getJbbecause());
int i = ps.executeUpdate();
if(i>0) {
flag=true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return flag;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询