• 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

ODBC-JDBC connection and Looping

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Guys, Thanks for your kind attntion about my software development project!


I have a poroblem in ODBC _ JDBC connection infact the code is working properly, but there is bug in my loob condition and Resultset.next(); mehtod;


I'll give more explanation adout the project;


we need to update records from an excel sheet ( should not be use any convertable softwares !) to MYSQL database. so, I created odbc connection for the excel sheet and jdbc connection to sql database.
The excel sheet columns are
1. email address and 2.category there are thress conditions avalable for this process !

1. if a same record avalable both sql and excle sheet with out change any changes of email or category, it should not be insert or update !

2. if a same record avalable both aql and excel sheet but the email address is equal and deferant category it should update the current cetegory inthe sql database !

3. esle the new record should be inserted.


I made the java code as this but it not working properly and it trys to duplecate the same record


If you have a differenat idea about this pls send to me


Thanks


**** remeber unspecified have been validated in mamber field *******************





[edited to add code tags]

guys if you have any idea adout this code's bug pls reply me !
Thanks agein !
[ November 17, 2006: Message edited by: Jeanne Boyarsky ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sumedha,
I see a couple of things that could cause a problem:
1) while((rsdb.next())||(rsxl.next())) - Why are you looping through both resultsets here? The excel document is already being looped through in the outer loop.
2) if(excelemail.equals(dbemail) && (!excelcategory.equals(dbcategory))) - If the e-mails weren't equal, the code wouldn't get to this point because it wouldn't have made it to the else and would have just done "continue next"
3) p.execute() - Gets called without setting the parameters/binding variables for the prepared statement.

Note that using labels for continue (next:) is usually considered poor practice. It makes the code more difficult to understand and maintain.

Try writing a method (it doesn't need to compile) with just the control logic. That way you have the logic done before complicating it with JDBC.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic