Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is cause of this exception?

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • 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("jdbcdbcSN","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
 
Rama Krishna Ghanta
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • 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
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Maalik:

String st="select * from author;";
Connection con=DriverManager.getConnection("jdbcdbcSN","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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic