Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MS SQL insert data problems

843841Dec 2 2005 — edited Dec 2 2005
I'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();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2005
Added on Dec 2 2005
1 comment
108 views