• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

Problem with SQL uqery or DSN

Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using two different DSN for two different tables, thats my requirement. How can I insert a value of table1 into table2 without changing another cloumns values.
RateInfo First DSN)
name address city
xxx yyy zzz
aaa bbb uuu
UserInfo: (Second DSN)
name address city
fff iii
hhh ddd
Finally the table would be look like
name address city
fff iii zzz
hhh ddd uuu

If I used firt query like
"insert into UserInfo (CITY) in 'C:\\User.mdb' select CITY from RateInfo"
its inserting the city value but remailning null, I mean not in a perticular row.
If I used second query like
"update UserInfo set CITY = (select CITY from RateInfo) where Name = '" +
theNameInTheRowThatNeedsToBeUpdated + "';"
its showing the runtime error like
SQLException: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'UserInfo'. Make sure it exists and that its name is spelled correctly.
If I used both queries like insert and update then the table2 is showing
like that.
name address city
hhh ddd
I am not getting the correct way, please watch my source code.
public static void main(String args[]){
// String url = "jdbc dbc:user"; // Second DSN name for UserPer.mdb
String url1 = "jdbc dbc:rate"; //First DSN name for RatePer.mdb
Connection con;
Statement stmt;

try {
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
try {
// con = DriverManager.getConnection(url);
con = DriverManager.getConnection(url1);
stmt = con.createStatement();
//String query = " insert into UserInfo(City) in 'C:\\UserPer.mdb'
//select City from RateInfo ";
String query1 = " update UserInfo set City = (select City from
RateInfo) where Name='"+Ahammad+"';";
// stmt.executeUpdate(query);
catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());


help would be apprciated,
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
    Bookmark Topic Watch Topic
  • New Topic