Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert query not working

 
mudassir shahab
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic