我想在数据库中插入一个日期,但它不会出现任何出现的错误消息.当我在Oracle DB中查看我的表时,我找不到我插入的数据.
java.util.Date daterecep;
// getter and setter
public void setdaterecep( java.util.Date daterecep) {
this.daterecep=daterecep;
}
public java.util.Date getdaterecep() {
return daterecep;
}
Run Code Online (Sandbox Code Playgroud)
和
nt val=0;
try {
val = st.executeUpdate("insert into tabdate (date) values('"+daterecep+"')" );
} catch (SQLException ex) {
Logger.getLogger(Insertdate.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(val);
return resultat;
}
Run Code Online (Sandbox Code Playgroud)
我使用了PreparedStatement,但它没有用,我只是尝试执行Java代码
val = st.executeUpdate("insert into tabdate(date) values('12/12/2004')");
Run Code Online (Sandbox Code Playgroud)
并添加
public static void main (String args[]) throws SQLException {
Insertdate B= new Insertdate();
B.connexionBD();
B.insert();//function for the insertion
}
Run Code Online (Sandbox Code Playgroud)
它的工作原理.
以下是我的代码我的bean
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
/**
*
* @author utilisateur
*/
@ManagedBean(name="Beansearch")
@SessionScoped
public class Beansearch extends HttpServlet {
ResultSet rs;
private String cond;
public String getcond() {
return this.cond;
}
public void setcond(String cond) {
this.cond= cond;
}
private List perInfoAll = new ArrayList();
private int i;
public List getperInfoAll(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
String value = req.getParameter("cond");
try {
Class.forName("oracle.jdbc.driver.OracleDriver"); …Run Code Online (Sandbox Code Playgroud)