• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

insert query not working

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 -----------------------------
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic