MS SQL insert data problems
843841Dec 2 2005 — edited Dec 2 2005I'm working with struts and mssql and i'm trying to insert data into db. select is workin fine, but insert does not. strange things is that i get no error message. this is the code i use:
Connection conn = null;
Statement stmt = null;
try
{
DataSource dataSource = (DataSource)servlet.getServletContext().getAttribute("org.apache.struts.action.DATA_SOURCE");
conn = dataSource.getConnection();
stmt = conn.createStatement();
stmt.executeUpdate("insert into wfKorisnik values('40', 'add1','city1','state1','country1','555','666','777','888')");
stmt.close();
conn.close();
}
catch(Exception e){
e.printStackTrace();
}
code that work:
DataSource dataSource = (DataSource)servlet.getServletContext().getAttribute("org.apache.struts.action.DATA_SOURCE");
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
int id = 0;
rs = stmt.executeQuery("select * from wfKorisnik");
rs.close();
stmt.close();
conn.close();
}
catch(Exception e){
e.printStackTrace();
}