File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes insert query not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "insert query not working" Watch "insert query not working" New topic

insert query not working

mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
i am using jdbc with microsoft access works fine with select query (showing all the data in db)..but the insert query is not working...even not prompting any error....the data could not enter the database..the code is as follows :

import java.sql.*;

public class db {

public static void main (String [] arg)

String source = "jdbc dbc:ssat" ;
Connection dbconn ;
Statement stat ;
ResultSet author ;

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
dbconn = DriverManager.getConnection(source);
stat = dbconn.createStatement() ;
int ap= stat.executeUpdate("Insert into kool(id,name,class) VALUES(5,'monte','computers')");

} //try ending

catch(ClassNotFoundException cnfe)
} //cnfe catch ending

catch(SQLException sqle)
} //catch ending

} //main end

} //class end
-------------------plz check it out -----------------------------
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It's a common problem with the jdbc-odbc bridge. the best solution is to use a better database such as MySQL or ever Hypersonic, but a short solution is to either set autoCommit(true) on the Connection or perform a dummy select after the insert.

Search the forum for more details.

I agree. Here's the link:
subject: insert query not working
It's not a secret anymore!