1 Replies - 636 Views - Last Post: 26 April 2009 - 01:46 PM Rate Topic: -----

#1 samanrz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-April 09

No changes are seen in MS access database after using INSERT INTO

Posted 25 April 2009 - 09:40 AM

this is my so simple code .
it prints "THIS IS THE END"
but i see NO new record in my database Access table (tabl)
try
	{
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	String dataSourceName = "db1.mdb";
	String dbURL = "jdbc:odbc:" + dataSourceName;
	Connection con = DriverManager.getConnection(dbURL,"","");
	Statement log = con.createStatement();
	log.execute("insert into tabl(ID,password) value('one','two')");
				System.out.println("THIS IS THE END");

	}
catch(Exception e)
	{
		System.err.print("connection failed!!!");
	}



Is This A Good Question/Topic? 0
  • +

Replies To: No changes are seen in MS access database after using INSERT INTO

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,905
  • Joined: 06-March 08

Re: No changes are seen in MS access database after using INSERT INTO

Posted 26 April 2009 - 01:46 PM

Don't know how leniant MSAccess is but SQL standards say that an SQL statement should end up with a ; and it is values not value (I think) and I always put a space after the table name So:
	log.execute("insert into tabl(ID,password) value('one','two')");
should be
	log.execute("insert into tabl (ID,password) values ('one','two');");


but that depends of your database. HSQLdb would have required the second syntax

This post has been edited by pbl: 26 April 2009 - 01:49 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1