Cannot insert into database using JSP

Hi,

I'm having trouble trying to insert data into a database using JSP.

I can execute select queries using my jsp page so I know my connection to database is working. However, when I try to execute insert statement through jsp the program hangs (it doesn't give me any error messages..it just waits forever).

Also, when I manually type the query into database, it works fine.

Could somebody please tell me what's going on?

Thank you.

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@database.grace.umd.edu:1521:dbclass3","userid","pass");

conn.setAutoCommit(true);

// Create a Statement

Statement stmt = conn.createStatement ();

String query ="insert into files (file_id) values (1)";

// 1 query = "update files set extension='jpeg' where extension='txt'";

stmt.executeUpdate(query);

// 2 stmt.executeUpdate("delete from files where file_id=1");

// 3 stmt.executeQuery ("select * from files");

}catch (Exception ex){

throw ex;

}

In the above code, insert, update, delete query do not work but select query works fine.

[1679 byte] By [sclee423a] at [2007-11-27 2:54:54]
# 1

That would indicate that there is an open session somewhere on the database which has got a lock on the table you want to manipulate.

Somewhere needs to issue a commit before this code will execute.

Also, insert the standard disclaimer how SQL in a JSP is bad style, and such code should be in a bean/servlet. Java code should be in .java files, not in .jsp.

evnafetsa at 2007-7-12 3:31:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...