• 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

what is cause of this exception?

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.sql.*;


public class today{

public static void main(String\u005B\u005D args){

try{

String st="select * from author;";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:DSN","sa","");
Statement stmt=con.createStatement();
stmt.executeUpdate("use pubs");

ResultSet rs=stmt.executeQuery(st);


String st1=rs.getString(0);
System.out.print(st1);

}

catch(Exception e){

System.out.println(e);

}

}

}

Hey ranchar in the above code i am getting the exception as
Invalide object name 'Author'. But why all ready there is a table author in pubs. what is the cause of this exception. I think DSN is not connecting with the pubs database.

Regard

Arun
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arun,

Your code chunk seems to be perfect.Check with your table name. It makes a difference between "author" and "Author" if your OS is Red Hat Linux. Also check whether you have the proper jar file in your class path.

Rama Krishna Ghanta
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arun Maalik:

String st="select * from author;";
Connection con=DriverManager.getConnection("jdbc:odbc:DSN","sa","");
Statement stmt=con.createStatement();
stmt.executeUpdate("use pubs");

ResultSet rs=stmt.executeQuery(st);

String st1=rs.getString(0);



try this code...



if still problem exist then don't hesitate to ask.
[ December 14, 2006: Message edited by: Saif uddin ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic