Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about JDBC

 
Salman Faraz
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respected Friends,
I am trying to write a very simple JDBC application with MS-Access at the back end as a database.This application takes two arguments from the command line while running and than insert these arguments in two different columns of the database.The name of the database is db10 and it contains two columns namely "id"(its data type is Integer) and "name"(its data type is Text).The problem which I am facing is that while running this program I get exceptions which shows that nither of the two arguments at run time are accepted by MS-Access.The source code is as follows:

////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////

Can you please tell what mistake I am making.

Thanking You,
Salman Faraz.

[edited to add code tags]
[ August 16, 2005: Message edited by: Jeanne Boyarsky ]
 
praveen kanakarajan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im not an expert .

("insert into db10 ( id, name ) values ( id1, string1 )"

instead can u try this

("insert into db10 ( id, name ) values ("+ id1+",'"+ string1+"'" )

hope it may help you
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend you have a look at Prepared Statements. They will help you overcome this problem and you don't have to worry about putting quotes etc into your SQL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic