Hi fellows,
I need to use JDBC to do some inserts. There's a seam service component where I do a lookup of the DataSource to get the connection object. so far so good, the problem is: after a first insert, I clean the form fields but if I fill it up again and submit it, it doesn't insert anything. Any idea about that? Could it be session issues?
InitialContext initialContext = new InitialContext();
DataSource ds = (DataSource) initialContext.lookup("java:comp/env/MyDatasource");
Connection con = ds.getConnection();
con.setAutoCommit(false);
PreparedStatement pstm = con.prepareStatement("insert ......");
pstm.setString(...)
...
...
pstm.executeUpdate();
pstm.close()
You can use the createNativeQuery method in the EntityManager JPA. Alternatively, use Spring JdbcTemplate for this. It's safer and cleaner.