aspose file tools*
The moose likes JDBC and the fly likes insert query not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "insert query not working" Watch "insert query not working" New topic
Author

insert query not working

mudassir shahab
Ranch Hand

Joined: Oct 13, 2003
Posts: 54
i am using jdbc with microsoft access database...it 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 ;

try
{
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)
{
System.out.println(cnfe);
} //cnfe catch ending

catch(SQLException sqle)
{
System.out.println(sqle);
} //catch ending



} //main end



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

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.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert query not working